Skip to content
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

feat(core): Align Span interface with OTEL #12898

Merged
merged 5 commits into from
Jul 18, 2024
Merged

Conversation

chargome
Copy link
Member

fixes #12566

@chargome chargome requested a review from mydea July 12, 2024 13:54
Copy link
Contributor

github-actions bot commented Jul 12, 2024

size-limit report 📦

Path Size
@sentry/browser 22.3 KB (0%)
@sentry/browser (incl. Tracing) 33.72 KB (+0.09% 🔺)
@sentry/browser (incl. Tracing, Replay) 69.81 KB (+0.04% 🔺)
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 63.11 KB (+0.04% 🔺)
@sentry/browser (incl. Tracing, Replay with Canvas) 74.2 KB (+0.04% 🔺)
@sentry/browser (incl. Tracing, Replay, Feedback) 86.52 KB (+0.04% 🔺)
@sentry/browser (incl. Tracing, Replay, Feedback, metrics) 88.39 KB (+0.04% 🔺)
@sentry/browser (incl. metrics) 26.62 KB (+0.11% 🔺)
@sentry/browser (incl. Feedback) 38.98 KB (0%)
@sentry/browser (incl. sendFeedback) 26.93 KB (0%)
@sentry/browser (incl. FeedbackAsync) 31.54 KB (0%)
@sentry/react 25.06 KB (0%)
@sentry/react (incl. Tracing) 36.79 KB (+0.09% 🔺)
@sentry/vue 26.44 KB (+0.13% 🔺)
@sentry/vue (incl. Tracing) 35.6 KB (+0.07% 🔺)
@sentry/svelte 22.44 KB (0%)
CDN Bundle 23.52 KB (0%)
CDN Bundle (incl. Tracing) 35.5 KB (+0.09% 🔺)
CDN Bundle (incl. Tracing, Replay) 69.91 KB (+0.05% 🔺)
CDN Bundle (incl. Tracing, Replay, Feedback) 75.17 KB (+0.05% 🔺)
CDN Bundle - uncompressed 69 KB (0%)
CDN Bundle (incl. Tracing) - uncompressed 105.1 KB (+0.16% 🔺)
CDN Bundle (incl. Tracing, Replay) - uncompressed 216.88 KB (+0.08% 🔺)
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 229.6 KB (+0.07% 🔺)
@sentry/nextjs (client) 36.64 KB (+0.07% 🔺)
@sentry/sveltekit (client) 34.37 KB (+0.08% 🔺)
@sentry/node 111.28 KB (0%)
@sentry/node - without tracing 88.73 KB (0%)
@sentry/aws-serverless 97.87 KB (-0.01% 🔽)

@chargome chargome self-assigned this Jul 15, 2024
@chargome chargome requested review from lforst and Lms24 July 15, 2024 09:48
Copy link
Member

@Lms24 Lms24 left a comment

Choose a reason for hiding this comment

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

Do we want to go through despite the breaking change?

@@ -118,18 +151,21 @@ export class SentrySpan implements Span {
}

/** @inheritdoc */
public setAttribute(key: string, value: SpanAttributeValue | undefined): void {
public setAttribute(key: string, value: SpanAttributeValue | undefined): this {
Copy link
Member

Choose a reason for hiding this comment

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

Technically that's a breaking change 😬

Sure, 99% of our users will simply call span.setAttribute but maybe for some reason someone asserts on undefined being returned. Is there a concrete reason (e.g. someone running into this mismatch) we should consider breaking here? If not, I'd vote we don't change the return types of setAttribute(s) in v8 but happy to discuss this.

Copy link
Member

Choose a reason for hiding this comment

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

This is not breaking unless somebody implements the SentrySpan interface, which is not really something we recommend anyone doing.

Copy link
Member

Choose a reason for hiding this comment

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

Hmm maybe I'm missing something but this (including variations of working with the return type) seems like valid code to me:

Sentry.startSpan({}, span => {
  assert(span.setAttribute(...) === undefined) 
})

I'm not saying this is a likely code path. We can make the call to technically break here. If we do, I'd prefer to extract the breaking aspect into a separate PR to revert more easily in case someone does write in.

Copy link
Member

Choose a reason for hiding this comment

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

Widening return types is generally not considered semver major, but sever minor I believe.

Copy link
Member

Choose a reason for hiding this comment

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

I'd say this is fine, we generally accept widening return types as non-breaking I believe, the potential for breaking here is extremely low 🤔

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok, I'll keep the change then?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, let's keep it.

* @hidden
* @internal
*/
public recordException(_exception: unknown, _time?: number | undefined): void {
Copy link
Member

Choose a reason for hiding this comment

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

comment/unactionable: "recordException" is a very unfortunate function name for users seeing this method when interacting with the Sentry SDK 😬

(ignore this comment, I'm just fairly sure someone is gonna call it "accidentally" instead of captureException)

Copy link
Member

Choose a reason for hiding this comment

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

Had the same thought! I had an idea that we could alias this to captureException. Maybe we should also make it very clear in the JS doc that captureException needs to be preferred.

Copy link
Member

Choose a reason for hiding this comment

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

I had an idea that we could alias this to captureException

yeah this also crossed my mind. But I'd rather do it when it comes up to save on bundle size.

@@ -118,18 +151,21 @@ export class SentrySpan implements Span {
}

/** @inheritdoc */
public setAttribute(key: string, value: SpanAttributeValue | undefined): void {
public setAttribute(key: string, value: SpanAttributeValue | undefined): this {
Copy link
Member

Choose a reason for hiding this comment

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

Yeah, let's keep it.

@chargome chargome merged commit 935bb61 into develop Jul 18, 2024
121 checks passed
@chargome chargome deleted the cg/align-span-interface branch July 18, 2024 09:21
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.

Align Span interface with changes in Otel Span interface
4 participants