Skip to content

feat(core): Deprecate StartSpanOptions.origin in favour of passing attribute #10274

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

Merged
merged 3 commits into from
Jan 25, 2024

Conversation

Lms24
Copy link
Member

@Lms24 Lms24 commented Jan 19, 2024

To remove ambiguity and normalization logic in v8, we should only set the origin as an attribute, not as a top level option in the new startSpan APIs.

@Lms24 Lms24 requested review from mydea and AbhiPrasad January 19, 2024 16:51
Copy link
Contributor

github-actions bot commented Jan 19, 2024

size-limit report 📦

Path Size
@sentry/browser (incl. Tracing, Replay, Feedback) - Webpack (gzipped) 77.85 KB (+0.01% 🔺)
@sentry/browser (incl. Tracing, Replay) - Webpack (gzipped) 69.04 KB (0%)
@sentry/browser (incl. Tracing, Replay with Canvas) - Webpack (gzipped) 72.93 KB (0%)
@sentry/browser (incl. Tracing, Replay) - Webpack with treeshaking flags (gzipped) 62.68 KB (+0.01% 🔺)
@sentry/browser (incl. Tracing) - Webpack (gzipped) 33.07 KB (+0.01% 🔺)
@sentry/browser (incl. Feedback) - Webpack (gzipped) 31.25 KB (0%)
@sentry/browser (incl. sendFeedback) - Webpack (gzipped) 31.26 KB (+0.01% 🔺)
@sentry/browser - Webpack (gzipped) 22.5 KB (0%)
@sentry/browser (incl. Tracing, Replay, Feedback) - ES6 CDN Bundle (gzipped) 75.58 KB (+0.01% 🔺)
@sentry/browser (incl. Tracing, Replay) - ES6 CDN Bundle (gzipped) 67.13 KB (+0.01% 🔺)
@sentry/browser (incl. Tracing) - ES6 CDN Bundle (gzipped) 32.97 KB (+0.01% 🔺)
@sentry/browser - ES6 CDN Bundle (gzipped) 24.43 KB (0%)
@sentry/browser (incl. Tracing, Replay) - ES6 CDN Bundle (minified & uncompressed) 211.38 KB (-0.02% 🔽)
@sentry/browser (incl. Tracing) - ES6 CDN Bundle (minified & uncompressed) 99.4 KB (-0.04% 🔽)
@sentry/browser - ES6 CDN Bundle (minified & uncompressed) 73.08 KB (0%)
@sentry/browser (incl. Tracing) - ES5 CDN Bundle (gzipped) 36.07 KB (+0.02% 🔺)
@sentry/react (incl. Tracing, Replay) - Webpack (gzipped) 69.45 KB (+0.01% 🔺)
@sentry/react - Webpack (gzipped) 22.55 KB (0%)
@sentry/nextjs Client (incl. Tracing, Replay) - Webpack (gzipped) 86.11 KB (+0.01% 🔺)
@sentry/nextjs Client - Webpack (gzipped) 50.41 KB (+0.01% 🔺)
@sentry-internal/feedback - Webpack (gzipped) 17.21 KB (0%)

@Lms24 Lms24 force-pushed the lms/feat-core-deprecate-StartSpanOptions-origin branch from 261cd89 to 74460e2 Compare January 23, 2024 12:30
Comment on lines 136 to 140
this._attributes = {
[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: spanContext.origin || 'manual',
[SEMANTIC_ATTRIBUTE_SENTRY_OP]: spanContext.op,
...spanContext.attributes,
};
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I simplified the _attributes setting logic here to handle precedences correctly if origin or op are defined via spanContext.attributes. In case both, attributes and top level op/origin are defined, attributes take precedence.

// eslint-disable-next-line deprecation/deprecation
this.instrumenter = spanContext.instrumenter || 'sentry';

this.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, spanContext.origin || 'manual');
this._attributes = dropUndefinedKeys({
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

l: IMHO we can just use this.setAttributes() here, that handles not setting undefined values under the hood anyhow?

/**
* The origin of the span - if it comes from auto instrumentation or manual instrumentation.
*
* @deprecated Set `attributes['sentry.origin']` instead.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

l: Should we reference the semantic attribute const here instead? Is probably a bit safer..?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah right, we export them. Sure, will do!

@Lms24 Lms24 force-pushed the lms/feat-core-deprecate-StartSpanOptions-origin branch from 18f1f11 to 30d5ce4 Compare January 24, 2024 16:44
Lms24 added 2 commits January 25, 2024 14:18
…attribute

partial

fix more tests

simplify ctor logic

dropUndefinedKeys

remove stronger typing of `SpanAttributes`

review suggestions

more replacements

fix import
@Lms24 Lms24 force-pushed the lms/feat-core-deprecate-StartSpanOptions-origin branch from b05313a to 7bfdf80 Compare January 25, 2024 13:18
@Lms24 Lms24 merged commit 5aac3a6 into develop Jan 25, 2024
@Lms24 Lms24 deleted the lms/feat-core-deprecate-StartSpanOptions-origin branch January 25, 2024 15:11
@Lms24 Lms24 self-assigned this Jan 26, 2024
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.

2 participants