-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(core): Set sentry.source
attribute to custom
when calling span.updateName
on SentrySpan
#14251
Conversation
size-limit report 📦
|
❌ 1 Tests Failed:
View the top 1 failed tests by shortest run time
To view more test analytics, go to the Test Analytics Dashboard |
14aa37c
to
ddbf336
Compare
sentry.source
attribute to custom
when calling span.updateName
sentry.source
attribute to custom
when calling span.updateName
on SentrySpan
08a8882
to
0f12ced
Compare
expect(transaction.transaction).toBe('parent_span'); | ||
expect(transaction.spans).toBeDefined(); | ||
}); | ||
sentryTest( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
adjusted this test to check that we by default start a span with source "custom"
import { sentryTest } from '../../../../utils/fixtures'; | ||
import { getFirstSentryEnvelopeRequest, shouldSkipTracingTest } from '../../../../utils/helpers'; | ||
|
||
sentryTest('should create a pageload transaction', async ({ getLocalTestPath, page }) => { | ||
sentryTest('creates a pageload transaction with url as source', async ({ getLocalTestPath, page }) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no behaviour change here, just to explicitly check that our default browserTracingIntegration starts spans with source "url"
bbbca89
to
ab779bb
Compare
@@ -193,6 +193,7 @@ export class SentrySpan implements Span { | |||
*/ | |||
public updateName(name: string): this { | |||
this._name = name; | |||
this.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, 'custom'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
l: Wondering if we would want to mention this in the jsdoc?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, let me add a note
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On second thought, I'll add this but only in #14280 (which is the PR to fix this and a couple of depending things in Node). Since we always pass the Span
interface, I need to upadet the JSDoc of the interface which we should only do once the behaviour is adjusted everywhere.
This PR fixes a "regression" introduced in v8 where we no longer updated the source of the span when calling
span.updateName
. We had this behaviour in our v7Transaction
class (IIRC viatransaction.setName(name, source)
but most likely forgot to port it to theSpan
class as theevent.transaction_info.source
field is only relevant for transactions (i.e. root spans in today's SDK lingo).The PR also adds and improves some unit and browser integration tests so that we check against the default source as well as that updating the name updates the source.
Important: While this is a fix in the core package it has no effect on spans created in the Node SDK, since these are created from OpenTelemetry. I'll open a second PR for Node, as the changes there are more involved. This fix only addresses the behaviour of our
SentrySpan
class, which is used in browser SDKs (and none-Otel SDKs if any others use tracing)The issue addressed in this PR shouldn't be a major issue because it does not concern manually created root spans. Probably the only relevant scenario where this behaviour had user impact is something like:
url
(likely viabrowserTracingIntegration
from@sentry/browser
)transaction_info.source: "url"
"url"
source is low qualityWhich again is unlikely an issue in framework SDKs because most of our routing instrumentations update the span name and set the source to
"route"
. The described example would for example happen in@sentry/browser
with the defaultbrowserTracingIntegration
enabled and users running their own enhancement for e.g. a yet unsupported router.