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 20, 2024
1 parent ab0f048 commit ee1b8bf
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 @@ -271,7 +271,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 @@ -283,7 +283,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 ee1b8bf

Please sign in to comment.