Skip to content

Commit

Permalink
Use integers in span attributes again
Browse files Browse the repository at this point in the history
  • Loading branch information
brettimus committed Sep 16, 2024
1 parent a0e138d commit 7622f8b
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions packages/client-library-otel/src/utils/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ export async function getResponseAttributes(
response: GlobalResponse | HonoResponse,
) {
const attributes: Attributes = {
[EXTRA_SEMATTRS_HTTP_RESPONSE_STATUS_CODE]: String(response.status),
[EXTRA_SEMATTRS_HTTP_RESPONSE_STATUS_CODE]: response.status,
[SEMATTRS_HTTP_SCHEME]: response.url.split(":")[0],
};

Expand All @@ -261,7 +261,14 @@ export async function getResponseAttributes(

const contentLength = response.headers.get("content-length");
if (contentLength) {
attributes[SEMATTRS_HTTP_RESPONSE_CONTENT_LENGTH] = contentLength;
try {
attributes[SEMATTRS_HTTP_RESPONSE_CONTENT_LENGTH] = Number.parseInt(
contentLength,
10,
);
} catch {
// ignore errors
}
}

const headers = response.headers;
Expand Down

0 comments on commit 7622f8b

Please sign in to comment.