Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto-Instrumentation and Metrics #4607

Open
SaschaBrechmannVHV opened this issue Apr 5, 2024 · 1 comment
Open

Auto-Instrumentation and Metrics #4607

SaschaBrechmannVHV opened this issue Apr 5, 2024 · 1 comment

Comments

@SaschaBrechmannVHV
Copy link

HI all,
we are using OT-JS Autoinstrumentation for Traces/Spans in our Project for some time. Every thing works right.
Now we would Create Metrics for the Autoinstrumentation, but we could not get it work.
We fellowed the documenation from here OT-JS Instrumentation
Could it be, that there is no metrics-instrumentation in Autoinstrumentation?
Autoinstrumentation is cool, we do not need any aditional instrumentation in our code for spans/traces. So my hope was, i only need to activate metrics and get some Metrics for e.g. incoming http-requests or db-connections.
Regards, Sascha

@david-luna
Copy link
Contributor

Hi @SaschaBrechmannVHV

Metrics is not enabled by default and there is an issue created to add that feature #4551

If you followed the link provided at the end it tells to use the require CLI option to load the metrics config like this

node --require ./instrumentation.js app.js

Assuming did follow the auto instrumentation instructions the docs are a bit misleading. The --require flag within NODE_OPTIONS environment var takes precedence over the one in the command therefore the SDK starts before the metrics is configured.

You need to make sure metrics config is loaded before registering auto instrumentations. You can update your auto instrumentations start script this way (taken from the docs)

export OTEL_TRACES_EXPORTER="otlp"
export OTEL_EXPORTER_OTLP_ENDPOINT="your-endpoint"
export OTEL_NODE_RESOURCE_DETECTORS="env,host,os"
export OTEL_SERVICE_NAME="your-service-name"
export NODE_OPTIONS=" --require ./instrumentation.js --require @opentelemetry/auto-instrumentations-node/register"
node app.js

The metrics configuration will be loaded 1st then the SDK will have visibility on it when it starts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants