Skip to content

Commit

Permalink
fix: change default propagator to match spec
Browse files Browse the repository at this point in the history
  • Loading branch information
jonahrosenblum committed Jun 18, 2020
1 parent a74fa66 commit 4fe8ea8
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
6 changes: 3 additions & 3 deletions packages/opentelemetry-node/test/registration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -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);
});
Expand Down Expand Up @@ -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);
});
Expand Down
11 changes: 9 additions & 2 deletions packages/opentelemetry-tracing/src/BasicTracerProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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) {
Expand Down
6 changes: 3 additions & 3 deletions packages/opentelemetry-web/test/registration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -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);
});
Expand Down Expand Up @@ -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);
});
Expand Down

0 comments on commit 4fe8ea8

Please sign in to comment.