NodeJS App Integration with OpenTelemetry Issue
TLDR Vinay was having trouble integrating OpenTelemetry into a NodeJS app. Srikanth advised updating to the latest versions of the relevant npm packages, which resolved the issue.
Nov 15, 2023 (2 weeks ago)
Vinay
01:03 PMtracing.js
file I'm using.// tracing.js
'use strict'
const process = require('process');
const { Resource } = require('@opentelemetry/resources');
const opentelemetry = require('@opentelemetry/sdk-node');
const { HttpInstrumentation } = require('@opentelemetry/instrumentation-http');
const { diag, DiagConsoleLogger, DiagLogLevel } = require('@opentelemetry/api');
const { OTLPTraceExporter } = require('@opentelemetry/exporter-trace-otlp-http');
const { SemanticResourceAttributes } = require('@opentelemetry/semantic-conventions');
const { getNodeAutoInstrumentations } = require('@opentelemetry/auto-instrumentations-node');
diag.setLogger(new DiagConsoleLogger(), DiagLogLevel.DEBUG);
const exporterOptions = {
url: process.env.OTEL_EXPORTER_OTLP_ENDPOINT || '',
}
const traceExporter = new OTLPTraceExporter(exporterOptions);
const sdk = new opentelemetry.NodeSDK({
traceExporter,
instrumentations: [
getNodeAutoInstrumentations(),
new HttpInstrumentation()
],
resource: new Resource({
[SemanticResourceAttributes.SERVICE_NAME]: 'internal-api'
})
});
// initialize the SDK and register with the OpenTelemetry API
// this enables the API to record telemetry
sdk.start()
// gracefully shut down the SDK on process exit
process.on('SIGTERM', () => {
sdk.shutdown()
.then(() => console.log('Tracing terminated'))
.catch((error) => console.log('Error terminating tracing', error))
.finally(() => process.exit(0));
});
And after running, I didn't see any data on SigNoz. After enabling debug logs, I see this:
{"stack":"OTLPExporterError: Bad Request\n at IncomingMessage. (/Users/vinay/vananam/internal-api/node_modules/@opentelemetry/otlp-exporter-base/src/platform/node/util.ts:131:27)\n at /Users/vinay/vananam/internal-api/node_modules/@opentelemetry/context-async-hooks/src/AbstractAsyncHooksContextManager.ts:75:49\n at AsyncLocalStorage.run (node:async_hooks:335:14)\n at AsyncLocalStorageContextManager.with (/Users/vinay/vananam/internal-api/node_modules/@opentelemetry/context-async-hooks/src/AsyncLocalStorageContextManager.ts:40:36)\n at IncomingMessage.contextWrapper (/Users/vinay/vananam/internal-api/node_modules/@opentelemetry/context-async-hooks/src/AbstractAsyncHooksContextManager.ts:75:26)\n at IncomingMessage.emit (node:events:526:35)\n at endReadableNT (node:internal/streams/readable:1408:12)\n at processTicksAndRejections (node:internal/process/task_queues:82:21)","message":"Bad Request","name":"OTLPExporterError","data":"{\"code\":3,\"message\":\"ReadUint64: unsupported value type, error found in #10 byte of ...|UnixNano\\\":{\\\"low\\\":200|..., bigger context ...|\\\":\\\"test manual span\\\",\\\"kind\\\":1,\\\"startTimeUnixNano\\\":{\\\"low\\\":200587200,\\\"high\\\":395822425},\\\"endTimeUnixNan|...\"}","code":"400"}
Would anyone be able to help out? I'm not sure if it a tracing issue, or my SigNoz setup issue
Nov 16, 2023 (1 week ago)
Srikanth
03:49 AMVinay
08:19 AM0.44.0
Nov 17, 2023 (1 week ago)
Srikanth
06:15 AMnpm install --save @opentelemetry/api@^1.6.0
npm install --save @opentelemetry/sdk-node@^0.45.0
npm install --save @opentelemetry/auto-instrumentations-node@^0.39.4
npm install --save @opentelemetry/exporter-trace-otlp-http@^0.45.0
Vinay
07:09 AMVinay
07:32 AMSigNoz Community
Indexed 1023 threads (61% resolved)
Similar Threads
Troubleshooting: No Tracing Data Exported from Docker Container
Hassan couldn't export tracing data from the otel-collector, but resolved it by running all containers on the same external network. Olawale experienced a similar issue.
Troubleshooting Signoz Deployment for Log Collection on OCI k8s Cluster
sudhanshu faces issues with log collection despite successful application performance monitoring after deploying Signoz on OCI k8s cluster. Prashant suggests updating paths used for log collection and verifying container logs on the nodes. Log files' paths seem correct, but issues persist. Further solutions are needed.
Query about TraceID propagation using GO Otel library
sunny asked advice on passing 'parent span IDs' through async jobs using the Go Otel library. Srikanth recommended injecting context into the message and provided examples on how to do so.