Reputation: 3423
I am trying to play with open telemetry in a Node application. I find it a bit confusing that some examples ask me to install the @opentelemetry/sdk-node
(like this official guide), while some others ask me to install @opentelemetry/sdk-tracing-node
(like this one, also offical guide).
The examples that require @opentelemetry/sdk-node
have code like this:
const sdk = new opentelemetry.NodeSDK({
traceExporter: new opentelemetry.tracing.ConsoleSpanExporter(),
instrumentations: [
// instrumentations...
]
});
sdk.start()
The ones using @opentelemetry/sdk-tracing-node
are like this:
registerInstrumentations({
instrumentations: [
// instrumentations...
]
});
const provider = new NodeTracerProvider();
const exporter = new ConsoleSpanExporter();
const processor = new BatchSpanProcessor(exporter);
provider.addSpanProcessor(processor);
provider.register();
They are somewhat similar, and I guess they achieve the same thing in the end. The questions are:
Upvotes: 5
Views: 1129
Reputation: 15115
sdk-node
also brings the metrics and logs SDK while sdk-tracing-node
only brings tracing SDK.
If you only care about tracing for now and want to avoid pulling useless dependencies, you can use sdk-tracing-node
.
Upvotes: 6