Skip to content

Commit 63938b0

Browse files
authored
fix: set span error states when fetch operations fail (#501)
1 parent 0c4327d commit 63938b0

File tree

1 file changed

+1
-0
lines changed
  • packages/otel/src/instrumentations

1 file changed

+1
-0
lines changed

packages/otel/src/instrumentations/fetch.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ export class FetchInstrumentation implements Instrumentation {
6161
'http.response.status_code': response.status,
6262
...this.prepareHeaders('response', response.headers),
6363
})
64+
span.setStatus({ code: response.status >= 400 ? api.SpanStatusCode.ERROR : api.SpanStatusCode.UNSET })
6465
}
6566

6667
private prepareHeaders(type: 'request' | 'response', headers: Headers): api.Attributes {

0 commit comments

Comments
 (0)