Skip to content
This repository has been archived by the owner on Nov 10, 2022. It is now read-only.

Latest commit

 

History

History
28 lines (21 loc) · 1.28 KB

sdk-registration.md

File metadata and controls

28 lines (21 loc) · 1.28 KB

SDK Registration Methods

These methods are used to register a compatible OpenTelemetry SDK. Some SDKs like the [OpenTelemetry JS SDK][opentelemetry-js] 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);