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

fix(node): Improve OTEL validation logic #13079

Merged
merged 2 commits into from
Jul 29, 2024
Merged

Conversation

mydea
Copy link
Member

@mydea mydea commented Jul 29, 2024

When using the SDK without tracing, the span processor is not required - we should reflect this in our validation logic.

While at it, I also improved the warning for not using the SentrySampler.

Copy link
Contributor

github-actions bot commented Jul 29, 2024

size-limit report 📦

Path Size
@sentry/browser 22.4 KB (0%)
@sentry/browser (incl. Tracing) 33.85 KB (0%)
@sentry/browser (incl. Tracing, Replay) 69.91 KB (0%)
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 63.25 KB (0%)
@sentry/browser (incl. Tracing, Replay with Canvas) 74.31 KB (0%)
@sentry/browser (incl. Tracing, Replay, Feedback) 86.88 KB (0%)
@sentry/browser (incl. Tracing, Replay, Feedback, metrics) 88.77 KB (0%)
@sentry/browser (incl. metrics) 26.71 KB (0%)
@sentry/browser (incl. Feedback) 39.32 KB (0%)
@sentry/browser (incl. sendFeedback) 27.02 KB (0%)
@sentry/browser (incl. FeedbackAsync) 31.66 KB (0%)
@sentry/react 25.17 KB (0%)
@sentry/react (incl. Tracing) 36.9 KB (0%)
@sentry/vue 26.55 KB (0%)
@sentry/vue (incl. Tracing) 35.7 KB (0%)
@sentry/svelte 22.54 KB (0%)
CDN Bundle 23.59 KB (0%)
CDN Bundle (incl. Tracing) 35.58 KB (0%)
CDN Bundle (incl. Tracing, Replay) 69.95 KB (0%)
CDN Bundle (incl. Tracing, Replay, Feedback) 75.22 KB (0%)
CDN Bundle - uncompressed 69.32 KB (0%)
CDN Bundle (incl. Tracing) - uncompressed 105.42 KB (0%)
CDN Bundle (incl. Tracing, Replay) - uncompressed 217.06 KB (0%)
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 229.89 KB (0%)
@sentry/nextjs (client) 36.75 KB (0%)
@sentry/sveltekit (client) 34.49 KB (0%)
@sentry/node 111.9 KB (+0.05% 🔺)
@sentry/node - without tracing 89.33 KB (+0.04% 🔺)
@sentry/aws-serverless 98.49 KB (+0.06% 🔺)

Copy link
Member

@andreiborza andreiborza left a comment

Choose a reason for hiding this comment

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

Could we add a test for this?

@mydea
Copy link
Member Author

mydea commented Jul 29, 2024

Could we add a test for this?

We have tests covering that this actually works (e.g. not having span processor), it was just not nicely reflected in the warning messages. Sadly it is hard to test this properly because this runs in node on init, which makes it tricky to test this well in e.g. an e2e test.

@@ -193,3 +195,65 @@ describe('init()', () => {
});
});
});

describe('validateOpenTelemetrySetup', () => {
Copy link
Member Author

Choose a reason for hiding this comment

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

@andreiborza added unit tests here!

Copy link
Member

Choose a reason for hiding this comment

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

Awesome, thanks :)

expect(warnSpy).toHaveBeenCalledTimes(1);

expect(errorSpy).toBeCalledWith(expect.stringContaining('You have to set up the SentryContextManager.'));
expect(errorSpy).toBeCalledWith(expect.stringContaining('You have to set up the SentryPropagator.'));
Copy link
Member

Choose a reason for hiding this comment

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

l: I think it would be good to also assert on the message we don't expect to show up as well, just relying on the number of times it has been called is error prone.

@mydea mydea merged commit 9a8e910 into develop Jul 29, 2024
111 checks passed
@mydea mydea deleted the fn/otel-warning-errors branch July 29, 2024 08:45
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.

3 participants