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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(tracing): Change where content-length gets added #8139

Merged
merged 2 commits into from
May 17, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 7 additions & 4 deletions packages/tracing-internal/src/browser/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,13 @@ export function fetchCallback(
// TODO (kmclb) remove this once types PR goes through
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
span.setHttpStatus(handlerData.response.status);

const contentLength =
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
handlerData.response && handlerData.response.headers && handlerData.response.headers.get('content-length');
if (contentLength > 0) {
span.setData('http.response_content_length', contentLength);
}
} else if (handlerData.error) {
span.setStatus('internal_error');
}
Expand All @@ -186,9 +193,6 @@ export function fetchCallback(
return;
}

const contentLength =
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
handlerData.response && handlerData.response.headers && handlerData.response.headers.get('content-length');
const currentScope = getCurrentHub().getScope();
const currentSpan = currentScope && currentScope.getSpan();
const activeTransaction = currentSpan && currentSpan.transaction;
Expand All @@ -199,7 +203,6 @@ export function fetchCallback(
data: {
url,
type: 'fetch',
...(contentLength ? { 'http.response_content_length': contentLength } : {}),
'http.method': method,
},
description: `${method} ${url}`,
Expand Down