opentelemetry-js
opentelemetry-js copied to clipboard
Auto-Instrumentation and Metrics
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
Hi @SaschaBrechmannVHV
Metrics is not enabled by default and there is an issue created to add that feature https://github.com/open-telemetry/opentelemetry-js/issues/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.
This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 14 days.
This issue was closed because it has been stale for 14 days with no activity.