Skip to content

Conversation

Lms24
Copy link
Member

@Lms24 Lms24 commented Sep 1, 2025

This PR fixes a bug in our Astro SDK's browserTracingIntegration. Previously, if users followed our docs how to set a custom span name for the pageload span via beforeStartSpan, the name would get overwritten by our route parameterization logic. This was because the route parametrization logic ran after the span was already created and it would simply update the span name.

In this case though, we can already start the span with the parameterized name instead of updating after it was started. This has a couple of advantages:

  • We get the "right" name from the start, meaning there's no time frame where we could potentially propagate a source: 'url' name before updating it to route.
  • It's predicatable for users, since the span name doesn't change throughout the life cycle of the trace (e.g. for logging but also for customizing the span)
  • It allows logic in beforeStartSpan to set the span name to be applied correctly (i.e. fixes this bug).

Admittedly, my fix isn't the simplest possible fix (which would have been to just check for the source before updating the span name to the parameterized name). However, I think that starting the span right away with the correct name is the overall better outcome.

closes #17487

@Lms24 Lms24 requested review from a team and andreiborza and removed request for a team September 1, 2025 10:42
@Lms24 Lms24 merged commit 1854214 into develop Sep 1, 2025
162 checks passed
@Lms24 Lms24 deleted the lms/fix-astro-allow-custom-pageload-span-name branch September 1, 2025 12:13
Lms24 added a commit that referenced this pull request Sep 2, 2025
…in-place in `beforeStartSpan` (#17501)

When using `beforeStartSpan` in `browserTracingIntgration`, we document
that users should return a new options object rather than mutating the
passed in object in-place. However, nothing keeps users from setting the
name in-place like so:'

```js
browserTracingIntegration({
  beforeStartSpan: opts => {
    opts.name = 'changed';
    return opts;
  },
}),
```

In such a case, we previously didn't catch the mutation and wouldn't
adjust the span source attribute to `'custom'` accordingly. This PR
ensures we take care of this case, too. (found while writing a test for
#17500)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Frontend performance insights breaking behavior after a 9.40-> 9.45 upgrade
3 participants