From 4fe8ea8c2057c9c16cd8e1242ee2346f418b2823 Mon Sep 17 00:00:00 2001 From: jonahrosenblum Date: Thu, 18 Jun 2020 20:19:28 +0000 Subject: [PATCH 1/2] fix: change default propagator to match spec --- packages/opentelemetry-node/test/registration.test.ts | 6 +++--- .../opentelemetry-tracing/src/BasicTracerProvider.ts | 11 +++++++++-- packages/opentelemetry-web/test/registration.test.ts | 6 +++--- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/packages/opentelemetry-node/test/registration.test.ts b/packages/opentelemetry-node/test/registration.test.ts index d305673470..a2bb5e6b94 100644 --- a/packages/opentelemetry-node/test/registration.test.ts +++ b/packages/opentelemetry-node/test/registration.test.ts @@ -22,7 +22,7 @@ import { } from '@opentelemetry/api'; import { AsyncHooksContextManager } from '@opentelemetry/context-async-hooks'; import { NoopContextManager } from '@opentelemetry/context-base'; -import { HttpTraceContext } from '@opentelemetry/core'; +import { CompositePropagator } from '@opentelemetry/core'; import * as assert from 'assert'; import { NodeTracerProvider } from '../src'; @@ -41,7 +41,7 @@ describe('API registration', () => { context['_getContextManager']() instanceof AsyncHooksContextManager ); assert.ok( - propagation['_getGlobalPropagator']() instanceof HttpTraceContext + propagation['_getGlobalPropagator']() instanceof CompositePropagator ); assert.ok(trace.getTracerProvider() === tracerProvider); }); @@ -72,7 +72,7 @@ describe('API registration', () => { assert.ok(context['_getContextManager']() instanceof NoopContextManager); assert.ok( - propagation['_getGlobalPropagator']() instanceof HttpTraceContext + propagation['_getGlobalPropagator']() instanceof CompositePropagator ); assert.ok(trace.getTracerProvider() === tracerProvider); }); diff --git a/packages/opentelemetry-tracing/src/BasicTracerProvider.ts b/packages/opentelemetry-tracing/src/BasicTracerProvider.ts index 375f998aa7..f86c950e85 100644 --- a/packages/opentelemetry-tracing/src/BasicTracerProvider.ts +++ b/packages/opentelemetry-tracing/src/BasicTracerProvider.ts @@ -15,7 +15,12 @@ */ import * as api from '@opentelemetry/api'; -import { ConsoleLogger, HttpTraceContext } from '@opentelemetry/core'; +import { + ConsoleLogger, + HttpTraceContext, + HttpCorrelationContext, + CompositePropagator, +} from '@opentelemetry/core'; import { SpanProcessor, Tracer } from '.'; import { DEFAULT_CONFIG } from './config'; import { MultiSpanProcessor } from './MultiSpanProcessor'; @@ -78,7 +83,9 @@ export class BasicTracerProvider implements api.TracerProvider { register(config: SDKRegistrationConfig = {}) { api.trace.setGlobalTracerProvider(this); if (config.propagator === undefined) { - config.propagator = new HttpTraceContext(); + config.propagator = new CompositePropagator({ + propagators: [new HttpCorrelationContext(), new HttpTraceContext()], + }); } if (config.contextManager) { diff --git a/packages/opentelemetry-web/test/registration.test.ts b/packages/opentelemetry-web/test/registration.test.ts index adcee3a94e..cc86d1c681 100644 --- a/packages/opentelemetry-web/test/registration.test.ts +++ b/packages/opentelemetry-web/test/registration.test.ts @@ -21,7 +21,7 @@ import { trace, } from '@opentelemetry/api'; import { NoopContextManager } from '@opentelemetry/context-base'; -import { HttpTraceContext } from '@opentelemetry/core'; +import { CompositePropagator } from '@opentelemetry/core'; import * as assert from 'assert'; import { StackContextManager, WebTracerProvider } from '../src'; @@ -38,7 +38,7 @@ describe('API registration', () => { assert.ok(context['_getContextManager']() instanceof StackContextManager); assert.ok( - propagation['_getGlobalPropagator']() instanceof HttpTraceContext + propagation['_getGlobalPropagator']() instanceof CompositePropagator ); assert.ok(trace.getTracerProvider() === tracerProvider); }); @@ -69,7 +69,7 @@ describe('API registration', () => { assert.ok(context['_getContextManager']() instanceof NoopContextManager); assert.ok( - propagation['_getGlobalPropagator']() instanceof HttpTraceContext + propagation['_getGlobalPropagator']() instanceof CompositePropagator ); assert.ok(trace.getTracerProvider() === tracerProvider); }); From 8afce6281581f457b7ca572d22aedf7fe98f3350 Mon Sep 17 00:00:00 2001 From: jonahrosenblum Date: Thu, 18 Jun 2020 21:12:20 +0000 Subject: [PATCH 2/2] fix: update documentation to identify correct default propagator --- packages/opentelemetry-core/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/opentelemetry-core/README.md b/packages/opentelemetry-core/README.md index 08e639d492..7bb1ee7ace 100644 --- a/packages/opentelemetry-core/README.md +++ b/packages/opentelemetry-core/README.md @@ -30,8 +30,6 @@ This package provides default implementations of the OpenTelemetry API for trace OpenTelemetry provides a text-based approach to propagate context to remote services using the [W3C Trace Context](https://www.w3.org/TR/trace-context/) HTTP headers. -> This is used as a default Propagator - ```js const api = require("@opentelemetry/api"); const { HttpTraceContext } = require("@opentelemetry/core"); @@ -56,6 +54,8 @@ api.propagation.setGlobalPropagator(new B3Propagator()); Combines multiple propagators into a single propagator. +> This is used as a default Propagator + ```js const api = require("@opentelemetry/api"); const { CompositePropagator } = require("@opentelemetry/core");