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(node)!: Avoid http spans by default for custom OTEL setups #14678

Merged
merged 2 commits into from
Dec 13, 2024

Conversation

mydea
Copy link
Member

@mydea mydea commented Dec 12, 2024

With this PR, the default value for the spans option in the httpIntegration is changed to false, if skipOpenTelemetrySetup: true is configured. This is what you'd expect as a user, you do not want Sentry to register any OTEL instrumentation and emit any spans in this scenario.

Closes #14675

@mydea mydea requested review from lforst and AbhiPrasad December 12, 2024 10:47
@mydea mydea self-assigned this Dec 12, 2024
@@ -158,3 +158,4 @@
- Deprecated `addOpenTelemetryInstrumentation`. Use the `openTelemetryInstrumentations` option in `Sentry.init()` or your custom Sentry Client instead.
- Deprecated `registerEsmLoaderHooks.include` and `registerEsmLoaderHooks.exclude`. Set `onlyIncludeInstrumentedModules: true` instead.
- `registerEsmLoaderHooks` will only accept `true | false | undefined` in the future. The SDK will default to wrapping modules that are used as part of OpenTelemetry Instrumentation.
- `httpIntegration({ spans: false })` is configured by default if `skipOpenTelemetrySetup: true` is set. You can still overwrite this if desired.
Copy link
Member

Choose a reason for hiding this comment

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

I would phrase it a bit differently and explain it to people like this: "The httpIntegration will no longer set up the Opentelemetry HTTP Instrumentation when skipOpenTelemetrySetup: true, or when spans: false is set."

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 added "better" docs to the v8-to-v9 migration guide, which I only saw after I wrote this 😅 should we maintain both of these docs?

Copy link
Member

Choose a reason for hiding this comment

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

I will merge them into one once develop becomes the "main" branch for the v9 work.

@@ -118,12 +121,21 @@ export const instrumentOtelHttp = generateInstrumentOnce<HttpInstrumentationConf
return instrumentation;
});

/** Exported only for tests. */
export function _shouldInstrumentSpans(options: HttpOptions, clientOptions: Partial<NodeClientOptions> = {}): boolean {
Copy link
Member

Choose a reason for hiding this comment

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

l: Do we really need a helper function + test for this? Imo could just be a const with description. Makes it rather hard to read.

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 just wanted to double check the behavior is correct without adding integration tests etc for this 😅 I always find it easy for little bugs to sneak in in such places, e.g. if you have a wrong ! somewhere everything can become wrong, which can be easy to miss when testing "happy paths" in integration tests only.

Copy link
Contributor

github-actions bot commented Dec 12, 2024

size-limit report 📦

Path Size % Change Change
@sentry/browser 23.27 KB - -
@sentry/browser - with treeshaking flags 21.94 KB - -
@sentry/browser (incl. Tracing) 35.77 KB - -
@sentry/browser (incl. Tracing, Replay) 73 KB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 63.4 KB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 77.31 KB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 89.8 KB - -
@sentry/browser (incl. Feedback) 40.02 KB - -
@sentry/browser (incl. sendFeedback) 27.88 KB - -
@sentry/browser (incl. FeedbackAsync) 32.67 KB - -
@sentry/react 25.94 KB - -
@sentry/react (incl. Tracing) 38.59 KB - -
@sentry/vue 27.47 KB - -
@sentry/vue (incl. Tracing) 37.61 KB - -
@sentry/svelte 23.43 KB - -
CDN Bundle 24.41 KB - -
CDN Bundle (incl. Tracing) 37.43 KB - -
CDN Bundle (incl. Tracing, Replay) 72.62 KB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 77.98 KB - -
CDN Bundle - uncompressed 71.69 KB - -
CDN Bundle (incl. Tracing) - uncompressed 110.99 KB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 225.06 KB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 238.28 KB - -
@sentry/nextjs (client) 38.88 KB - -
@sentry/sveltekit (client) 36.27 KB - -
@sentry/node 162.44 KB +0.03% +38 B 🔺
@sentry/node - without tracing 98.6 KB +0.04% +34 B 🔺
@sentry/aws-serverless 126.3 KB +0.03% +29 B 🔺

View base workflow run

Copy link

codecov bot commented Dec 12, 2024

❌ 4 Tests Failed:

Tests completed Failed Passed Skipped
252 4 248 8
View the top 3 failed tests by shortest run time
errors.test.ts Sends correct error event
Stack Traces | 0.122s run time
errors.test.ts:4:5 Sends correct error event
sampling.test.ts Sends a sampled API route transaction
Stack Traces | 30s run time
sampling.test.ts:4:5 Sends a sampled API route transaction
transactions.test.ts Sends an API route transaction for an errored route
Stack Traces | 30s run time
transactions.test.ts:131:5 Sends an API route transaction for an errored route

To view more test analytics, go to the Test Analytics Dashboard
📢 Thoughts on this report? Let us know!

@mydea mydea merged commit 8b81476 into v9 Dec 13, 2024
136 checks passed
@mydea mydea deleted the fn/http-spans-default branch December 13, 2024 08:19
mydea added a commit that referenced this pull request Dec 13, 2024
With this PR, the default value for the `spans` option in the
`httpIntegration` is changed to `false`, if `skipOpenTelemetrySetup:
true` is configured. This is what you'd expect as a user, you do not
want Sentry to register any OTEL instrumentation and emit any spans in
this scenario.

Closes #14675
mydea added a commit that referenced this pull request Dec 13, 2024
With this PR, the default value for the `spans` option in the
`httpIntegration` is changed to `false`, if `skipOpenTelemetrySetup:
true` is configured. This is what you'd expect as a user, you do not
want Sentry to register any OTEL instrumentation and emit any spans in
this scenario.

Closes #14675
lforst pushed a commit that referenced this pull request Dec 13, 2024
With this PR, the default value for the `spans` option in the
`httpIntegration` is changed to `false`, if `skipOpenTelemetrySetup:
true` is configured. This is what you'd expect as a user, you do not
want Sentry to register any OTEL instrumentation and emit any spans in
this scenario.

Closes #14675
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.

[v9] Set spans: false in httpIntegration when skipOpenTelemetrySetup: true
3 participants