-
Hi, in my Node.js app (simple http server) after switching from deprecated Jeager related Opentelemetry packages to OTLP protocol related packages my traces broken Here is how i configure Opentelemetry in my app: import os from "node:os";
import { BatchSpanProcessor } from "@opentelemetry/sdk-trace-base";
import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-http";
import { JaegerPropagator } from "@opentelemetry/propagator-jaeger";
import { NodeTracerProvider } from "@opentelemetry/sdk-trace-node";
import { Resource } from "@opentelemetry/resources";
import { SemanticResourceAttributes } from "@opentelemetry/semantic-conventions";
import { propagation, ROOT_CONTEXT, trace } from "@opentelemetry/api";
const resource = new Resource({
[SemanticResourceAttributes.HOST_NAME]: os.hostname(),
[SemanticResourceAttributes.SERVICE_NAME]: "some string",
[SemanticResourceAttributes.SERVICE_VERSION]: "some string",
[SemanticResourceAttributes.DEPLOYMENT_ENVIRONMENT]: "some string",
});
const provider = new NodeTracerProvider({ resource });
provider.addSpanProcessor(new BatchSpanProcessor(new OTLPTraceExporter()));
provider.register({ propagator: new JaegerPropagator() });
const tracer = provider.getTracer("some string", "some string"); And here is how i define spans: function expressTracingMiddleware(req, res, next) {
const externalContext = propagation.extract(ROOT_CONTEXT, req.headers);
const rootSpan = tracer.startSpan("response", undefined, externalContext);
rootSpan.setAttributes({ "request.path": req.originalUrl });
const rootContext = trace.setSpan(externalContext, rootSpan);
res.locals.tracing = {
rootSpan,
rootContext,
};
res.once("render:start", () => {
res.locals.tracing.renderSpan = tracer.startSpan(
"render",
undefined,
rootContext
);
});
res.once("render:finish", () => {
res.locals.tracing.renderSpan.end();
});
res.once("finish", () => {
rootSpan.end();
});
next();
} I run local docker container according to docs: After i send several http requests to target http server there is no traces for my service in http://localhost:16686/search There is only What am I doing wrong and how to properly confugure OTEL for sending traces to Jaeger via OTLP HTTP in Node.js? #3970 |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
looks like i forgot set env variable COLLECTOR_OTLP_ENABLED=true |
Beta Was this translation helpful? Give feedback.
looks like i forgot set env variable COLLECTOR_OTLP_ENABLED=true