From 089f340d5aecba49290d45a1a486bf42c7d482ad Mon Sep 17 00:00:00 2001 From: Lukas Stracke Date: Thu, 14 Nov 2024 17:37:04 +0100 Subject: [PATCH 1/5] feat(js): Add docs for `updateSpanName` --- .../custom-instrumentation/index.mdx | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) 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..f4a1396f0d446 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.39.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 (e.g. `@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()` instead of `span.updateName()` 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 +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. From c393c32f7c00d92d7fe1040bc44fe74cd3e8e1d8 Mon Sep 17 00:00:00 2001 From: Lukas Stracke Date: Wed, 11 Dec 2024 11:27:14 +0100 Subject: [PATCH 2/5] apply review feedback --- .../instrumentation/custom-instrumentation/index.mdx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) 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 f4a1396f0d446..f49b928e98364 100644 --- a/docs/platforms/javascript/common/tracing/instrumentation/custom-instrumentation/index.mdx +++ b/docs/platforms/javascript/common/tracing/instrumentation/custom-instrumentation/index.mdx @@ -246,11 +246,11 @@ if (span) { } ``` -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`): +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 +- 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()` instead of `span.updateName()` ensures that the name is updated correctly and no longer overwritten in these cases. +Using `Sentry.updateSpanName()` ensures that the name is updated correctly and no longer overwritten in these cases. -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. +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. From e5d3f662e1f6402e098a790182159a5edc0bdb8d Mon Sep 17 00:00:00 2001 From: Lukas Stracke Date: Wed, 11 Dec 2024 11:27:59 +0100 Subject: [PATCH 3/5] bump version number --- .../tracing/instrumentation/custom-instrumentation/index.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 f49b928e98364..2d9fc888d781e 100644 --- a/docs/platforms/javascript/common/tracing/instrumentation/custom-instrumentation/index.mdx +++ b/docs/platforms/javascript/common/tracing/instrumentation/custom-instrumentation/index.mdx @@ -235,7 +235,7 @@ Sentry maintains a [list of well known span operations](https://develop.sentry.d ### Updating the Span Name -_Available since: v8.39.0_ +_Available since: v8.44.0_ You can update the name of a span at any time: From ba369e60a3ff5f742a45654a98a8adcb5b65a740 Mon Sep 17 00:00:00 2001 From: Lukas Stracke Date: Mon, 16 Dec 2024 16:35:39 +0100 Subject: [PATCH 4/5] Update docs/platforms/javascript/common/tracing/instrumentation/custom-instrumentation/index.mdx --- .../tracing/instrumentation/custom-instrumentation/index.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 2d9fc888d781e..4ca6604ba338e 100644 --- a/docs/platforms/javascript/common/tracing/instrumentation/custom-instrumentation/index.mdx +++ b/docs/platforms/javascript/common/tracing/instrumentation/custom-instrumentation/index.mdx @@ -235,7 +235,7 @@ Sentry maintains a [list of well known span operations](https://develop.sentry.d ### Updating the Span Name -_Available since: v8.44.0_ +_Available since: v8.46.0_ You can update the name of a span at any time: From 29ba68d75e451771c595be0edf05e0a2fed74a43 Mon Sep 17 00:00:00 2001 From: Lukas Stracke Date: Thu, 19 Dec 2024 09:30:14 +0100 Subject: [PATCH 5/5] Update docs/platforms/javascript/common/tracing/instrumentation/custom-instrumentation/index.mdx --- .../tracing/instrumentation/custom-instrumentation/index.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 4ca6604ba338e..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,7 +235,7 @@ Sentry maintains a [list of well known span operations](https://develop.sentry.d ### Updating the Span Name -_Available since: v8.46.0_ +_Available since: v8.47.0_ You can update the name of a span at any time: