-
-
Notifications
You must be signed in to change notification settings - Fork 461
Report OpenTelemetry Agentless SDK and integration #4570
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
Changes from all commits
1ce9608
a863ac5
811c9da
16dcaee
5d9f010
bee800a
e531d9d
9d01916
105e0d0
195937c
d5fd3b0
e2de187
4ca9d75
521850d
0ac58fd
469e399
6886aef
7cbb0cc
d764e43
c6f7d1d
75436ce
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,7 +21,7 @@ public final class ManifestVersionReader { | |
| private static final @NotNull AutoClosableReentrantLock staticLock = | ||
| new AutoClosableReentrantLock(); | ||
| private volatile boolean hasManifestBeenRead = false; | ||
| private volatile @Nullable VersionInfoHolder versionInfo = null; | ||
| private final @NotNull VersionInfoHolder versionInfo = new VersionInfoHolder(); | ||
| private @NotNull AutoClosableReentrantLock lock = new AutoClosableReentrantLock(); | ||
|
|
||
| public static @NotNull ManifestVersionReader getInstance() { | ||
|
|
@@ -40,6 +40,9 @@ private ManifestVersionReader() {} | |
|
|
||
| public @Nullable VersionInfoHolder readOpenTelemetryVersion() { | ||
| readManifestFiles(); | ||
| if (versionInfo.sdkVersion == null) { | ||
| return null; | ||
| } | ||
| return versionInfo; | ||
| } | ||
|
|
||
|
|
@@ -48,7 +51,6 @@ public void readManifestFiles() { | |
| return; | ||
| } | ||
|
|
||
| @Nullable VersionInfoHolder infoHolder = null; | ||
| try (final @NotNull ISentryLifecycleToken ignored = lock.acquire()) { | ||
| if (hasManifestBeenRead) { | ||
| return; | ||
|
|
@@ -66,28 +68,32 @@ public void readManifestFiles() { | |
| final @Nullable String packageName = mainAttributes.getValue("Sentry-SDK-Package-Name"); | ||
|
|
||
| if (name != null && version != null) { | ||
| infoHolder = new VersionInfoHolder(); | ||
| infoHolder.sdkName = name; | ||
| infoHolder.sdkVersion = version; | ||
| infoHolder.packages.add( | ||
| new SentryPackage("maven:io.sentry:sentry-opentelemetry-agent", version)); | ||
| versionInfo.sdkName = name; | ||
| versionInfo.sdkVersion = version; | ||
| final @Nullable String otelVersion = | ||
| mainAttributes.getValue("Sentry-Opentelemetry-Version-Name"); | ||
| if (otelVersion != null) { | ||
| infoHolder.packages.add( | ||
| versionInfo.packages.add( | ||
| new SentryPackage("maven:io.opentelemetry:opentelemetry-sdk", otelVersion)); | ||
| infoHolder.integrations.add("OpenTelemetry"); | ||
| versionInfo.integrations.add("OpenTelemetry"); | ||
| } | ||
| final @Nullable String otelJavaagentVersion = | ||
| mainAttributes.getValue("Sentry-Opentelemetry-Javaagent-Version-Name"); | ||
| if (otelJavaagentVersion != null) { | ||
| infoHolder.packages.add( | ||
| versionInfo.packages.add( | ||
| new SentryPackage( | ||
| "maven:io.opentelemetry.javaagent:opentelemetry-javaagent", | ||
| otelJavaagentVersion)); | ||
| infoHolder.integrations.add("OpenTelemetry-Agent"); | ||
| versionInfo.integrations.add("OpenTelemetry-Agent"); | ||
| } | ||
| if (name.equals("sentry.java.opentelemetry.agentless")) { | ||
| SentryIntegrationPackageStorage.getInstance() | ||
| .addIntegration("OpenTelemetry-Agentless"); | ||
| } | ||
| if (name.equals("sentry.java.opentelemetry.agentless-spring")) { | ||
| SentryIntegrationPackageStorage.getInstance() | ||
| .addIntegration("OpenTelemetry-Agentless-Spring"); | ||
|
Comment on lines
+90
to
+95
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should add to
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It feels much cleaner to just remove integrations and packages from |
||
| } | ||
| break; | ||
| } | ||
|
|
||
| if (sdkName != null | ||
|
|
@@ -105,13 +111,12 @@ public void readManifestFiles() { | |
| // ignore | ||
| } finally { | ||
| hasManifestBeenRead = true; | ||
| versionInfo = infoHolder; | ||
| } | ||
| } | ||
|
|
||
| public static final class VersionInfoHolder { | ||
| private @Nullable String sdkName; | ||
| private @Nullable String sdkVersion; | ||
| private volatile @Nullable String sdkName; | ||
| private volatile @Nullable String sdkVersion; | ||
| private List<SentryPackage> packages = new ArrayList<>(); | ||
| private List<String> integrations = new ArrayList<>(); | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Manifest Loop Issue Causes SDK Version Overwrite
The removal of the
breakstatement from the manifest processing loop causesversionInfo.sdkNameandversionInfo.sdkVersionto be overwritten by each subsequent OpenTelemetry manifest found. This leads to non-deterministic and potentially incorrect SDK version reporting, as only the last processed manifest's details are retained. Furthermore, themaven:io.sentry:sentry-opentelemetry-agentpackage is no longer added, resulting in incomplete package information.Locations (1)
sentry/src/main/java/io/sentry/internal/ManifestVersionReader.java#L69-L97