# Span breakdown metrics and service name auto-discovery (Time spent by span type is empty)

**URL:** <https://discuss.elastic.co/t/span-breakdown-metrics-and-service-name-auto-discovery-time-spent-by-span-type-is-empty/288498>\
**Category:** APM\
**Tags:** java\
**Created:** [November 5, 2021, 1:45pm UTC](https://discuss.elastic.co/t/span-breakdown-metrics-and-service-name-auto-discovery-time-spent-by-span-type-is-empty/288498 "2021-11-05T13:45:07Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Matthias\_W](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/matthias_w/32/96451_2.png) [@Matthias\_W](https://discuss.elastic.co/u/Matthias_W)\
**Post date:** [November 5, 2021, 1:45pm UTC](https://discuss.elastic.co/t/span-breakdown-metrics-and-service-name-auto-discovery-time-spent-by-span-type-is-empty/288498/1 "2021-11-05T13:45:07Z")

</div>

Hi,

just wanted to confirm if this is expected behavior:

If I use the Elastic APM Agent in a servlet environment (e.g. JAX-RS running on a Wildfly) and don't set the `service_name`, then the span breakdown metrics won't be available (i.e. the "Time spent by span type" will be empty).

This is because apparently the span breakdown metrics will be computed not per display-name, but only once per application server (in my case, they all have service.name = jboss-application).

I know the documentation states:

> When relying on auto-discovery of the service name in Servlet environments (including Spring Boot), there is currently a caveat related to metrics. The consequence is that the _Metrics_ tab of a service does not show process-global metrics like CPU utilization.

However, this does not necessarily imply span breakdown metrics being unavailable. I would not assume them to be "process-global" metrics.

Any way to get the span breakdown metrics per display-name and not only per application server?

Thanks!

---

<div class="post-metadata">

**Author:** ![Jack\_Shirazi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jack_shirazi/32/91641_2.png) [@Jack\_Shirazi](https://discuss.elastic.co/u/Jack_Shirazi)\
**Post date:** [November 5, 2021, 2:19pm UTC](https://discuss.elastic.co/t/span-breakdown-metrics-and-service-name-auto-discovery-time-spent-by-span-type-is-empty/288498/2 "2021-11-05T14:19:31Z")

</div>

spans should be showing. Are you saying that if you set the service\_name you see them, but if you leave it unset you don't?

---

<div class="post-metadata">

**Author:** ![Matthias\_W](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/matthias_w/32/96451_2.png) [@Matthias\_W](https://discuss.elastic.co/u/Matthias_W)\
**Post date:** [November 5, 2021, 2:43pm UTC](https://discuss.elastic.co/t/span-breakdown-metrics-and-service-name-auto-discovery-time-spent-by-span-type-is-empty/288498/3 "2021-11-05T14:43:08Z")

</div>

> [@Jack\_Shirazi](#):
>
> spans should be showing. Are you saying that if you set the service\_name you see them, but if you leave it unset you don't?

Spans itself (as part of transactions) are showing. I am talking about the span breakdown metrics (which are visualized in the "Time spent by span type" visualization in Kibana APM):

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

Yes, if I set the `service_name`, the data is shown - if I don't set the `service_name`, the span breakdown metrics disappear because they are all being tagged with `service.name = jboss-application` and not with the auto-discovered context name.

---

<div class="post-metadata">

**Author:** ![Jack\_Shirazi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jack_shirazi/32/91641_2.png) [@Jack\_Shirazi](https://discuss.elastic.co/u/Jack_Shirazi)\
**Post date:** [November 5, 2021, 2:56pm UTC](https://discuss.elastic.co/t/span-breakdown-metrics-and-service-name-auto-discovery-time-spent-by-span-type-is-empty/288498/4 "2021-11-05T14:56:30Z")

</div>

per-service within application server metrics are being worked on eg [this PR being worked on right now](https://github.com/elastic/apm-agent-java/pull/2233), I'm not sure if that includes the span breakdowns you're referring to, I'll need to delve a bit to see

---

<div class="post-metadata">

**Author:** ![felixbarny](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/felixbarny/32/27341_2.png) [@felixbarny](https://discuss.elastic.co/u/felixbarny)\
**Post date:** [November 5, 2021, 3:56pm UTC](https://discuss.elastic.co/t/span-breakdown-metrics-and-service-name-auto-discovery-time-spent-by-span-type-is-empty/288498/5 "2021-11-05T15:56:58Z")

</div>

This has been fixed in this PR: [Track metrics for each service individually (#2204) by tobiasstadler · Pull Request #2208 · elastic/apm-agent-java · GitHub](https://github.com/elastic/apm-agent-java/pull/2208).

However, it requires APM Server 8.0 which is not out yet.

---

<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:** [November 26, 2021, 11:56am UTC](https://discuss.elastic.co/t/span-breakdown-metrics-and-service-name-auto-discovery-time-spent-by-span-type-is-empty/288498/6 "2021-11-26T11:56:59Z")

</div>

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