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

POTEL 30 - span.startChild now uses .makeCurrent() by default #3544

Merged
merged 4 commits into from
Jul 3, 2024

Conversation

adinauer
Copy link
Member

@adinauer adinauer commented Jul 3, 2024

📜 Description

When starting a child span of a OtelSpanWrapper span (i.e. use Sentry API and OpenTelemetry under the hood), we now call .makeCurrent() on the child span by default so it's made the current span.

💡 Motivation and Context

Without this, there's a difference in behaviour when using OpenTelemetry. Making a span current was previously part of the transaction which can or cannot be the current transaction on the stack.

We could follow up on this by exposing a flag on SpanOptions that allows customers to control this. We already have bindToScope for TransactionOptions which defaults to false. For backend IMO it makes much more sense to bind to scope by default. This option can then also be used for Sentry.startSpan and Sentry.startInactiveSpan.

💚 How did you test it?

📝 Checklist

  • I reviewed the submitted code.
  • I added tests to verify the changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • I updated the docs if needed.
  • Review from the native team if needed.
  • No breaking change or entry added to the changelog.
  • No breaking change for hybrid SDKs or communicated to hybrid SDKs.

🔮 Next steps

Copy link
Contributor

github-actions bot commented Jul 3, 2024

Messages
📖 Do not forget to update Sentry-docs with your feature once the pull request gets approved.

Generated by 🚫 dangerJS against bcae360

Copy link
Contributor

github-actions bot commented Jul 3, 2024

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 399.71 ms 467.16 ms 67.45 ms
Size 1.70 MiB 2.29 MiB 599.77 KiB

Baseline results on branch: 8.x.x

Startup times

Revision Plain With Sentry Diff
a59fca2 560.08 ms 658.80 ms 98.71 ms

App size

Revision Plain With Sentry Diff
a59fca2 1.70 MiB 2.29 MiB 599.77 KiB

Previous results on branch: feat/potel-30-child-span-make-current-by-default

Startup times

Revision Plain With Sentry Diff
be5a4cc 391.08 ms 457.08 ms 66.00 ms

App size

Revision Plain With Sentry Diff
be5a4cc 1.70 MiB 2.29 MiB 599.77 KiB

@@ -129,7 +129,11 @@ public OtelSpanWrapper(
return NoOpSpan.getInstance();
Copy link
Member

Choose a reason for hiding this comment

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

this should also use makeCurrent(), even if there is no practical change, right?

Copy link
Member Author

@adinauer adinauer Jul 3, 2024

Choose a reason for hiding this comment

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

Yeah NoOpSpan.makeCurrent does nothing and returns a NoOpScopesLifecycleToken atm.

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 checked, there's more places where we would have to add this .makeCurrent for noop spans. I'd say we only add it when we actually need it. That's if we ever change NoOpSpan.makeCurrent to modify Context.

Base automatically changed from feat/potel-29-partially-fix-bootstrap-class-loading to 8.x.x July 3, 2024 12:19
@adinauer adinauer merged commit 49cc6bb into 8.x.x Jul 3, 2024
22 checks passed
@adinauer adinauer deleted the feat/potel-30-child-span-make-current-by-default branch July 3, 2024 13:42
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