diff --git a/docs/platforms/javascript/common/tracing/instrumentation/custom-instrumentation/index.mdx b/docs/platforms/javascript/common/tracing/instrumentation/custom-instrumentation/index.mdx index 559fe10399e1f..c932c33236e38 100644 --- a/docs/platforms/javascript/common/tracing/instrumentation/custom-instrumentation/index.mdx +++ b/docs/platforms/javascript/common/tracing/instrumentation/custom-instrumentation/index.mdx @@ -235,16 +235,22 @@ Sentry maintains a [list of well known span operations](https://develop.sentry.d ### Updating the Span Name +_Available since: v8.47.0_ + You can update the name of a span at any time: ```javascript const span = Sentry.getActiveSpan(); if (span) { - span.updateName("New Name"); + Sentry.updateSpanName(span, "New Name"); } ``` -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: +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 (for example, `@sentry/nextjs`): + +- Spans with `http.method` or `http.request.method` attributes would automatically have their name set to the method + the URL path. +- Spans with `db.system` attributes would automatically have their name set to the system + the statement. + +Using `Sentry.updateSpanName()` ensures that the name is updated correctly and no longer overwritten in these cases. -* Spans with `http.method` or `http.request.method` attributes will automatically have their name set to the method + the URL path -* Spans with `db.system` attributes will automatically have their name set to the system + the statement +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.