Skip to content

Commit 221b86a

Browse files
committed
feat: Add span status docs
1 parent 0cbbbce commit 221b86a

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

docs/platforms/javascript/common/apis.mdx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -728,6 +728,13 @@ These utilities can be used for more advanced tracing use cases.
728728
that the span is updated in all backends.
729729
</SdkApi>
730730

731+
<SdkApi
732+
name="setHttpStatus"
733+
signature="function setHttpStatus(span: Span, httpStatus: number): void"
734+
>
735+
Set the status of a span based on the given http status code.
736+
</SdkApi>
737+
731738
<SdkApi
732739
name="getActiveSpan"
733740
signature="function getActiveSpan(): Span | undefined"

docs/platforms/javascript/common/tracing/instrumentation/index.mdx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,3 +212,17 @@ Prior to v8.39.0, you had to use `span.updateName('New Name')`, which had some l
212212
Using `Sentry.updateSpanName()` ensures that the name is updated correctly and no longer overwritten in these cases.
213213

214214
If you use `@sentry/browser`, `@sentry/react`, and so on in browser environments, `span.updateName()` and `Sentry.updateSpanName()` will function identically, so you can use either one of them.
215+
216+
### Updating the Span Status
217+
218+
By default, spans will have an `unknown` status. You can manually update the status of a span to indicate whether it succeeded or failed:
219+
220+
```javascript
221+
// Status codes:
222+
// 0: unknown
223+
// 1: ok
224+
// 2: error
225+
span.setStatus({ status: 2 });
226+
```
227+
228+
Alternatively, you can also use the <PlatformLink to='/apis/#setHttpStatus'>`Sentry.setHttpStatus()`</PlatformLink> utility function to set a more specific error status.

0 commit comments

Comments
 (0)