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

Named Tracers / Tracer Registry #582

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
d75f53e
feat: spike of named tracer registry
dyladan Dec 2, 2019
ead9f16
Merge remote-tracking branch 'upstream/master' into tracer-registry
dyladan Dec 2, 2019
50927cd
chore: mysql/mongo tracer registry support
dyladan Dec 2, 2019
c686117
fix: lint
dyladan Dec 2, 2019
7dba62c
Merge remote-tracking branch 'upstream/master' into tracer-registry
dyladan Dec 2, 2019
14fa061
chore: add getTracer back
dyladan Dec 2, 2019
b1e887c
chore: change default tracer name to empty string
dyladan Dec 2, 2019
5ca0209
fix: lint
dyladan Dec 2, 2019
217d3b3
Merge branch 'master' into tracer-registry
dyladan Dec 2, 2019
61f4618
chore: update examples for registry
dyladan Dec 2, 2019
33dd773
Merge branch 'tracer-registry' of github.com:dynatrace-oss-contrib/op…
dyladan Dec 2, 2019
6f81608
Merge remote-tracking branch 'upstream/master' into tracer-registry
dyladan Dec 10, 2019
0687f1c
Merge remote-tracking branch 'upstream/master' into tracer-registry
dyladan Dec 17, 2019
cc4eba9
chore(tracer-registry): make name required
dyladan Dec 17, 2019
9d95597
chore: lint
dyladan Dec 17, 2019
3237f99
chore: update examples for required tracer name
dyladan Dec 17, 2019
643e286
chore: remove unused tracer delegate
dyladan Dec 17, 2019
508ff33
Merge remote-tracking branch 'upstream/master' into tracer-registry
dyladan Dec 18, 2019
41c1168
chore: remove references to basic tracer
dyladan Dec 23, 2019
6a94efe
chore: remove references to NodeTracer
dyladan Dec 23, 2019
4693d22
Merge remote-tracking branch 'upstream/master' into tracer-registry
dyladan Dec 26, 2019
13f96fd
chore: update xhr for tracer registry
dyladan Dec 26, 2019
38ffef8
chore: update tracer names to match package names
dyladan Dec 26, 2019
9915a2c
chore: add version script to all packages
dyladan Dec 26, 2019
69ff01f
chore: update plugins to use version script
dyladan Dec 26, 2019
40c4301
chore: add jsdoc to noop tracer registry
dyladan Dec 27, 2019
1eea9d2
Merge remote-tracking branch 'upstream/master' into tracer-registry
dyladan Dec 27, 2019
660f41f
chore: update ioredis for tracer registry
dyladan Dec 27, 2019
8e6399e
chore: update pg pool for tracer registry
dyladan Dec 27, 2019
bd0be2c
fix: lint
dyladan Dec 30, 2019
30a1b36
Merge remote-tracking branch 'upstream/master' into tracer-registry
dyladan Jan 3, 2020
7c39151
chore: fix tests
dyladan Jan 3, 2020
e814df6
chore: lint
dyladan Jan 3, 2020
0ec5b82
Merge remote-tracking branch 'upstream/master' into tracer-registry
dyladan Jan 6, 2020
cd47354
chore: lint
dyladan Jan 6, 2020
bfa8bfa
Merge branch 'master' into tracer-registry
mayurkale22 Jan 9, 2020
5740098
Merge branch 'master' into tracer-registry
mayurkale22 Jan 9, 2020
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ docs

#lerna
.changelog
package.json.lerna_backup
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this intentional ?


# OS generated files
.DS_Store
Expand Down
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 { BasicTracer, BatchSpanProcessor, InMemorySpanExporter, SimpleSpanProcessor } = require('@opentelemetry/tracing');
const { NodeTracer } = require('@opentelemetry/node');
const { BasicTracerRegistry, BatchSpanProcessor, InMemorySpanExporter, SimpleSpanProcessor } = require('@opentelemetry/tracing');
const { NodeTracerRegistry } = require('@opentelemetry/node');

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

const setups = [
{
name: 'BasicTracer',
tracer: new BasicTracer({ logger })
name: 'BasicTracerRegistry',
registry: new BasicTracerRegistry({ logger })
},
{
name: 'NodeTracer',
tracer: new NodeTracer({ logger })
name: 'NodeTracerRegistry',
registry: new NodeTracerRegistry({ logger })
}
];

for (const setup of setups) {
console.log(`Beginning ${setup.name} Benchmark...`);
const tracer = setup.tracer;
const tracer = setup.registry.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);

tracer.addSpanProcessor(simpleSpanProcessor);
registry.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);

