# CaptureTransaction not showing all spans in webflux project

**URL:** <https://discuss.elastic.co/t/capturetransaction-not-showing-all-spans-in-webflux-project/314279>\
**Category:** Elastic Observability\
**Tags:** docker\
**Created:** [September 13, 2022, 10:10am UTC](https://discuss.elastic.co/t/capturetransaction-not-showing-all-spans-in-webflux-project/314279 "2022-09-13T10:10:19Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![gfan8w](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gfan8w/32/110790_2.png) [@gfan8w](https://discuss.elastic.co/u/gfan8w)\
**Post date:** [September 13, 2022, 10:10am UTC](https://discuss.elastic.co/t/capturetransaction-not-showing-all-spans-in-webflux-project/314279/1 "2022-09-13T10:10:20Z")

</div>

I have a [sample application](https://github.com/gfan8w/elasticsearch-apm-tutorials/tree/master/spring-webflux-apm-app), it is a WebFlux SpringBoot application (SpringBoot version=2.5.3, WebFlux version=5.3.9) embedded an Elastic APM agent (version=1.28.0). Start the Spring WebFlux app:  
`mvn spring-boot:run -Dspring-boot.run.arguments=--server.port=8085`

go to the docker folder: `cd ../elastic-apm-java/docker` , run `docker-compose up -d` to set up a dev APM server.

Do some controller accessing. then go the Kibana/APM portal.  
I found that the Transaction or Span are not recored.

 ![tqJZHKG5pO](https://us1.discourse-cdn.com/elastic/original/3X/0/2/02cd79b82c3d4f2facebb82c6b43786328473213.png)

But, I tried another Spring MVC app: [elastic-apm-java](https://github.com/gfan8w/elasticsearch-apm-tutorials/tree/master/elastic-apm-java). After running the app, the go to the Kibana/APM portal, I can see the Transaction or Span are recored.

 ![p0SsojI2Hr](https://us1.discourse-cdn.com/elastic/original/3X/b/3/b32639c5f09ab4977063fc59d452f80f9c2274f9.png)

**I am wondering where is the WebFlux APM wrong? Is the version of ES & Kibana not correct? Mismatched with APM agent?**  
My sample code is [here](https://github.com/gfan8w/elasticsearch-apm-tutorials).

Update-1： I have enable the [experimental feature](https://github.com/gfan8w/elasticsearch-apm-tutorials/blob/master/spring-webflux-apm-app/src/main/resources/elasticapm.properties) in my code.  
file: **elasticapm.properties** under the resources folder, value is: `enable_experimental_instrumentations=true`.  
When the app start up, it prints log:

> [Attach Listener] INFO co.elastic.apm.agent.configuration.StartupInfo - enable\_experimental\_instrumentations: 'true' (source: Attachment configuration)

So, I think the `enable_experimental_instrumentations` is in effect.

Update 2:  
I modify the [docker-compose.yaml](https://github.com/gfan8w/elasticsearch-apm-tutorials/blob/master/elastic-apm-java/docker/docker-compose.yml), now the `user-microservice` and `user-webfluxservice` can run in docker, just start the docker-compose file, then observe the APM dashboard.

It is slightly different, it can display the `random` **CaptureSpan** , but the offset position is the same as the _UserController#all_, it's not correct.

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/e/9/e96778fd0791cd880adbd8c415597391cb68e8cb.png)

the corresponding code is:

```auto
@CaptureSpan("random")
    public int random(int min, int max) {

        return new Random().nextInt(max - min) + min;
    }

```

---

<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:** [September 13, 2022, 11:11am UTC](https://discuss.elastic.co/t/capturetransaction-not-showing-all-spans-in-webflux-project/314279/2 "2022-09-13T11:11:08Z")

</div>

Hi @gfan8w , the Webflux instrumentation is currently in `experimental` status, so you have to set `enable_experimental_instrumentations=true` otherwise it gets disabled by default (see documentation: [Core configuration options | APM Java Agent Reference [1.x] | Elastic](https://www.elastic.co/guide/en/apm/agent/java/current/config-core.html#config-enable-experimental-instrumentations)).

We are planning to enable it by default for the next release, so it won't be necessary in the future.

---

<div class="post-metadata">

**Author:** ![gfan8w](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gfan8w/32/110790_2.png) [@gfan8w](https://discuss.elastic.co/u/gfan8w)\
**Post date:** [September 13, 2022, 11:17am UTC](https://discuss.elastic.co/t/capturetransaction-not-showing-all-spans-in-webflux-project/314279/3 "2022-09-13T11:17:13Z")

</div>

I have updated my question. I have already enabled the `enable_experimental_instrumentations=true`, I forgot to mention it.

---

<div class="post-metadata">

**Author:** ![Eyal\_Koren](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/eyal_koren/32/36830_2.png) [@Eyal\_Koren](https://discuss.elastic.co/u/Eyal_Koren)\
**Post date:** [September 13, 2022, 1:04pm UTC](https://discuss.elastic.co/t/capturetransaction-not-showing-all-spans-in-webflux-project/314279/4 "2022-09-13T13:04:05Z")

</div>

1.28.0 is quite old and this particular version suffered from some issues.  
So first thing to do is try the latest version (still with `enable_experimental_instrumentations=true`).

If that still doesn't work, please set `log_level=debug` in your WebFlux app, restart and invoke a couple of requests and see if you can get a hint from the log. If possible, please share the entire log from startup and until after a few requests were handled.

---

<div class="post-metadata">

**Author:** ![gfan8w](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gfan8w/32/110790_2.png) [@gfan8w](https://discuss.elastic.co/u/gfan8w)\
**Post date:** [September 14, 2022, 7:08am UTC](https://discuss.elastic.co/t/capturetransaction-not-showing-all-spans-in-webflux-project/314279/5 "2022-09-14T07:08:53Z")

</div>

I upgrade the APM agent client to 1.33. and the dashboard on the server side is still not show information correctly. I append full debug log [here](https://github.com/gfan8w/elasticsearch-apm-tutorials/blob/master/debug.txt)

The log:

> log by user code: saved the user

is the info hit by user operation.

---

<div class="post-metadata">

**Author:** ![Eyal\_Koren](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/eyal_koren/32/36830_2.png) [@Eyal\_Koren](https://discuss.elastic.co/u/Eyal_Koren)\
**Post date:** [September 14, 2022, 7:57am UTC](https://discuss.elastic.co/t/capturetransaction-not-showing-all-spans-in-webflux-project/314279/6 "2022-09-14T07:57:06Z")

</div>

The shared log is `info` level, thus doesn't contain a lot of info.  
You'd need to modify the [`log_level`](https://www.elastic.co/guide/en/apm/agent/java/current/config-logging.html#config-log-level) config option for that.  
It would be quite verbose, try to dig in it for possible clues.

---

<div class="post-metadata">

**Author:** ![gfan8w](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gfan8w/32/110790_2.png) [@gfan8w](https://discuss.elastic.co/u/gfan8w)\
**Post date:** [September 14, 2022, 12:32pm UTC](https://discuss.elastic.co/t/capturetransaction-not-showing-all-spans-in-webflux-project/314279/7 "2022-09-14T12:32:02Z")

</div>

Hi,  
I update the [debug log](https://github.com/gfan8w/elasticsearch-apm-tutorials/blob/master/debug.txt), the print an error:

> Cannot resolve type description for javax.servlet.ServletContext

I searched for a while, it seems that this kind of error should not appear again, because now the the [APM agent have support the WebFlux](https://www.elastic.co/guide/en/apm/agent/java/current/supported-technologies-details.html) .

I also trigger the controller to make some data record by APM agent.  
this log is printed by user accessing:

> log by user code: saved the user:onComplete

I am new, I investigate the debug log, I could not find any reason why the data displayed on the Kibana portal is not correct.

---

<div class="post-metadata">

**Author:** ![gfan8w](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gfan8w/32/110790_2.png) [@gfan8w](https://discuss.elastic.co/u/gfan8w)\
**Post date:** [September 14, 2022, 2:28pm UTC](https://discuss.elastic.co/t/capturetransaction-not-showing-all-spans-in-webflux-project/314279/8 "2022-09-14T14:28:31Z")

</div>

I would like to post another question, I mentioned in the **Update2** :

> I modify the [docker-compose.yaml](https://github.com/gfan8w/elasticsearch-apm-tutorials/blob/master/elastic-apm-java/docker/docker-compose.yml), now the `user-microservice` and `user-webfluxservice` can run in docker, just start the docker-compose file, then observe the APM dashboard.

the `user-microservice`(mvc) and `user-webfluxservice`(webflux) can run in docker or just the dev host machine.

This is the event of `user-microservice`(mvc) running on the dev host machine (JDK11)

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/f/4/f427b0975c71db40ac17cecb3a1597a738485506.png)

This is the event captured of `user-microservice`(mvc) running in the docker(JDK11):

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/3/b/3bc1c21be053f90b2c6acbf138ddff95ba7258e3.png)

The [code](https://github.com/gfan8w/elasticsearch-apm-tutorials/blob/e7146233deef7cafa98786e7441aad029c7580f7/elastic-apm-java/src/main/java/com/cosmin/tutorials/apm/service/UserService.java#L23) are the same.

```auto
public User save(User user) {
        sleep(); // sleep has @CaptureSpan("otherOperations"), so it should display a span on the Kibana portal
        return userRepository.save(user);
    }

```

---

<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:** [September 15, 2022, 6:56am UTC](https://discuss.elastic.co/t/capturetransaction-not-showing-all-spans-in-webflux-project/314279/9 "2022-09-15T06:56:58Z")

</div>

Hi,

We just released version 1.34.0 yesterday ([release notes](https://www.elastic.co/guide/en/apm/agent/java/current/release-notes-1.x.html#release-notes-1.34.0)), the Webflux instrumentation is enabled by default.

Thus I suggest doing the following to debug your issue:

- update to agent version 1.34.0
- start the agent with `log_level=info` (or an higher log-level) and compare the first few lines of the agent logs when the agent starts for any difference in agent configuration.

If there is any difference in configuration with a previous agent version it could have been the likely issue, but with `1.34.0` Webflux should be enabled and not depend anymore on configuration.

---

<div class="post-metadata">

**Author:** ![gfan8w](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gfan8w/32/110790_2.png) [@gfan8w](https://discuss.elastic.co/u/gfan8w)\
**Post date:** [September 17, 2022, 11:08am UTC](https://discuss.elastic.co/t/capturetransaction-not-showing-all-spans-in-webflux-project/314279/10 "2022-09-17T11:08:13Z")

</div>

Does elastic APM support r2dbc in WebFlux? From [here](https://github.com/elastic/apm-agent-java/issues/2069), it seems still not support r2dbc?

---

<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:** [September 19, 2022, 7:54am UTC](https://discuss.elastic.co/t/capturetransaction-not-showing-all-spans-in-webflux-project/314279/11 "2022-09-19T07:54:34Z")

</div>

Hi @gfan8w ,

As you have found, there is currently no support for r2dbc in Elastic APM agent, there hasn't had many requests for it thus it is not currently planned. However it is still possible to create an internal/external plugin for it, or try using manual instrumentation through a [Tracing API](https://www.elastic.co/guide/en/apm/agent/java/current/apis.html).

---

<div class="post-metadata">

**Author:** ![gfan8w](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gfan8w/32/110790_2.png) [@gfan8w](https://discuss.elastic.co/u/gfan8w)\
**Post date:** [September 20, 2022, 3:23am UTC](https://discuss.elastic.co/t/capturetransaction-not-showing-all-spans-in-webflux-project/314279/12 "2022-09-20T03:23:23Z")

</div>

Thanks for your reply. now, I think I know why the span data is not showing on the webpage. I should write tracing code to record more information.

Thank you!

---

<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:** [October 10, 2022, 11:24pm UTC](https://discuss.elastic.co/t/capturetransaction-not-showing-all-spans-in-webflux-project/314279/13 "2022-10-10T23:24:17Z")

</div>

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