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 Aug 29, 2024
1 parent c31e14a commit 0e92b2c
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 @@ -237,7 +237,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 @@ -248,7 +248,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 0e92b2c

Please sign in to comment.