tracer.addSpanProcessor(batchSpanProcessor);
registry.addSpanProcessor(batchSpanProcessor);
const span = tracer.startSpan('op');
span.end();
batchSpanProcessor.shutdown();
Expand Down
15 changes: 8 additions & 7 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 { BasicTracer, SimpleSpanProcessor } = require('@opentelemetry/tracing');
const { BasicTracerRegistry, 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,16 +20,17 @@ if (EXPORTER.toLowerCase().startsWith('z')) {
exporter = new CollectorExporter(options);
}

const tracer = new BasicTracer();
const registry = new BasicTracerRegistry();
dyladan marked this conversation as resolved.
Show resolved Hide resolved

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

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

// Create a span. A span must be closed.
const span = opentelemetry.getTracer().startSpan('main');
const span = tracer.startSpan('main');
for (let i = 0; i < 10; i++) {
doWork(span);
}
Expand All @@ -42,7 +43,7 @@ exporter.shutdown();
function doWork(parent) {
// Start another span. In this example, the main method already started a
// span, so that'll be the parent span, and this will be a child span.
const span = opentelemetry.getTracer().startSpan('doWork', {
const span = tracer.startSpan('doWork', {
parent: parent
});

Expand Down
19 changes: 10 additions & 9 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 { BasicTracer, BatchSpanProcessor, SimpleSpanProcessor } = require('@opentelemetry/tracing');
const { BasicTracerRegistry, BatchSpanProcessor, SimpleSpanProcessor } = require('@opentelemetry/tracing');
const { JaegerExporter } = require('@opentelemetry/exporter-jaeger');
const { ZipkinExporter } = require('@opentelemetry/exporter-zipkin');
const { CollectorExporter } = require('@opentelemetry/exporter-collector');

const tracer = new BasicTracer();
const registry = new BasicTracerRegistry();

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

// It is recommended to use this BatchSpanProcessor for better performance
// and optimization, especially in production.
tracer.addSpanProcessor(new BatchSpanProcessor(zipkinExporter, {
registry.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.
tracer.addSpanProcessor(new SimpleSpanProcessor(jaegerExporter));
registry.addSpanProcessor(new SimpleSpanProcessor(jaegerExporter));

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

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

// Create a span. A span must be closed.
const span = opentelemetry.getTracer().startSpan('main');
const span = tracer.startSpan('main');
dyladan marked this conversation as resolved.
Show resolved Hide resolved
for (let i = 0; i < 10; i++) {
doWork(span);
}
Expand All @@ -43,7 +44,7 @@ collectorExporter.shutdown();
function doWork(parent) {
// Start another span. In this example, the main method already started a
// span, so that'll be the parent span, and this will be a child span.
const span = opentelemetry.getTracer().startSpan('doWork', {
const span = tracer.startSpan('doWork', {
parent: parent
});

Expand Down
2 changes: 1 addition & 1 deletion examples/dns/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const config = require('./setup');
config.setupTracerAndExporters('dns-client-service');

const dns = require('dns').promises;
const tracer = opentelemetry.getTracer();
const tracer = opentelemetry.getTracer('example-dns');

/** A function which makes a dns lookup and handles response. */
function makeLookup() {
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 { NodeTracer } = require('@opentelemetry/node');
const { NodeTracerRegistry } = 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 tracer = new NodeTracer({
const registry = new NodeTracerRegistry({
      plugins: {
          dns: {
            enabled: true,
Expand All @@ -30,10 +30,10 @@ function setupTracerAndExporters(service) {
});
}

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

// Initialize the OpenTelemetry APIs to use the BasicTracer bindings
opentelemetry.initGlobalTracer(tracer);
// Initialize the OpenTelemetry APIs to use the BasicTracerRegistry bindings
opentelemetry.initGlobalTracerRegistry(registry);
}

exports.setupTracerAndExporters = setupTracerAndExporters;
2 changes: 1 addition & 1 deletion examples/grpc/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const grpc = require('grpc');
const messages = require('./helloworld_pb');
const services = require('./helloworld_grpc_pb');
const PORT = 50051;
const tracer = opentelemetry.getTracer();
const tracer = opentelemetry.getTracer('example-grpc-client');

/** A function which makes requests and handles response. */
function main() {
Expand Down
2 changes: 1 addition & 1 deletion examples/grpc/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const config = require('./setup');
config.setupTracerAndExporters('grpc-server-service');

const grpc = require('grpc');
const tracer = opentelemetry.getTracer();
const tracer = opentelemetry.getTracer('example-grpc-server');

const messages = require('./helloworld_pb');
const services = require('./helloworld_grpc_pb');
Expand Down
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 { NodeTracer } = require('@opentelemetry/node');
const { NodeTracerRegistry } = 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 tracer = new NodeTracer({
const registry = new NodeTracerRegistry({
plugins: {
grpc: {
enabled: true,
Expand All @@ -29,10 +29,10 @@ function setupTracerAndExporters(service) {
});
}

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

// Initialize the OpenTelemetry APIs to use the BasicTracer bindings
opentelemetry.initGlobalTracer(tracer);
// Initialize the OpenTelemetry APIs to use the BasicTracerRegistry bindings
opentelemetry.initGlobalTracerRegistry(registry);
}

exports.setupTracerAndExporters = setupTracerAndExporters;
2 changes: 1 addition & 1 deletion examples/grpc_dynamic_codegen/capitalize_client.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const path = require('path');
const grpc = require('grpc');
const protoLoader = require('@grpc/proto-loader');

const tracer = opentelemetry.getTracer();
const tracer = opentelemetry.getTracer('example-grpc-capitalize-client');

const PROTO_PATH = path.join(__dirname, 'protos/defs.proto');
const PROTO_OPTIONS = { keepCase: true, enums: String, defaults: true, oneofs: true };
Expand Down
2 changes: 1 addition & 1 deletion examples/grpc_dynamic_codegen/capitalize_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const PROTO_OPTIONS = { keepCase: true, enums: String, defaults: true, oneofs: t
const definition = protoLoader.loadSync(PROTO_PATH, PROTO_OPTIONS);
const rpcProto = grpc.loadPackageDefinition(definition).rpc;

const tracer = opentelemetry.getTracer();
const tracer = opentelemetry.getTracer('example-grpc-capitalize-server');

/** Implements the Capitalize RPC method. */
function capitalize(call, callback) {
Expand Down
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 { NodeTracer } = require('@opentelemetry/node');
const { NodeTracerRegistry } = 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 tracer = new NodeTracer({
const registry = new NodeTracerRegistry({
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.
tracer.addSpanProcessor(new SimpleSpanProcessor(exporter));
registry.addSpanProcessor(new SimpleSpanProcessor(exporter));

// Initialize the OpenTelemetry APIs to use the BasicTracer bindings
opentelemetry.initGlobalTracer(tracer);
// Initialize the OpenTelemetry APIs to use the BasicTracerRegistry bindings
opentelemetry.initGlobalTracerRegistry(registry);
}

exports.setupTracerAndExporters = setupTracerAndExporters;
2 changes: 1 addition & 1 deletion examples/http/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const config = require('./setup');
config.setupTracerAndExporters('http-client-service');

const http = require('http');
const tracer = opentelemetry.getTracer();
const tracer = opentelemetry.getTracer('example-http-client');

/** A function which makes requests and handles response. */
function makeRequest() {
Expand Down
2 changes: 1 addition & 1 deletion examples/http/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const config = require('./setup');
config.setupTracerAndExporters('http-server-service');

const http = require('http');
const tracer = opentelemetry.getTracer();
const tracer = opentelemetry.getTracer('example-http-server');

/** Starts a HTTP server that receives requests on sample server port. */
function startServer (port) {
Expand Down
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 { NodeTracer } = require('@opentelemetry/node');
const { NodeTracerRegistry } = 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 tracer = new NodeTracer();
const registry = new NodeTracerRegistry();

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

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

// Initialize the OpenTelemetry APIs to use the BasicTracer bindings
opentelemetry.initGlobalTracer(tracer);
// Initialize the OpenTelemetry APIs to use the BasicTracerRegistry bindings
opentelemetry.initGlobalTracerRegistry(registry);
}

exports.setupTracerAndExporters = setupTracerAndExporters;
4 changes: 2 additions & 2 deletions examples/https/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const config = require('./setup');
config.setupTracerAndExporters('https-client-service');

const https = require('https');
const tracer = opentelemetry.getTracer();
const tracer = opentelemetry.getTracer('example-https-client');

/** A function which makes requests and handles response. */
function makeRequest() {
Expand All @@ -31,7 +31,7 @@ function makeRequest() {
});
});
});

// The process must live for at least the interval past any traces that
// must be exported, or some risk being lost if they are recorded after the
// last export.
Expand Down
2 changes: 1 addition & 1 deletion examples/https/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const config = require('./setup');
config.setupTracerAndExporters('https-server-service');

const https = require('https');
const tracer = opentelemetry.getTracer();
const tracer = opentelemetry.getTracer('example-https-server');

/** Starts a HTTPs server that receives requests on sample server port. */
function startServer (port) {
Expand Down
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 { NodeTracer } = require('@opentelemetry/node');
const { NodeTracerRegistry } = 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 tracer = new NodeTracer();
const registry = new NodeTracerRegistry();

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

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

// Initialize the OpenTelemetry APIs to use the BasicTracer bindings
opentelemetry.initGlobalTracer(tracer);
// Initialize the OpenTelemetry APIs to use the BasicTracerRegistry bindings
opentelemetry.initGlobalTracerRegistry(registry);
}

exports.setupTracerAndExporters = setupTracerAndExporters;
Loading