Skip to content

Commit

Permalink
doc(*): Migrate away from deprecated addSpanProcessor in READMEs
Browse files Browse the repository at this point in the history
This migrates from the deprecated `addSpanProcessor` method to the
constructor option in preparation for the upcoming SDK 2.0 release.

This commit migrates everything in the README.md of each package,
other than that there are no runtime code changes.

Technically this is a user-facing change for users that previously
followed the examples.

Ref open-telemetry#2645
  • Loading branch information
chancancode committed Jan 17, 2025
1 parent e57f3e4 commit e9ba507
Show file tree
Hide file tree
Showing 10 changed files with 47 additions and 21 deletions.
4 changes: 3 additions & 1 deletion metapackages/auto-instrumentations-node/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,10 @@ const provider = new NodeTracerProvider({
resource: new Resource({
[SEMRESATTRS_SERVICE_NAME]: 'basic-service',
}),
spanProcessors: [
new SimpleSpanProcessor(exporter),
],
});
provider.addSpanProcessor(new SimpleSpanProcessor(exporter));
provider.register();

registerInstrumentations({
Expand Down
7 changes: 5 additions & 2 deletions metapackages/auto-instrumentations-web/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,11 @@ const exporter = new CollectorTraceExporter({
serviceName: 'auto-instrumentations-web',
});

const provider = new WebTracerProvider();
provider.addSpanProcessor(new SimpleSpanProcessor(exporter));
const provider = new WebTracerProvider({
spanProcessors: [
new SimpleSpanProcessor(exporter),
],
});
provider.register({
contextManager: new ZoneContextManager(),
propagator: new B3Propagator(),
Expand Down
7 changes: 5 additions & 2 deletions plugins/node/instrumentation-undici/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,12 @@ const {
} = require('@opentelemetry/sdk-trace-node');
const { registerInstrumentations } = require('@opentelemetry/instrumentation');

const provider = new NodeTracerProvider();
const provider = new NodeTracerProvider({
spanProcessors: [
new SimpleSpanProcessor(new ConsoleSpanExporter()),
],
});

provider.addSpanProcessor(new SimpleSpanProcessor(new ConsoleSpanExporter()));
provider.register();

registerInstrumentations({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,12 @@ const { NodeTracerProvider } = require('@opentelemetry/sdk-trace-node');
const { registerInstrumentations } = require('@opentelemetry/instrumentation');
const { GenericPoolInstrumentation } = require('@opentelemetry/instrumentation-generic-pool');

const provider = new NodeTracerProvider();
const provider = new NodeTracerProvider({
spanProcessors: [
new SimpleSpanProcessor(new ConsoleSpanExporter()),
],
});

provider.addSpanProcessor(new SimpleSpanProcessor(new ConsoleSpanExporter()));
provider.register();

registerInstrumentations({
Expand Down
7 changes: 5 additions & 2 deletions plugins/node/opentelemetry-instrumentation-knex/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,12 @@ const { ConsoleSpanExporter, SimpleSpanProcessor } = require('@opentelemetry/sdk
const { NodeTracerProvider } = require('@opentelemetry/sdk-trace-node');
const { registerInstrumentations } = require('@opentelemetry/instrumentation');

const provider = new NodeTracerProvider();
const provider = new NodeTracerProvider({
spanProcessors: [
new SimpleSpanProcessor(new ConsoleSpanExporter()),
],
});

provider.addSpanProcessor(new SimpleSpanProcessor(new ConsoleSpanExporter()));
provider.register();

registerInstrumentations({
Expand Down
7 changes: 5 additions & 2 deletions plugins/node/opentelemetry-instrumentation-restify/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,12 @@ const { ConsoleSpanExporter, SimpleSpanProcessor } = require('@opentelemetry/sdk
const { NodeTracerProvider } = require('@opentelemetry/sdk-trace-node');
const { registerInstrumentations } = require('@opentelemetry/instrumentation');

const provider = new NodeTracerProvider();
const provider = new NodeTracerProvider({
spanProcessors: [
new SimpleSpanProcessor(new ConsoleSpanExporter()),
]
});

provider.addSpanProcessor(new SimpleSpanProcessor(new ConsoleSpanExporter()));
provider.register();

registerInstrumentations({
Expand Down
7 changes: 5 additions & 2 deletions plugins/node/opentelemetry-instrumentation-router/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,12 @@ const { NodeTracerProvider } = require('@opentelemetry/sdk-trace-node');
const { registerInstrumentations } = require('@opentelemetry/instrumentation');
const { RouterInstrumentation } = require('@opentelemetry/instrumentation-router');

const provider = new NodeTracerProvider();
const provider = new NodeTracerProvider({
spanProcessors: [
new SimpleSpanProcessor(new ConsoleSpanExporter()),
],
});

provider.addSpanProcessor(new SimpleSpanProcessor(new ConsoleSpanExporter()));
provider.register();

registerInstrumentations({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@ import { registerInstrumentations } from '@opentelemetry/instrumentation';
import { B3Propagator } from '@opentelemetry/propagator-b3';
import { CompositePropagator, W3CTraceContextPropagator } from '@opentelemetry/core';

const provider = new WebTracerProvider();

provider.addSpanProcessor(new SimpleSpanProcessor(new ConsoleSpanExporter()));
const provider = new WebTracerProvider({
spanProcessors: [
new SimpleSpanProcessor(new ConsoleSpanExporter()),
],
});

provider.register({
propagator: new CompositePropagator({
Expand Down
8 changes: 5 additions & 3 deletions plugins/web/opentelemetry-instrumentation-long-task/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@ import { WebTracerProvider } from '@opentelemetry/sdk-trace-web';
import { LongTaskInstrumentation } from '@opentelemetry/instrumentation-long-task';
import { registerInstrumentations } from '@opentelemetry/instrumentation';

const provider = new WebTracerProvider();

provider.addSpanProcessor(new SimpleSpanProcessor(new ConsoleSpanExporter()));
const provider = new WebTracerProvider({
spanProcessors: [
new SimpleSpanProcessor(new ConsoleSpanExporter()),
],
});

registerInstrumentations({
tracerProvider: provider,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,12 @@ import { registerInstrumentations } from '@opentelemetry/instrumentation';
// import { ZoneContextManager } from '@opentelemetry/context-zone-peer-dep';

const provider = new WebTracerProvider({
contextManager: new ZoneContextManager()
contextManager: new ZoneContextManager(),
spanProcessors: [
new SimpleSpanProcessor(new ConsoleSpanExporter()),
],
});

provider.addSpanProcessor(new SimpleSpanProcessor(new ConsoleSpanExporter()));
provider.register();

registerInstrumentations({
Expand Down

0 comments on commit e9ba507

Please sign in to comment.