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

refactor!: specification compliant baggage #1876

Merged
merged 11 commits into from
Feb 5, 2021
Prev Previous commit
Next Next commit
chore: improve test for baggage key length
  • Loading branch information
dyladan committed Feb 2, 2021
commit 9821a68115f679288ba97e84b99aba3cde8dc881
23 changes: 21 additions & 2 deletions packages/opentelemetry-core/test/baggage/HttpBaggage.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,18 +80,36 @@ describe('HttpBaggage', () => {
const shortKey = Array(95).fill('k').join('');
const value = Array(4000).fill('v').join('');

const baggage = createBaggage({
let baggage = createBaggage({
aa: { value: 'shortvalue' },
[shortKey]: { value: value },
});

httpTraceContext.inject(
setBaggage(ROOT_CONTEXT, baggage),
carrier,
defaultTextMapSetter
);

let header = carrier[BAGGAGE_HEADER];
assert.ok(typeof header === 'string');
assert.deepStrictEqual(header, `aa=shortvalue,${shortKey}=${value}`);

baggage = createBaggage({
aa: { value: 'shortvalue' },
[longKey]: { value: value },
});

carrier = {};
httpTraceContext.inject(
setBaggage(ROOT_CONTEXT, baggage),
carrier,
defaultTextMapSetter
);

assert.deepStrictEqual(carrier[BAGGAGE_HEADER], `${shortKey}=${value}`);
header = carrier[BAGGAGE_HEADER];
assert.ok(typeof header === 'string');
assert.deepStrictEqual(header, 'aa=shortvalue');
});

it('should not exceed the W3C standard header length limit of 8192 bytes', () => {
Expand Down Expand Up @@ -122,6 +140,7 @@ describe('HttpBaggage', () => {
aa: { value: Array(89).fill('v').join('') },
});

carrier = {};
httpTraceContext.inject(
setBaggage(ROOT_CONTEXT, baggage),
carrier,
Expand Down