Skip to content

Commit

Permalink
Merge branch 'main' into grpc-exporter-env-headers
Browse files Browse the repository at this point in the history
  • Loading branch information
dyladan authored Jun 30, 2021
2 parents 6765ba6 + 8f2209f commit e46afa4
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/opentelemetry-context-async-hooks/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"@types/mocha": "8.2.2",
"@types/node": "14.14.43",
"@types/shimmer": "1.0.1",
"codecov": "^3.8.2",
"codecov": "3.8.2",
"mocha": "7.2.0",
"nyc": "15.1.0",
"rimraf": "3.0.2",
Expand Down
5 changes: 4 additions & 1 deletion packages/opentelemetry-propagator-b3/src/B3Propagator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,10 @@ export class B3Propagator implements TextMapPropagator {
}

extract(context: Context, carrier: unknown, getter: TextMapGetter): Context {
if (getter.get(carrier, B3_CONTEXT_HEADER)) {
const header = getter.get(carrier, B3_CONTEXT_HEADER);
const b3Context = Array.isArray(header) ? header[0] : header;

if (b3Context) {
return this._b3SinglePropagator.extract(context, carrier, getter);
} else {
return this._b3MultiPropagator.extract(context, carrier, getter);
Expand Down
25 changes: 25 additions & 0 deletions packages/opentelemetry-propagator-b3/test/B3Propagator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,31 @@ describe('B3Propagator', () => {
});
});

it('extracts multi header b3 using array getter', () => {
const context = propagator.extract(
ROOT_CONTEXT,
b3MultiCarrier,
{
get(carrier, key) {
if (carrier == null || carrier[key] === undefined) {
return [];
}
return [carrier[key]];
},

keys: defaultTextMapGetter.keys
}
);

const extractedSpanContext = trace.getSpanContext(context);
assert.deepStrictEqual(extractedSpanContext, {
spanId: '6e0c63257de34c92',
traceId: 'd4cda95b652f4a1592b449d5929fda1b',
isRemote: true,
traceFlags: TraceFlags.SAMPLED,
});
});

it('extracts single header over multi', () => {
const context = propagator.extract(
ROOT_CONTEXT,
Expand Down
5 changes: 5 additions & 0 deletions renovate.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@
{
"matchPackageNames": ["@opentelemetry/api"],
"rangeStrategy": "bump"
},
{
"matchPaths": ["backwards-compatibility/**"],
"matchPackageNames": ["@types/node"],
"enabled": false
}
],
"ignoreDeps": ["gcp-metadata", "got", "mocha", "husky", "karma-webpack"],
Expand Down

0 comments on commit e46afa4

Please sign in to comment.