# Unable to Set sync = false in elastic apm while doing custom instrumentation

**URL:** <https://discuss.elastic.co/t/unable-to-set-sync-false-in-elastic-apm-while-doing-custom-instrumentation/355503>\
**Category:** APM\
**Tags:** java\
**Created:** [March 15, 2024, 2:55pm UTC](https://discuss.elastic.co/t/unable-to-set-sync-false-in-elastic-apm-while-doing-custom-instrumentation/355503 "2024-03-15T14:55:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![amaan75](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/amaan75/32/132668_2.png) [@amaan75](https://discuss.elastic.co/u/amaan75)\
**Post date:** [March 15, 2024, 2:55pm UTC](https://discuss.elastic.co/t/unable-to-set-sync-false-in-elastic-apm-while-doing-custom-instrumentation/355503/1 "2024-03-15T14:55:17Z")

</div>

If you are asking about a problem you are experiencing, please use the following template, as it will help us help you. If you have a different problem, please delete all of this text 🙂

TIP 1: select at least one tag that further categorizes your topic. For example `server` for APM Server related questions, `java` for questions regarding the Elastic APM Java agent, or `ui` for questions about the APM App within Kibana.

**APM Server version** : "version": "7.13.0"

**APM Agent language and version** : Java 11.0.19 apm agent 1.48.1

**Original install method (e.g. download page, yum, deb, from source, etc.) and version**:  
download page

**Fresh install or upgraded from other version?**  
Fresh install  
**Is there anything special in your setup?**  
Nothing special in setup

**Description of the problem including expected versus actual behavior. Please include screenshots (if relevant)**:  
I am trying to set up some custom instrumentation and tracing  
and i know for a fact that the method i am trying to instrument is an async operation since its is called in a background thread always.  
I want to show the async badge in apm by some how setting the sync=false in the span but the Elastic apm api does not expose any method to modify this span and make it sync=false.  
all i can do is set some label but then those don't show up in the apm ui with the async badge.

```auto
 private <T> Callable<T> wrapTask(Callable<T> delegate) {
    return () -> {
      log.info("setting config refresh label to sync false");
      final Span span = ElasticApm.currentSpan();
      span.setLabel("sync", false);
      final T call = delegate.call();
      log.info("setting this to sync ");
      return call;
    };
  }

```

---

<div class="post-metadata">

**Author:** ![Sylvain\_Juge](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sylvain_juge/32/55521_2.png) [@Sylvain\_Juge](https://discuss.elastic.co/u/Sylvain_Juge)\
**Post date:** [March 18, 2024, 1:15pm UTC](https://discuss.elastic.co/t/unable-to-set-sync-false-in-elastic-apm-while-doing-custom-instrumentation/355503/2 "2024-03-18T13:15:07Z")

</div>

Hi @amaan75 ,

If you have a clear way to identify your async spans (for example through their name or custom labels), then it should be possible to use a custom ingest pipeline to modify them: [Parse data using ingest pipelines | Elastic Observability [8.12] | Elastic](https://www.elastic.co/guide/en/observability/current/ingest-pipelines.html)

However this `<signal>-apm@custom` custom pipeline does not apply to the version you are using, however it's possible to modify the APM ingest pipelines themselves to achieve this: [Pipelines | APM Server Reference [7.13] | Elastic](https://www.elastic.co/guide/en/apm/server/7.13/apm-integration-pipelines.html).

I am not an expert on the ingestion details, especially the older versions, but this usually the recommended way to manually alter the captured data before storage.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [April 15, 2024, 1:15pm UTC](https://discuss.elastic.co/t/unable-to-set-sync-false-in-elastic-apm-while-doing-custom-instrumentation/355503/3 "2024-04-15T13:15:52Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
