Skip to content

Commit f7cbbe7

Browse files
committed
feat(js): Add docs for updateSpanName
1 parent c29c9f0 commit f7cbbe7

File tree

1 file changed

+10
-4
lines changed
  • docs/platforms/javascript/common/tracing/instrumentation/custom-instrumentation

1 file changed

+10
-4
lines changed

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

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -235,16 +235,22 @@ Sentry maintains a [list of well known span operations](https://develop.sentry.d
235235

236236
### Updating the Span Name
237237

238+
_Available since: v8.39.0_
239+
238240
You can update the name of a span at any time:
239241

240242
```javascript
241243
const span = Sentry.getActiveSpan();
242244
if (span) {
243-
span.updateName("New Name");
245+
Sentry.updateSpanName(span, "New Name");
244246
}
245247
```
246248

247-
Please note that in certain scenarios, the span name will be overwritten by the SDK. This is the case for spans with any of the following attribute combinations:
249+
Prior to v8.39.0, you had to use `span.updateName('New Name')`, which had some limitations in `@sentry/node` and SDKs depending on it (e.g. `@sentry/nextjs`):
250+
251+
- Spans with `http.method` or `http.request.method` attributes would automatically have their name set to the method + the URL path
252+
- Spans with `db.system` attributes would automatically have their name set to the system + the statement
253+
254+
Using `Sentry.updateSpanName()` instead of `span.updateName()` ensures that the name is updated correctly and no longer overwritten in all cases.
248255

249-
* Spans with `http.method` or `http.request.method` attributes will automatically have their name set to the method + the URL path
250-
* Spans with `db.system` attributes will automatically have their name set to the system + the statement
256+
In browser environments (if you use `@sentry/browser`, `@sentry/react`, etc), `span.updateName()` and `Sentry.updateSpanName()` are identical and you can use either of them.

0 commit comments

Comments
 (0)