Skip to content

Latest commit

 

History

History
29 lines (22 loc) · 1.39 KB

sdk-registration.md

File metadata and controls

29 lines (22 loc) · 1.39 KB

SDK Registration Methods

These methods are used to register a compatible OpenTelemetry SDK. Some SDKs like the OpenTelemetry JS SDK provide convenience methods which call these registration methods for you.

const api = require("@opentelemetry/api");

/* Register a global TracerProvider */
api.trace.setGlobalTracerProvider(tracerProvider);
/* returns tracerProvider (no-op if a working provider has not been initialized) */
api.trace.getTracerProvider();
/* returns a tracer from the registered global tracer provider (no-op if a working provider has not been initialized) */
api.trace.getTracer(name, version);

/* Register a global Propagator */
api.propagation.setGlobalPropagator(httpTraceContextPropagator);

/* Register a global Context Manager */
api.context.setGlobalContextManager(asyncHooksContextManager);