Skip to content

Commit 32d7885

Browse files
Additional test for baggage header and minor warn message improvement
1 parent c06f455 commit 32d7885

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

packages/core/src/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/__tests__/baggageHeaderUtils.test.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,4 +103,15 @@ describe('formatBaggageHeader', () => {
103103
const result = formatBaggageHeader(entries);
104104
expect(result).toBe('first=1,second=2,third=3');
105105
});
106+
107+
it('should trim keys and values', () => {
108+
const entries = new Set([
109+
'traceId=abc123;sampled=true;debug',
110+
'test1 = this is a test'
111+
]);
112+
const result = formatBaggageHeader(entries);
113+
expect(result).toBe(
114+
'traceId=abc123;sampled=true;debug,test1=this%20is%20a%20test'
115+
);
116+
});
106117
});

packages/core/src/rum/instrumentation/resourceTracking/requestProxy/XHRProxy/baggageHeaderUtils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ export function formatBaggageHeader(entries: Set<string>): string | null {
102102

103103
if (formattedParts.length > MAX_MEMBERS) {
104104
InternalLog.log(
105-
`XHRProxy: Too many baggage members: ${formattedParts.length} > ${MAX_MEMBERS} - entries might be dropped (https://www.w3.org/TR/baggage/#limits)`,
105+
`XHRProxy: Too many baggage members: ${formattedParts.length} > ${MAX_MEMBERS} - entries may be dropped (https://www.w3.org/TR/baggage/#limits)`,
106106
SdkVerbosity.WARN
107107
);
108108
} else if (formattedParts.length === 0) {
@@ -114,7 +114,7 @@ export function formatBaggageHeader(entries: Set<string>): string | null {
114114

115115
if (byteLength > MAX_BYTES) {
116116
InternalLog.log(
117-
`Baggage header too large: ${byteLength} bytes > ${MAX_BYTES} - entries might be dropped (https://www.w3.org/TR/baggage/#limits)`,
117+
`Baggage header too large: ${byteLength} bytes > ${MAX_BYTES} - entries may be dropped (https://www.w3.org/TR/baggage/#limits)`,
118118
SdkVerbosity.WARN
119119
);
120120
}

0 commit comments

Comments
 (0)