Skip to content

Commit

Permalink
refactor(sdk-trace-web): Use tree-shakeable string constants for semconv
Browse files Browse the repository at this point in the history
  • Loading branch information
JohannesHuster committed Jun 1, 2024
1 parent ecc88a3 commit 72e4da9
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions packages/opentelemetry-sdk-trace-web/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ import {
timeInputToHrTime,
urlMatches,
} from '@opentelemetry/core';
import { SemanticAttributes } from '@opentelemetry/semantic-conventions';
import {
SEMATTRS_HTTP_RESPONSE_CONTENT_LENGTH,
SEMATTRS_HTTP_RESPONSE_CONTENT_LENGTH_UNCOMPRESSED,
} from '@opentelemetry/semantic-conventions';

// Used to normalize relative URLs
let urlNormalizingAnchor: HTMLAnchorElement | undefined;
Expand Down Expand Up @@ -110,16 +113,13 @@ export function addSpanNetworkEvents(
addSpanNetworkEvent(span, PTN.RESPONSE_END, resource);
const encodedLength = resource[PTN.ENCODED_BODY_SIZE];
if (encodedLength !== undefined) {
span.setAttribute(
SemanticAttributes.HTTP_RESPONSE_CONTENT_LENGTH,
encodedLength
);
span.setAttribute(SEMATTRS_HTTP_RESPONSE_CONTENT_LENGTH, encodedLength);
}
const decodedLength = resource[PTN.DECODED_BODY_SIZE];
// Spec: Not set if transport encoding not used (in which case encoded and decoded sizes match)
if (decodedLength !== undefined && encodedLength !== decodedLength) {
span.setAttribute(
SemanticAttributes.HTTP_RESPONSE_CONTENT_LENGTH_UNCOMPRESSED,
SEMATTRS_HTTP_RESPONSE_CONTENT_LENGTH_UNCOMPRESSED,
decodedLength
);
}
Expand Down

0 comments on commit 72e4da9

Please sign in to comment.