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

Remove debug logs when searching for OpenTelemetry marker classes #4091

Merged
merged 4 commits into from
Jan 23, 2025

Conversation

adinauer
Copy link
Member

📜 Description

Use NoOpLogger for LoadClass when searching for OpenTelemetry marker classes to determine if Sentry OpenTelemetry dependencies / agent are present.

💡 Motivation and Context

It's not a nice experience to start the SDK without OpenTelemetry and be greeted with a wall of stacktraces when debug is enabled.

DEBUG: Class not available:io.sentry.opentelemetry.agent.AgentMarker
java.lang.ClassNotFoundException: io.sentry.opentelemetry.agent.AgentMarker
	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
	at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:526)
	at java.base/java.lang.Class.forName0(Native Method)
	at java.base/java.lang.Class.forName(Class.java:421)
	at java.base/java.lang.Class.forName(Class.java:412)
	at io.sentry.util.LoadClass.loadClass(LoadClass.java:23)
	at io.sentry.util.LoadClass.isClassAvailable(LoadClass.java:41)
	at io.sentry.opentelemetry.OpenTelemetryUtil.ignoredSpanOrigins(OpenTelemetryUtil.java:31)
	at io.sentry.opentelemetry.OpenTelemetryUtil.applyIgnoredSpanOrigins(OpenTelemetryUtil.java:20)
	at io.sentry.Sentry.initConfigurations(Sentry.java:516)
	at io.sentry.Sentry.init(Sentry.java:328)
	at io.sentry.Sentry.init(Sentry.java:259)
	...

DEBUG: Class not available:io.sentry.opentelemetry.agent.AgentlessMarker
java.lang.ClassNotFoundException: io.sentry.opentelemetry.agent.AgentlessMarker
	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
	at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:526)
	...

DEBUG: Class not available:io.sentry.opentelemetry.agent.AgentlessSpringMarker
java.lang.ClassNotFoundException: io.sentry.opentelemetry.agent.AgentlessSpringMarker
	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
	at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:526)
	...

💚 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 Jan 22, 2025

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

Generated by 🚫 dangerJS against 72d00b4

Copy link
Contributor

github-actions bot commented Jan 22, 2025

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 416.23 ms 478.39 ms 62.16 ms
Size 1.65 MiB 2.31 MiB 677.61 KiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
00c8eeb 415.32 ms 428.08 ms 12.76 ms

App size

Revision Plain With Sentry Diff
00c8eeb 1.70 MiB 2.36 MiB 671.98 KiB

Previous results on branch: feat/remove-debug-logs-for-loading-otel-classes

Startup times

Revision Plain With Sentry Diff
04af998 405.06 ms 460.74 ms 55.68 ms
92de480 414.71 ms 430.39 ms 15.67 ms
3411544 410.41 ms 513.26 ms 102.85 ms

App size

Revision Plain With Sentry Diff
04af998 1.65 MiB 2.31 MiB 677.61 KiB
92de480 1.65 MiB 2.31 MiB 677.59 KiB
3411544 1.65 MiB 2.31 MiB 677.61 KiB

@adinauer adinauer requested a review from lcian as a code owner January 22, 2025 18:45
Comment on lines +33 to +41
"io.sentry.opentelemetry.agent.AgentMarker", NoOpLogger.getInstance())) {
return SpanUtils.ignoredSpanOriginsForOpenTelemetry(SentryOpenTelemetryMode.AGENT);
}
if (loadClass.isClassAvailable(
"io.sentry.opentelemetry.agent.AgentlessMarker", options.getLogger())) {
"io.sentry.opentelemetry.agent.AgentlessMarker", NoOpLogger.getInstance())) {
return SpanUtils.ignoredSpanOriginsForOpenTelemetry(SentryOpenTelemetryMode.AGENTLESS);
}
if (loadClass.isClassAvailable(
"io.sentry.opentelemetry.agent.AgentlessSpringMarker", options.getLogger())) {
"io.sentry.opentelemetry.agent.AgentlessSpringMarker", NoOpLogger.getInstance())) {
Copy link
Member

Choose a reason for hiding this comment

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

LGTM, let's add a way to log this information along with the OpenTelemetryMode to help debug customer issues in another PR

Copy link
Member Author

Choose a reason for hiding this comment

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

Created #4099 to track

@adinauer adinauer merged commit 467b52b into main Jan 23, 2025
38 checks passed
@adinauer adinauer deleted the feat/remove-debug-logs-for-loading-otel-classes branch January 23, 2025 15:43
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.

Get rid of debug log messages complaining about missing OpenTelemetry marker classes
2 participants