Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(B3Propagator): B3 sampled causing gRPC error #977

Merged
merged 3 commits into from
Apr 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,13 @@ export class B3Propagator implements HttpTextPropagator {
// We set the header only if there is an existing sampling decision.
// Otherwise we will omit it => Absent.
if (spanContext.traceFlags !== undefined) {
setter(carrier, X_B3_SAMPLED, Number(spanContext.traceFlags));
setter(
carrier,
X_B3_SAMPLED,
(TraceFlags.SAMPLED & spanContext.traceFlags) === TraceFlags.SAMPLED
dyladan marked this conversation as resolved.
Show resolved Hide resolved
? '1'
: '0'
);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions packages/opentelemetry-core/test/context/B3Propagator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ describe('B3Propagator', () => {
'd4cda95b652f4a1592b449d5929fda1b'
);
assert.deepStrictEqual(carrier[X_B3_SPAN_ID], '6e0c63257de34c92');
assert.deepStrictEqual(carrier[X_B3_SAMPLED], TraceFlags.SAMPLED);
assert.deepStrictEqual(carrier[X_B3_SAMPLED], '1');
});

it('should set b3 traceId and spanId headers - ignore tracestate', () => {
Expand All @@ -82,7 +82,7 @@ describe('B3Propagator', () => {
'd4cda95b652f4a1592b449d5929fda1b'
);
assert.deepStrictEqual(carrier[X_B3_SPAN_ID], '6e0c63257de34c92');
assert.deepStrictEqual(carrier[X_B3_SAMPLED], TraceFlags.NONE);
assert.deepStrictEqual(carrier[X_B3_SAMPLED], '0');
});

it('should not inject empty spancontext', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/opentelemetry-core/test/context/composite.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ describe('Composite Propagator', () => {

assert.strictEqual(carrier[X_B3_TRACE_ID], traceId);
assert.strictEqual(carrier[X_B3_SPAN_ID], spanId);
assert.strictEqual(carrier[X_B3_SAMPLED], 1);
assert.strictEqual(carrier[X_B3_SAMPLED], '1');
assert.strictEqual(
carrier[TRACE_PARENT_HEADER],
`00-${traceId}-${spanId}-01`
Expand Down