opentelemetry-js icon indicating copy to clipboard operation
opentelemetry-js copied to clipboard

Export NoopTracer

Open GregLahaye opened this issue 2 years ago • 1 comments
trafficstars

Is your feature request related to a problem? Please describe.

Export NoopTracer.

We have a Tracer that we export for use in instrumenting our application, however we would like to disable tracing in certain situations.

Describe the solution you'd like

A solution that would work for us would to use the NoopTracer in these scenarios to avoid creating/exporting traces, while still having a (no-op) Tracer that can be made use of.

Describe alternatives you've considered

Another work-around would to to shutdown the exporter but I'd rather be able to avoid creating a real tracer in the first place.

Additional context

Example use in our application:

telemetry.ts

let tracer: Tracer;
if (telemetryEnabled) {
  tracer = NoopTracer();
} else {
  // set up real tracer
}

app.ts

import {tracer} from "./telemetry";

tracer.startSpan();
// instrument app

I'd be happy to put up a PR to add this change.

GregLahaye avatar Nov 30 '22 12:11 GregLahaye

What about not registering a global TracerProvider?

your solution will only disable traces in your code part but other instrumentations (like http) will continue to create spans as they create their own Tracer.

Flarna avatar Nov 30 '22 14:11 Flarna

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 14 days.

github-actions[bot] avatar Feb 06 '23 06:02 github-actions[bot]

This issue was closed because it has been stale for 14 days with no activity.

github-actions[bot] avatar Feb 20 '23 06:02 github-actions[bot]