Skip to content

Fix NodeJS OTLP Integration docs #17253

@mznet

Description

@mznet

SDK

JavaScript SDK

Description

In the NodeJS OTLP Integration doc, the example uses addSpanProcessor method of NodeTracerProvider class.

However, this method was removed in @opentelemetry/sdk-trace-node v2.0.0.
So when using latest version of OTel SDK, the example throws TypeError.

const provider = new NodeTracerProvider({
  // This ensures trace propagation works as expected
  sampler: sentryClient ? new SentrySampler(sentryClient) : undefined,
});

provider.addSpanProcessor(
  new BatchSpanProcessor(
    new OTLPTraceExporter({
      url: "http://OTLP-ENDPOINT.com/api",
    })
  )
);

Suggested Solution

The example should be updated to work with @opentelemetry/sdk-trace-node v2.x. A span processor can be set through constructor instead of addSpanProcessor.

Metadata

Metadata

Assignees

No one assigned
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions