# APM Spans do not show cust code

**URL:** <https://discuss.elastic.co/t/apm-spans-do-not-show-cust-code/346699>\
**Category:** APM\
**Tags:** elastic-stack-monitoring, nodejs\
**Created:** [November 8, 2023, 10:59am UTC](https://discuss.elastic.co/t/apm-spans-do-not-show-cust-code/346699 "2023-11-08T10:59:36Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![NIelsVM](https://avatars.discourse-cdn.com/v4/letter/n/a8b319/32.png) [@NIelsVM](https://discuss.elastic.co/u/NIelsVM)\
**Post date:** [November 8, 2023, 10:59am UTC](https://discuss.elastic.co/t/apm-spans-do-not-show-cust-code/346699/1 "2023-11-08T10:59:36Z")

</div>

**Kibana version** : v8.10.4

**Elasticsearch version** : v8.10.4

**APM Server version** : v8.10.4

**APM Agent language and version** : NodeJS, Node 20, version 4.1.0

**Browser version** : Firefox 119.0

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

**Fresh install or upgraded from other version?** Fresh install

**Is there anything special in your setup?** For example, are you using the Logstash or Kafka outputs? Are you using a load balancer in front of the APM Servers? Have you changed index pattern, generated custom templates, changed agent configuration etc.

No specific changes

**Description of the problem including expected versus actual behavior. Please include screenshots (if relevant)**:

APM Traces do not include function calls from the NodeJS project.

 ![Screenshot 2023-11-08 at 11.55.31](https://us1.discourse-cdn.com/elastic/original/3X/d/0/d0c94472c4c4796a79043ec98bc105f86fcf9ba8.png)  
(Anonymized for obvious reasons)

HTTP calls and database calls are properly shown in spans, however all code references, such as functions are not shown.

The running code does include source maps.

**Steps to reproduce** :  
Reproduction is a clean install of elastic cloud and setting up a nodejs application plus monitoring.

## **Errors in browser console (if relevant)**:

## **Provide logs and/or server output (if relevant)**:

If any more info is required I'd be happy to provide!

---

<div class="post-metadata">

**Author:** ![trentm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/trentm/32/77647_2.png) [@trentm](https://discuss.elastic.co/u/trentm)\
**Post date:** [November 10, 2023, 2:11am UTC](https://discuss.elastic.co/t/apm-spans-do-not-show-cust-code/346699/2 "2023-11-10T02:11:19Z")

</div>

Hi @NIelsVM. Thanks for the question.

I think this is a misunderstanding. It sounds like the APM agent is operating as expected. The APM agent does not create tracing spans for any/every JavaScript function call. Spans are only created for (a) specific interesting events in libraries that the APM agent instruments (for example, http client/server requests, database calls, etc.) and (b) for manual instrumentation (using the [Elastic APM agent's API](https://www.elastic.co/guide/en/apm/agent/nodejs/current/agent-api.html#apm-start-span) or the [OpenTelemetry Tracing API](https://www.elastic.co/guide/en/apm/agent/nodejs/current/opentelemetry-bridge.html)).

---

<div class="post-metadata">

**Author:** ![trentm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/trentm/32/77647_2.png) [@trentm](https://discuss.elastic.co/u/trentm)\
**Post date:** [November 10, 2023, 2:12am UTC](https://discuss.elastic.co/t/apm-spans-do-not-show-cust-code/346699/3 "2023-11-10T02:12:32Z")

</div>

I should say that our Universal Profiler -- [Universal Profiling - continuous profiling that just works | Elastic](https://www.elastic.co/observability/universal-profiling) -- does provide function-level profiling.

---

<div class="post-metadata">

**Author:** ![NIelsVM](https://avatars.discourse-cdn.com/v4/letter/n/a8b319/32.png) [@NIelsVM](https://discuss.elastic.co/u/NIelsVM)\
**Post date:** [November 14, 2023, 10:21am UTC](https://discuss.elastic.co/t/apm-spans-do-not-show-cust-code/346699/4 "2023-11-14T10:21:42Z")

</div>

Ah okay thank you Trent! I think I got confused due to this screenshot:

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

Here it looks like there are functions being logged but I guess they are endpoints on microservices that are called.

I will look into the Universal Profiling feature!

---

<div class="post-metadata">

**Author:** ![trentm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/trentm/32/77647_2.png) [@trentm](https://discuss.elastic.co/u/trentm)\
**Post date:** [November 20, 2023, 10:46pm UTC](https://discuss.elastic.co/t/apm-spans-do-not-show-cust-code/346699/5 "2023-11-20T22:46:32Z")

</div>

> [@NIelsVM](#):
>
> Here it looks like there are functions being logged but I guess they are endpoints on microservices that are called.

Yes, those are endpoints and/or manual instrumentations on a number of services in a distributed trace -- i.e. a trace that went through a number of separate services, implemented in different languages.

---

<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:** [December 18, 2023, 10:47pm UTC](https://discuss.elastic.co/t/apm-spans-do-not-show-cust-code/346699/6 "2023-12-18T22:47:09Z")

</div>

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