sentry-java icon indicating copy to clipboard operation
sentry-java copied to clipboard

POTEL 1 - Use OpenTelemetry for Performance and `Scopes` propagation

Open adinauer opened this issue 1 year ago • 2 comments

:scroll: Description

  • Rely on Context for Scopes propagation by hooking into OpenTelemetry Context storage
  • Fork Scopes when new OpenTelemetry spans are created
  • Add a util for figuring out which storage mechanism for Scopes to use on startup
    • If our OpenTelemetry code is available, it'll use Context based storage
    • Otherwise it'll default to our own ThreadLocal based storage
  • SpanProcessor and Propagator are also involved in Scopes forking
  • SpanExporter combines OpenTelemetry spans into Sentry transactions and sends them
  • Add a new Gradle module sentry-opentelemetry-bootstrap so certain classes can be added to the bootstrap classloader
  • We use a global storage for linking OpenTelemetry spans and Sentry Scopes

:bulb: Motivation and Context

Make Java SDK more compatible with OpenTelemetry by forking Scopes along OpenTelemetry and using OpenTelemetry Context for propagation of Scopes.

:green_heart: How did you test it?

:pencil: 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.

:crystal_ball: Next steps

adinauer avatar Apr 30 '24 08:04 adinauer

Fails
:no_entry_sign: Please consider adding a changelog entry for the next release.
Messages
:book: Do not forget to update Sentry-docs with your feature once the pull request gets approved.

Instructions and example for changelog

Please add an entry to CHANGELOG.md to the "Unreleased" section. Make sure the entry includes this PR's number.

Example:

## Unreleased

- POTEL 1 - Use OpenTelemetry for Performance and `Scopes` propagation ([#3399](https://github.com/getsentry/sentry-java/pull/3399))

If none of the above apply, you can opt out of this check by adding #skip-changelog to the PR description.

Generated by :no_entry_sign: dangerJS against cd6e592d262f62dadca40f1c4dc4081da992b3f6

github-actions[bot] avatar Apr 30 '24 08:04 github-actions[bot]

Performance metrics :rocket:

  Plain With Sentry Diff
Startup time 374.45 ms 449.56 ms 75.11 ms
Size 1.70 MiB 2.29 MiB 598.04 KiB

Baseline results on branch: 8.x.x

Startup times

Revision Plain With Sentry Diff
a373f020dc423eab02ff263f005494d00c57e2c4 372.81 ms 432.96 ms 60.15 ms
dcad3c9309c1849fe21f1d4dceaa0a7990477d1e 400.04 ms 479.67 ms 79.62 ms
3e1e45bf7179435cf8da8c7d2ee1511bb585485e 373.72 ms 439.33 ms 65.60 ms
9428efa5bd61a12862f4cc5e22dce8597e464893 389.31 ms 481.67 ms 92.37 ms
34db09fa45d95fbd4a0756cae22791b83c399e7d 362.68 ms 443.02 ms 80.34 ms
6f168826c814df0d6651918b2f7ff0e7ece4c639 426.16 ms 494.15 ms 67.99 ms
9f2c8552fd8bf28926a24cb82be26f6a48a50183 424.20 ms 506.34 ms 82.14 ms

App size

Revision Plain With Sentry Diff
a373f020dc423eab02ff263f005494d00c57e2c4 1.70 MiB 2.28 MiB 596.35 KiB
dcad3c9309c1849fe21f1d4dceaa0a7990477d1e 1.70 MiB 2.28 MiB 596.35 KiB
3e1e45bf7179435cf8da8c7d2ee1511bb585485e 1.70 MiB 2.28 MiB 596.32 KiB
9428efa5bd61a12862f4cc5e22dce8597e464893 1.70 MiB 2.28 MiB 597.68 KiB
34db09fa45d95fbd4a0756cae22791b83c399e7d 1.70 MiB 2.28 MiB 596.37 KiB
6f168826c814df0d6651918b2f7ff0e7ece4c639 1.70 MiB 2.28 MiB 596.37 KiB
9f2c8552fd8bf28926a24cb82be26f6a48a50183 1.70 MiB 2.28 MiB 596.32 KiB

github-actions[bot] avatar Apr 30 '24 08:04 github-actions[bot]