# Opentelemety nodes js tracing error

**URL:** <https://discuss.elastic.co/t/opentelemety-nodes-js-tracing-error/353433>\
**Category:** APM\
**Tags:** nodejs, open-telemetry\
**Created:** [February 16, 2024, 5:54am UTC](https://discuss.elastic.co/t/opentelemety-nodes-js-tracing-error/353433 "2024-02-16T05:54:01Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![lalitprasanth](https://avatars.discourse-cdn.com/v4/letter/l/ac8455/32.png) [@lalitprasanth](https://discuss.elastic.co/u/lalitprasanth)\
**Post date:** [February 16, 2024, 5:54am UTC](https://discuss.elastic.co/t/opentelemety-nodes-js-tracing-error/353433/1 "2024-02-16T05:54:01Z")

</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.

TIP 2: Check out the [troubleshooting guide](https://www.elastic.co/guide/en/apm/get-started/current/troubleshooting.html) first. Not only will it help you to resolve common problems faster but it also explains in more detail which information we need before we can properly help you.

Kibana version: 8.8.1

Elasticsearch version: 8.8.1

APM Server version: 8.8.1

**APM Agent language and version** : "@opentelemetry/api": "^1.7.0" and "@opentelemetry/auto-instrumentations-node": "^0.41.1"

\*\*Fresh install

I am trying to instrument my nodejs application to send traces to elastic apm.

Steps:

1. I have sample hellow world nodejs application
2. i did npm install --save @opentelemetry/api and npm install --save @opentelemetry/auto-instrumentations-node
3. Started the app with command -  
`env OTEL_TRACES_EXPORTER=otlp OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=<took the endpoint from integrations tab> OTEL_EXPORTER_OTLP_HEADERS="Authorization=Bearer xxxxxxxxxxxx" node --require @opentelemetry/auto-instrumentations-node/register app.js`
4. App is starting fine and also the traces were coming but on start up I am getting errors related to kubernetes. Below are the application log on start up

```auto
@opentelemetry/instrumentation-grpc Module @grpc/grpc-js has been loaded before @opentelemetry/instrumentation-grpc so it might not work, please initialize it before requiring @grpc/grpc-js
OpenTelemetry automatic instrumentation started successfully
no original function cpSync to wrap
no original function cp to wrap
no original function cp to wrap
Example app listening on port 3000!
Container Detector failed to read the Container ID: ENOENT: no such file or directory, open '/proc/self/cgroup'
Process is not running on K8S [Error: ENOENT: no such file or directory, access '/var/run/secrets/kubernetes.io/serviceaccount/token'] {
  errno: -2,
  code: 'ENOENT',
  syscall: 'access',
  path: '/var/run/secrets/kubernetes.io/serviceaccount/token'
}

```

---

<div class="post-metadata">

**Author:** ![carly.richmond](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/carly.richmond/32/104935_2.png) [@carly.richmond](https://discuss.elastic.co/u/carly.richmond)\
**Post date:** [February 19, 2024, 12:23pm UTC](https://discuss.elastic.co/t/opentelemety-nodes-js-tracing-error/353433/2 "2024-02-19T12:23:44Z")

</div>

Hi @lalitprasanth,

Welcome back! I did find a related issue on the OTel JS agent GitHub:

> <https://github.com/open-telemetry/opentelemetry-js-contrib/issues/1173>
>
> \### Is your feature request related to a problem? Please describe
> 
> Detection o…f the \`container.id\` via \`@opentelemetry/resource-detector-docker\` currently works by reading from \`/proc/self/cgroup\`. That does not work when cgroupv2 is turned on. However, based on these two sources there's another place to read from:
> 
> \- \[How to get docker container ID from within the container with cgroup v2\](https://stackoverflow.com/questions/68816329/how-to-get-docker-container-id-from-within-the-container-with-cgroup-v2)
> \- \[Python NullResource error when running torizoncore-builder build\](https://community.toradex.com/t/python-nullresource-error-when-running-torizoncore-builder-build/15240/4)
> 
> In short, the \`container.id\` could be read from /proc/self/mountinfo as well. This also works for \`containerd\` and not only docker.
> 
> Eventually it would be good to have a standard for that, but unfortunately this is a long-standing non-moving \[OCI issue\](https://github.com/opencontainers/runtime-spec/issues/1105), until then a combination of both approaches seems to be reliable enough.
> 
> \### Describe the solution you'd like to see
> Add code that reads the container id from \`/proc/self/mountinfo\` if reading from \`/proc/self/cgroup\` failed.
> 
> \### Describe alternatives you've considered
> As stated in the description, eventually it would be great to have this standardized, but until then this is the best way to go.
> 
> cc: @abhee11, @osherv

There are a couple of references issues in that one that might be worth taking a look at as well, or potentially commenting on for help. But that looks to be an issue with the OTel JS agent rather than the ingestion to Elastic APM.

Hope that helps!

---

<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:** [March 6, 2024, 12:22am UTC](https://discuss.elastic.co/t/opentelemety-nodes-js-tracing-error/353433/3 "2024-03-06T00:22:46Z")

</div>

> [@lalitprasanth](#):
>
> App is starting fine and also the traces were coming but on start up I am getting errors related to kubernetes. Below are the application log on start up

Hi @lalitprasanth,

Sorry for the very long delay in responding.

That `Prcoess is not running on K8S ...` output is a diagnostic "warning" from [opentelemetry-js-contrib/detectors/node/opentelemetry-resource-detector-aws/src/detectors/AwsEksDetector.ts at main · open-telemetry/opentelemetry-js-contrib · GitHub](https://github.com/open-telemetry/opentelemetry-js-contrib/blob/main/detectors/node/opentelemetry-resource-detector-aws/src/detectors/AwsEksDetector.ts) -- i.e. from the `@opentelemetry/resource-detector-aws` package. This detector is turned on by default by the `@opentelemetry/auto-instrumentations-node/register` tool.

I am a little surprised that it is warning so loudly. Perhaps this is an issue you could bring up at [Issues · open-telemetry/opentelemetry-js-contrib · GitHub](https://github.com/open-telemetry/opentelemetry-js-contrib/issues) ?

Similarly the `Container Detector failed to read the Container ID` message is a diagnostic "info"-level message from [opentelemetry-js-contrib/detectors/node/opentelemetry-resource-detector-container/src/detectors/ContainerDetector.ts at 710631309e2af7c063f0dfcf489f3197b87c9987 · open-telemetry/opentelemetry-js-contrib · GitHub](https://github.com/open-telemetry/opentelemetry-js-contrib/blob/710631309e2af7c063f0dfcf489f3197b87c9987/detectors/node/opentelemetry-resource-detector-container/src/detectors/ContainerDetector.ts#L116-L120) -- i.e. from the `@opentelemetry/resource-detector-container` package that is started by the `.../register` code by default.

---

<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 3, 2024, 12:23am UTC](https://discuss.elastic.co/t/opentelemety-nodes-js-tracing-error/353433/4 "2024-04-03T00:23:17Z")

</div>

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