Skip to content

feat(core): Allow custom tracing implementations #11003

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 1 commit into from
Mar 11, 2024
Merged

Conversation

mydea
Copy link
Member

@mydea mydea commented Mar 11, 2024

And do this for opentelemetry, instead of relying on extra exports.

Also needed to move things around a bit to avoid circular dependency build issues.

Missing is getRootSpan which is still different, I will update this in a follow up to actually use the same non-enumerable property under the hood so we can use the same implementation there!

Reasoning

Until now, we had a core implementation of tracing APIs in @sentry/core. In @sentry/opentelemetry, we had some alternative implementations, which where instead re-exported in @sentry/node - so if you do e.g. this:

import { startSpan } from '@sentry/node';

You'll get the correct, OTEL-powered performance API - great!

However, if any code would internally do e.g. this:

import { getActiveSpan } from '@sentry/core'; // import from core, not node

It would not work, because it would use the non-OTEL-powered API.

This PR addresses this by ensuring we use the same API everywhere when @sentry/node is being used.

And do this for opentelemetry, instead of relying on extra exports.

Also needed to move things around a bit to avoid circular dependency build issues.
Copy link
Contributor

@lforst lforst left a comment

Choose a reason for hiding this comment

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

Looks great! One thing though: Would you mind going into a little bit more detail in the PR description? I know all the context around this change because we had this convo offline but future readers might not know that. Thanks!

export function startSpanManual<T>(options: OpenTelemetrySpanContext, callback: (span: Span) => T): T {
export function startSpanManual<T>(
options: OpenTelemetrySpanContext,
callback: (span: Span, finish: () => void) => T,
Copy link
Contributor

Choose a reason for hiding this comment

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

What is this change about?

Copy link
Member Author

Choose a reason for hiding this comment

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

Aligning the APIs - we talked about removing the finish callback, but it's actually still there in core, we may or may not want to delete it (it's not deprecated so far 😬 ), so I had to add it in the otel implementation as well to make the APIs compatible 😬

@mydea mydea merged commit e249f36 into develop Mar 11, 2024
@mydea mydea deleted the fn/acs-tracing branch March 11, 2024 12:08
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