Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: rename registry to provider #699

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions benchmark/tracer.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,26 @@

const benchmark = require('./benchmark');
const opentelemetry = require('@opentelemetry/core');
const { BasicTracerRegistry, BatchSpanProcessor, InMemorySpanExporter, SimpleSpanProcessor } = require('@opentelemetry/tracing');
const { NodeTracerRegistry } = require('@opentelemetry/node');
const { BasicTracerProvider, BatchSpanProcessor, InMemorySpanExporter, SimpleSpanProcessor } = require('@opentelemetry/tracing');
const { NodeTracerProvider } = require('@opentelemetry/node');

const exporter = new InMemorySpanExporter();
const logger = new opentelemetry.NoopLogger();

const setups = [
{
name: 'BasicTracerRegistry',
registry: new BasicTracerRegistry({ logger })
name: 'BasicTracerProvider',
provider: new BasicTracerProvider({ logger })
},
{
name: 'NodeTracerRegistry',
registry: new NodeTracerRegistry({ logger })
name: 'NodeTracerProvider',
provider: new NodeTracerProvider({ logger })
}
];

for (const setup of setups) {
console.log(`Beginning ${setup.name} Benchmark...`);
const tracer = setup.registry.getTracer("benchmark");
const tracer = setup.provider.getTracer("benchmark");
const suite = benchmark()
.add('#startSpan', function () {
const span = tracer.startSpan('op');
Expand Down Expand Up @@ -55,7 +55,7 @@ for (const setup of setups) {
.add('#startSpan with SimpleSpanProcessor', function () {
const simpleSpanProcessor = new SimpleSpanProcessor(exporter);

registry.addSpanProcessor(simpleSpanProcessor);
provider.addSpanProcessor(simpleSpanProcessor);
const span = tracer.startSpan('op');
span.end();

Expand All @@ -64,7 +64,7 @@ for (const setup of setups) {
.add('#startSpan with BatchSpanProcessor', function () {
const batchSpanProcessor = new BatchSpanProcessor(exporter);

registry.addSpanProcessor(batchSpanProcessor);
provider.addSpanProcessor(batchSpanProcessor);
const span = tracer.startSpan('op');
span.end();
batchSpanProcessor.shutdown();
Expand Down
10 changes: 5 additions & 5 deletions examples/basic-tracer-node/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const opentelemetry = require('@opentelemetry/core');
const { BasicTracerRegistry, SimpleSpanProcessor } = require('@opentelemetry/tracing');
const { BasicTracerProvider, SimpleSpanProcessor } = require('@opentelemetry/tracing');
const { JaegerExporter } = require('@opentelemetry/exporter-jaeger');
const { ZipkinExporter } = require('@opentelemetry/exporter-zipkin');
const { CollectorExporter } = require('@opentelemetry/exporter-collector');
Expand All @@ -20,13 +20,13 @@ if (EXPORTER.toLowerCase().startsWith('z')) {
exporter = new CollectorExporter(options);
}

const registry = new BasicTracerRegistry();
const provider = new BasicTracerProvider();

// Configure span processor to send spans to the provided exporter
registry.addSpanProcessor(new SimpleSpanProcessor(exporter));
provider.addSpanProcessor(new SimpleSpanProcessor(exporter));

// Initialize the OpenTelemetry APIs to use the BasicTracerRegistry bindings
opentelemetry.initGlobalTracerRegistry(registry);
// Initialize the OpenTelemetry APIs to use the BasicTracerProvider bindings
opentelemetry.initGlobalTracerProvider(provider);
const tracer = opentelemetry.getTracer('example-basic-tracer-node')

// Create a span. A span must be closed.
Expand Down
14 changes: 7 additions & 7 deletions examples/basic-tracer-node/multi_exporter.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
const opentelemetry = require('@opentelemetry/core');
const { BasicTracerRegistry, BatchSpanProcessor, SimpleSpanProcessor } = require('@opentelemetry/tracing');
const { BasicTracerProvider, BatchSpanProcessor, SimpleSpanProcessor } = require('@opentelemetry/tracing');
const { JaegerExporter } = require('@opentelemetry/exporter-jaeger');
const { ZipkinExporter } = require('@opentelemetry/exporter-zipkin');
const { CollectorExporter } = require('@opentelemetry/exporter-collector');

const registry = new BasicTracerRegistry();
const provider = new BasicTracerProvider();

const zipkinExporter = new ZipkinExporter({serviceName: 'basic-service'});
const jaegerExporter = new JaegerExporter({
Expand All @@ -14,18 +14,18 @@ const collectorExporter = new CollectorExporter({serviceName: 'basic-service'});

// It is recommended to use this BatchSpanProcessor for better performance
// and optimization, especially in production.
registry.addSpanProcessor(new BatchSpanProcessor(zipkinExporter, {
provider.addSpanProcessor(new BatchSpanProcessor(zipkinExporter, {
bufferSize: 10 // This is added for example, default size is 100.
}));

// It is recommended to use SimpleSpanProcessor in case of Jaeger exporter as
// it's internal client already handles the spans with batching logic.
registry.addSpanProcessor(new SimpleSpanProcessor(jaegerExporter));
provider.addSpanProcessor(new SimpleSpanProcessor(jaegerExporter));

registry.addSpanProcessor(new SimpleSpanProcessor(collectorExporter));
provider.addSpanProcessor(new SimpleSpanProcessor(collectorExporter));

// Initialize the OpenTelemetry APIs to use the BasicTracerRegistry bindings
opentelemetry.initGlobalTracerRegistry(registry);
// Initialize the OpenTelemetry APIs to use the BasicTracerProvider bindings
opentelemetry.initGlobalTracerProvider(provider);
const tracer = opentelemetry.getTracer('default');

// Create a span. A span must be closed.
Expand Down
10 changes: 5 additions & 5 deletions examples/dns/setup.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
'use strict';

const opentelemetry = require('@opentelemetry/core');
const { NodeTracerRegistry } = require('@opentelemetry/node');
const { NodeTracerProvider } = require('@opentelemetry/node');
const { SimpleSpanProcessor } = require('@opentelemetry/tracing');
const { JaegerExporter } = require('@opentelemetry/exporter-jaeger');
const { ZipkinExporter } = require('@opentelemetry/exporter-zipkin');
const EXPORTER = process.env.EXPORTER || '';

function setupTracerAndExporters(service) {
const registry = new NodeTracerRegistry({
const provider = new NodeTracerProvider({
      plugins: {
          dns: {
            enabled: true,
Expand All @@ -30,10 +30,10 @@ function setupTracerAndExporters(service) {
});
}

registry.addSpanProcessor(new SimpleSpanProcessor(exporter));
provider.addSpanProcessor(new SimpleSpanProcessor(exporter));

// Initialize the OpenTelemetry APIs to use the BasicTracerRegistry bindings
opentelemetry.initGlobalTracerRegistry(registry);
// Initialize the OpenTelemetry APIs to use the BasicTracerProvider bindings
opentelemetry.initGlobalTracerProvider(provider);
}

exports.setupTracerAndExporters = setupTracerAndExporters;
10 changes: 5 additions & 5 deletions examples/grpc/setup.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
'use strict';

const opentelemetry = require('@opentelemetry/core');
const { NodeTracerRegistry } = require('@opentelemetry/node');
const { NodeTracerProvider } = require('@opentelemetry/node');
const { SimpleSpanProcessor } = require('@opentelemetry/tracing');
const { JaegerExporter } = require('@opentelemetry/exporter-jaeger');
const { ZipkinExporter } = require('@opentelemetry/exporter-zipkin');
const EXPORTER = process.env.EXPORTER || '';

function setupTracerAndExporters(service) {
const registry = new NodeTracerRegistry({
const provider = new NodeTracerProvider({
plugins: {
grpc: {
enabled: true,
Expand All @@ -29,10 +29,10 @@ function setupTracerAndExporters(service) {
});
}

registry.addSpanProcessor(new SimpleSpanProcessor(exporter));
provider.addSpanProcessor(new SimpleSpanProcessor(exporter));

// Initialize the OpenTelemetry APIs to use the BasicTracerRegistry bindings
opentelemetry.initGlobalTracerRegistry(registry);
// Initialize the OpenTelemetry APIs to use the BasicTracerProvider bindings
opentelemetry.initGlobalTracerProvider(provider);
}

exports.setupTracerAndExporters = setupTracerAndExporters;
10 changes: 5 additions & 5 deletions examples/grpc_dynamic_codegen/setup.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
'use strict';

const opentelemetry = require('@opentelemetry/core');
const { NodeTracerRegistry } = require('@opentelemetry/node');
const { NodeTracerProvider } = require('@opentelemetry/node');
const { SimpleSpanProcessor } = require('@opentelemetry/tracing');
const { JaegerExporter } = require('@opentelemetry/exporter-jaeger');
const { ZipkinExporter } = require('@opentelemetry/exporter-zipkin');
const EXPORTER = process.env.EXPORTER || '';

function setupTracerAndExporters(service) {
const registry = new NodeTracerRegistry({
const provider = new NodeTracerProvider({
plugins: {
grpc: {
enabled: true,
Expand All @@ -31,10 +31,10 @@ function setupTracerAndExporters(service) {

// It is recommended to use this `BatchSpanProcessor` for better performance
// and optimization, especially in production.
registry.addSpanProcessor(new SimpleSpanProcessor(exporter));
provider.addSpanProcessor(new SimpleSpanProcessor(exporter));

// Initialize the OpenTelemetry APIs to use the BasicTracerRegistry bindings
opentelemetry.initGlobalTracerRegistry(registry);
// Initialize the OpenTelemetry APIs to use the BasicTracerProvider bindings
opentelemetry.initGlobalTracerProvider(provider);
}

exports.setupTracerAndExporters = setupTracerAndExporters;
10 changes: 5 additions & 5 deletions examples/http/setup.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
'use strict';

const opentelemetry = require('@opentelemetry/core');
const { NodeTracerRegistry } = require('@opentelemetry/node');
const { NodeTracerProvider } = require('@opentelemetry/node');
const { SimpleSpanProcessor } = require('@opentelemetry/tracing');
const { JaegerExporter } = require('@opentelemetry/exporter-jaeger');
const { ZipkinExporter } = require('@opentelemetry/exporter-zipkin');
const EXPORTER = process.env.EXPORTER || '';

function setupTracerAndExporters(service) {
const registry = new NodeTracerRegistry();
const provider = new NodeTracerProvider();

let exporter;
if (EXPORTER.toLowerCase().startsWith('z')) {
Expand All @@ -21,10 +21,10 @@ function setupTracerAndExporters(service) {
});
}

registry.addSpanProcessor(new SimpleSpanProcessor(exporter));
provider.addSpanProcessor(new SimpleSpanProcessor(exporter));

// Initialize the OpenTelemetry APIs to use the BasicTracerRegistry bindings
opentelemetry.initGlobalTracerRegistry(registry);
// Initialize the OpenTelemetry APIs to use the BasicTracerProvider bindings
opentelemetry.initGlobalTracerProvider(provider);
}

exports.setupTracerAndExporters = setupTracerAndExporters;
10 changes: 5 additions & 5 deletions examples/https/setup.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
'use strict';

const opentelemetry = require('@opentelemetry/core');
const { NodeTracerRegistry } = require('@opentelemetry/node');
const { NodeTracerProvider } = require('@opentelemetry/node');
const { SimpleSpanProcessor } = require('@opentelemetry/tracing');
const { JaegerExporter } = require('@opentelemetry/exporter-jaeger');
const { ZipkinExporter } = require('@opentelemetry/exporter-zipkin');
const EXPORTER = process.env.EXPORTER || '';
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
function setupTracerAndExporters(service) {
let exporter;
const registry = new NodeTracerRegistry();
const provider = new NodeTracerProvider();

if (EXPORTER.toLowerCase().startsWith('z')) {
exporter = new ZipkinExporter({
Expand All @@ -21,10 +21,10 @@ function setupTracerAndExporters(service) {
});
}

registry.addSpanProcessor(new SimpleSpanProcessor(exporter));
provider.addSpanProcessor(new SimpleSpanProcessor(exporter));

// Initialize the OpenTelemetry APIs to use the BasicTracerRegistry bindings
opentelemetry.initGlobalTracerRegistry(registry);
// Initialize the OpenTelemetry APIs to use the BasicTracerProvider bindings
opentelemetry.initGlobalTracerProvider(provider);
}

exports.setupTracerAndExporters = setupTracerAndExporters;
12 changes: 6 additions & 6 deletions examples/mysql/setup.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
'use strict';

const opentelemetry = require('@opentelemetry/core');
const { NodeTracerRegistry } = require('@opentelemetry/node');
const { NodeTracerProvider } = require('@opentelemetry/node');
const { SimpleSpanProcessor } = require('@opentelemetry/tracing');
const { JaegerExporter } = require('@opentelemetry/exporter-jaeger');
const { ZipkinExporter } = require('@opentelemetry/exporter-zipkin');

function setupTracerAndExporters(service) {
const registry = new NodeTracerRegistry({
const provider = new NodeTracerProvider({
plugins: {
mysql: {
enabled: true,
Expand All @@ -20,15 +20,15 @@ function setupTracerAndExporters(service) {
}
});

registry.addSpanProcessor(new SimpleSpanProcessor(new ZipkinExporter({
provider.addSpanProcessor(new SimpleSpanProcessor(new ZipkinExporter({
serviceName: service,
})));
registry.addSpanProcessor(new SimpleSpanProcessor(new JaegerExporter({
provider.addSpanProcessor(new SimpleSpanProcessor(new JaegerExporter({
serviceName: service,
})));

// Initialize the OpenTelemetry APIs to use the BasicTracerRegistry bindings
opentelemetry.initGlobalTracerRegistry(registry);
// Initialize the OpenTelemetry APIs to use the BasicTracerProvider bindings
opentelemetry.initGlobalTracerProvider(provider);
}

exports.setupTracerAndExporters = setupTracerAndExporters;
8 changes: 4 additions & 4 deletions examples/opentracing-shim/shim.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
"use strict";

const { NodeTracerRegistry } = require("@opentelemetry/node");
const { NodeTracerProvider } = require("@opentelemetry/node");
const { SimpleSpanProcessor } = require("@opentelemetry/tracing");
const { JaegerExporter } = require("@opentelemetry/exporter-jaeger");
const { ZipkinExporter } = require("@opentelemetry/exporter-zipkin");
const { TracerShim } = require("@opentelemetry/shim-opentracing");

function shim(serviceName) {
const registry = new NodeTracerRegistry();
const provider = new NodeTracerProvider();

registry.addSpanProcessor(new SimpleSpanProcessor(getExporter(serviceName)));
provider.addSpanProcessor(new SimpleSpanProcessor(getExporter(serviceName)));

return new TracerShim(registry.getTracer("opentracing-shim"));
return new TracerShim(provider.getTracer("opentracing-shim"));
}

function getExporter(serviceName) {
Expand Down
10 changes: 5 additions & 5 deletions examples/redis/setup.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
'use strict';

const opentelemetry = require('@opentelemetry/core');
const { NodeTracerRegistry } = require('@opentelemetry/node');
const { NodeTracerProvider } = require('@opentelemetry/node');
const { SimpleSpanProcessor } = require('@opentelemetry/tracing');
const { JaegerExporter } = require('@opentelemetry/exporter-jaeger');
const { ZipkinExporter } = require('@opentelemetry/exporter-zipkin');
const EXPORTER = process.env.EXPORTER || '';

function setupTracerAndExporters(service) {
const registry = new NodeTracerRegistry();
const provider = new NodeTracerProvider();

let exporter;
if (EXPORTER.toLowerCase().startsWith('z')) {
Expand All @@ -21,10 +21,10 @@ function setupTracerAndExporters(service) {
});
}

registry.addSpanProcessor(new SimpleSpanProcessor(exporter));
provider.addSpanProcessor(new SimpleSpanProcessor(exporter));

// Initialize the OpenTelemetry APIs to use the BasicTracerRegistry bindings
opentelemetry.initGlobalTracerRegistry(registry);
// Initialize the OpenTelemetry APIs to use the BasicTracerProvider bindings
opentelemetry.initGlobalTracerProvider(provider);
}

exports.setupTracerAndExporters = setupTracerAndExporters;
14 changes: 7 additions & 7 deletions examples/tracer-web/examples/document-load/index.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
import { ConsoleSpanExporter, SimpleSpanProcessor } from '@opentelemetry/tracing';
import { WebTracerRegistry } from '@opentelemetry/web';
import { WebTracerProvider as WebTracerProvider } from '@opentelemetry/web';
import { DocumentLoad } from '@opentelemetry/plugin-document-load';
import { ZoneScopeManager } from '@opentelemetry/scope-zone';
import { CollectorExporter } from '@opentelemetry/exporter-collector'

const registry = new WebTracerRegistry({
const provider = new WebTracerProvider({
plugins: [
new DocumentLoad()
]
});
registry.addSpanProcessor(new SimpleSpanProcessor(new ConsoleSpanExporter()));
provider.addSpanProcessor(new SimpleSpanProcessor(new ConsoleSpanExporter()));

const registryWithZone = new WebTracerRegistry({
const providerWithZone = new WebTracerProvider({
scopeManager: new ZoneScopeManager(),
plugins: [
new DocumentLoad()
]
});
registryWithZone.addSpanProcessor(new SimpleSpanProcessor(new ConsoleSpanExporter()));
registryWithZone.addSpanProcessor(new SimpleSpanProcessor(new CollectorExporter()));
providerWithZone.addSpanProcessor(new SimpleSpanProcessor(new ConsoleSpanExporter()));
providerWithZone.addSpanProcessor(new SimpleSpanProcessor(new CollectorExporter()));

const tracerWithZone = registryWithZone.getTracer('example-tracer-web');
const tracerWithZone = providerWithZone.getTracer('example-tracer-web');
console.log('Current span is window', tracerWithZone.getCurrentSpan() === window);

// example of keeping track of scope between async operations
Expand Down
Loading