From b1db324ab9fbd837a21fdf2619ff2dfa44d45a72 Mon Sep 17 00:00:00 2001 From: Francesco Novy Date: Wed, 17 Jul 2024 09:38:53 +0200 Subject: [PATCH 1/2] feat(js): Improve `tracesSampler` docs for JS --- .../javascript/common/configuration/sampling.mdx | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/docs/platforms/javascript/common/configuration/sampling.mdx b/docs/platforms/javascript/common/configuration/sampling.mdx index 10390b4e898b2c..f333cd1988b539 100644 --- a/docs/platforms/javascript/common/configuration/sampling.mdx +++ b/docs/platforms/javascript/common/configuration/sampling.mdx @@ -58,18 +58,12 @@ By default, none of these options are set, meaning no transactions will be sent ## Sampling Context Data -### Default Sampling Context Data - -The information contained in the object passed to the when a transaction is created varies by platform and integration. - - - -### Custom Sampling Context Data - -When using custom instrumentation to create a span, the `tracesSampler` function will automatically receive the span `name` and the initial span `attributes` to use in its sampling decision. +When a span is started, the `tracesSampler` function will automatically receive the span `name` and the initial span `attributes` to use in its sampling decision. +Please note that the `name` passed to `tracesSampler` may not be the exact same name that is eventually sent to Sentry. The name may be updated during the lifetime of the span, but the `name` passed to `tracesSampler` will always be the initial name. For example, the `name` for `http.server` spans will usually not be parametrized yet when passed to `tracesSampler`, so instead of `GET /users/:id` you may see a name of `GET /users/123`. + ## Inheritance From 413e11a775ab858e983195930dc0dd15591c0a26 Mon Sep 17 00:00:00 2001 From: Francesco Novy Date: Wed, 17 Jul 2024 09:42:15 +0200 Subject: [PATCH 2/2] fixes --- .../javascript/common/configuration/sampling.mdx | 2 +- .../javascript.mdx | 13 ------------- .../default-sampling-context/javascript.mdx | 1 - 3 files changed, 1 insertion(+), 15 deletions(-) delete mode 100644 platform-includes/performance/default-sampling-context-platform/javascript.mdx delete mode 100644 platform-includes/performance/default-sampling-context/javascript.mdx diff --git a/docs/platforms/javascript/common/configuration/sampling.mdx b/docs/platforms/javascript/common/configuration/sampling.mdx index f333cd1988b539..0bb775bea4b774 100644 --- a/docs/platforms/javascript/common/configuration/sampling.mdx +++ b/docs/platforms/javascript/common/configuration/sampling.mdx @@ -58,7 +58,7 @@ By default, none of these options are set, meaning no transactions will be sent ## Sampling Context Data -When a span is started, the `tracesSampler` function will automatically receive the span `name` and the initial span `attributes` to use in its sampling decision. +When a span is started, the `tracesSampler` function will automatically receive the span `name` and the initial span `attributes` to use in its sampling decision. Additionally, it will also receive a `parentSampled` boolean indicating whether the parent span was sampled. This data can be used to make a more informed decision about whether to sample the span. diff --git a/platform-includes/performance/default-sampling-context-platform/javascript.mdx b/platform-includes/performance/default-sampling-context-platform/javascript.mdx deleted file mode 100644 index 15d141bb412091..00000000000000 --- a/platform-includes/performance/default-sampling-context-platform/javascript.mdx +++ /dev/null @@ -1,13 +0,0 @@ -It includes at least the following: - -```typescript -// contents of `samplingContext` -{ - // human-readable identifier, like "GET /users" - name: string; - // if this transaction has a parent, its sampling decision - parentSampled: boolean; - // The initial attributes passed to the span - attributes: Record; -} -``` diff --git a/platform-includes/performance/default-sampling-context/javascript.mdx b/platform-includes/performance/default-sampling-context/javascript.mdx deleted file mode 100644 index a6a92c2a989d8c..00000000000000 --- a/platform-includes/performance/default-sampling-context/javascript.mdx +++ /dev/null @@ -1 +0,0 @@ -