Skip to content

Restore span names for GraphQL on the new version of OpenTelemetry (by changing OpenTelemetry defaults) #4537

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

Conversation

adinauer
Copy link
Member

@adinauer adinauer commented Jul 3, 2025

📜 Description

GraphQL span names in OpenTelemetry have been changed to just query from e.g. query GreetingQuery for this query:

query GreetingQuery($name: String) {
    greeting(name: $name)
}

This PR uses span attributes to restore the previous op and description for Sentry spans by changing the following config of the OpenTelemetry SDK to restore previous behaviour:

System.setProperty("otel.instrumentation.graphql.add-operation-name-to-span-name.enabled", "true");

More info:

💡 Motivation and Context

💚 How did you test it?

📝 Checklist

  • 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.
  • I updated the wizard 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, 2025

Fails
🚫 Please consider adding a changelog entry for the next release.
Messages
📖 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

- Restore span names for GraphQL on the new version of OpenTelemetry (by changing OpenTelemetry defaults) ([#4537](https://github.com/getsentry/sentry-java/pull/4537))

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

Generated by 🚫 dangerJS against 4f5e29d

Copy link
Contributor

github-actions bot commented Jul 3, 2025

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 359.33 ms 377.26 ms 17.93 ms
Size 1.58 MiB 2.09 MiB 519.08 KiB

Baseline results on branch: feat/bump-otel-1_51_0

Startup times

Revision Plain With Sentry Diff
228dd89 449.13 ms 465.16 ms 16.04 ms
f2bb552 412.40 ms 417.63 ms 5.23 ms

App size

Revision Plain With Sentry Diff
228dd89 1.58 MiB 2.09 MiB 518.90 KiB
f2bb552 1.58 MiB 2.09 MiB 518.90 KiB

Previous results on branch: feat/otel-bump-graphql-op-fix-change-otel-defaults

Startup times

Revision Plain With Sentry Diff
8053e0b 409.17 ms 452.52 ms 43.35 ms
33c64d6 419.66 ms 488.46 ms 68.80 ms
3a46437 386.28 ms 408.67 ms 22.39 ms

App size

Revision Plain With Sentry Diff
8053e0b 1.58 MiB 2.09 MiB 519.08 KiB
33c64d6 1.58 MiB 2.09 MiB 519.07 KiB
3a46437 1.58 MiB 2.09 MiB 519.08 KiB

@lcian
Copy link
Member

lcian commented Jul 3, 2025

Wrong branch I think, anyway I understand the approach.
Would it be possible for the user to override our choice of otel.instrumentation.graphql.add-operation-name-to-span-name.enabled? Or would we be forcing it to true regardless of what the user sets?

@adinauer adinauer force-pushed the feat/otel-bump-graphql-op-fix-change-otel-defaults branch from 199ce90 to aed6b3b Compare July 3, 2025 07:49
@adinauer
Copy link
Member Author

adinauer commented Jul 3, 2025

Wrong branch I think, anyway I understand the approach.

Fixed

Copy link
Member

@lcian lcian left a comment

Choose a reason for hiding this comment

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

Nice, I prefer this option as it allows the user to easily override it, it's more transparent, and less code to maintain.

@adinauer adinauer merged commit 3166922 into feat/bump-otel-1_51_0 Jul 3, 2025
24 of 26 checks passed
@adinauer adinauer deleted the feat/otel-bump-graphql-op-fix-change-otel-defaults branch July 3, 2025 09:23
adinauer added a commit that referenced this pull request Jul 7, 2025
…emconv to `1.34.0` (#4532)

* Bump OTel SDK to 1.51.0, instrumentation to 2.17.0 and semconv to 1.34.0

* Restore span names for GraphQL on the new version of OpenTelemetry (by changing OpenTelemetry defaults) (#4537)

* do not override span name if customized

* Format code

* log in case system property cannot be set

* merge

* changelog

---------

Co-authored-by: Sentry Github Bot <bot+github-bot@sentry.io>

* Use non alpha version for semconv

* move changelog entry

---------

Co-authored-by: Sentry Github Bot <bot+github-bot@sentry.io>
adinauer added a commit that referenced this pull request Jul 8, 2025
* Bump OTel SDK to 1.51.0, instrumentation to 2.17.0 and semconv to 1.34.0

* Restore span names for GraphQL on the new version of OpenTelemetry (by changing OpenTelemetry defaults) (#4537)

* do not override span name if customized

* Format code

* log in case system property cannot be set

* merge

* changelog

---------

Co-authored-by: Sentry Github Bot <bot+github-bot@sentry.io>

* more assertions for e2e tests

* Use non alpha version for semconv

* fix changelog

* Format code

* api file and format

---------

Co-authored-by: Sentry Github Bot <bot+github-bot@sentry.io>
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