Skip to content
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
2 changes: 2 additions & 0 deletions packages/tracing/src/browser/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ export function fetchCallback(
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const options = (handlerData.args[1] = (handlerData.args[1] as { [key: string]: any }) || {});
options.headers = addTracingHeaders(request, activeTransaction.getBaggage(), span, options);
activeTransaction.metadata.propagations += 1;
}
}

Expand Down Expand Up @@ -304,6 +305,7 @@ export function xhrCallback(
BAGGAGE_HEADER_NAME,
mergeAndSerializeBaggage(activeTransaction.getBaggage(), headerBaggageString),
);
activeTransaction.metadata.propagations += 1;
} catch (_) {
// Error: InvalidStateError: Failed to execute 'setRequestHeader' on 'XMLHttpRequest': The object's state must be OPENED.
}
Expand Down
26 changes: 26 additions & 0 deletions packages/tracing/test/browser/request.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,19 @@ describe('callbacks', () => {
expect(newSpan).toBeUndefined();
});

it('records outgoing propogations', () => {
const firstReqData = { ...fetchHandlerData };
const secondReqData = { ...fetchHandlerData };

expect(transaction.metadata.propagations).toBe(0);

fetchCallback(firstReqData, alwaysCreateSpan, {});
expect(transaction.metadata.propagations).toBe(1);

fetchCallback(secondReqData, alwaysCreateSpan, {});
expect(transaction.metadata.propagations).toBe(2);
});

it('adds sentry-trace header to fetch requests', () => {
// TODO
});
Expand Down Expand Up @@ -304,5 +317,18 @@ describe('callbacks', () => {

expect(newSpan).toBeUndefined();
});

it('records outgoing propogations', () => {
const firstReqData = { ...xhrHandlerData };
const secondReqData = { ...xhrHandlerData };

expect(transaction.metadata.propagations).toBe(0);

xhrCallback(firstReqData, alwaysCreateSpan, {});
expect(transaction.metadata.propagations).toBe(1);

xhrCallback(secondReqData, alwaysCreateSpan, {});
expect(transaction.metadata.propagations).toBe(2);
});
});
});