Skip to content

Commit 5b05195

Browse files
authored
Report OpenTelemetry Agentless SDK and integration (#4570)
#skip-changelog ## 📜 Description <!--- Describe your changes in detail --> Report OpenTelemetry Agentless SDK and integration ## 💡 Motivation and Context <!--- Why is this change required? What problem does it solve? --> <!--- If it fixes an open issue, please link to the issue here. --> To have better stats on which ways of combining Sentry and OpenTelemetry are most used and make most sense to invest in. ## 💚 How did you test it? ## 📝 Checklist <!--- Put an `x` in the boxes that apply --> - [ ] 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
1 parent dea75aa commit 5b05195

File tree

3 files changed

+23
-15
lines changed

3 files changed

+23
-15
lines changed

sentry-opentelemetry/sentry-opentelemetry-agentless-spring/build.gradle.kts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ buildConfig {
3030
tasks.jar {
3131
manifest {
3232
attributes(
33+
"Sentry-Opentelemetry-SDK-Name" to
34+
Config.Sentry.SENTRY_OPENTELEMETRY_AGENTLESS_SPRING_SDK_NAME,
3335
"Sentry-Version-Name" to project.version,
3436
"Sentry-SDK-Name" to Config.Sentry.SENTRY_OPENTELEMETRY_AGENTLESS_SPRING_SDK_NAME,
3537
"Sentry-SDK-Package-Name" to "maven:io.sentry:sentry-opentelemetry-agentless-spring",

sentry-opentelemetry/sentry-opentelemetry-agentless/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ buildConfig {
2828
tasks.jar {
2929
manifest {
3030
attributes(
31+
"Sentry-Opentelemetry-SDK-Name" to Config.Sentry.SENTRY_OPENTELEMETRY_AGENTLESS_SDK_NAME,
3132
"Sentry-Version-Name" to project.version,
3233
"Sentry-SDK-Name" to Config.Sentry.SENTRY_OPENTELEMETRY_AGENTLESS_SDK_NAME,
3334
"Sentry-SDK-Package-Name" to "maven:io.sentry:sentry-opentelemetry-agentless",

sentry/src/main/java/io/sentry/internal/ManifestVersionReader.java

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public final class ManifestVersionReader {
2121
private static final @NotNull AutoClosableReentrantLock staticLock =
2222
new AutoClosableReentrantLock();
2323
private volatile boolean hasManifestBeenRead = false;
24-
private volatile @Nullable VersionInfoHolder versionInfo = null;
24+
private final @NotNull VersionInfoHolder versionInfo = new VersionInfoHolder();
2525
private @NotNull AutoClosableReentrantLock lock = new AutoClosableReentrantLock();
2626

2727
public static @NotNull ManifestVersionReader getInstance() {
@@ -40,6 +40,9 @@ private ManifestVersionReader() {}
4040

4141
public @Nullable VersionInfoHolder readOpenTelemetryVersion() {
4242
readManifestFiles();
43+
if (versionInfo.sdkVersion == null) {
44+
return null;
45+
}
4346
return versionInfo;
4447
}
4548

@@ -48,7 +51,6 @@ public void readManifestFiles() {
4851
return;
4952
}
5053

51-
@Nullable VersionInfoHolder infoHolder = null;
5254
try (final @NotNull ISentryLifecycleToken ignored = lock.acquire()) {
5355
if (hasManifestBeenRead) {
5456
return;
@@ -66,28 +68,32 @@ public void readManifestFiles() {
6668
final @Nullable String packageName = mainAttributes.getValue("Sentry-SDK-Package-Name");
6769

6870
if (name != null && version != null) {
69-
infoHolder = new VersionInfoHolder();
70-
infoHolder.sdkName = name;
71-
infoHolder.sdkVersion = version;
72-
infoHolder.packages.add(
73-
new SentryPackage("maven:io.sentry:sentry-opentelemetry-agent", version));
71+
versionInfo.sdkName = name;
72+
versionInfo.sdkVersion = version;
7473
final @Nullable String otelVersion =
7574
mainAttributes.getValue("Sentry-Opentelemetry-Version-Name");
7675
if (otelVersion != null) {
77-
infoHolder.packages.add(
76+
versionInfo.packages.add(
7877
new SentryPackage("maven:io.opentelemetry:opentelemetry-sdk", otelVersion));
79-
infoHolder.integrations.add("OpenTelemetry");
78+
versionInfo.integrations.add("OpenTelemetry");
8079
}
8180
final @Nullable String otelJavaagentVersion =
8281
mainAttributes.getValue("Sentry-Opentelemetry-Javaagent-Version-Name");
8382
if (otelJavaagentVersion != null) {
84-
infoHolder.packages.add(
83+
versionInfo.packages.add(
8584
new SentryPackage(
8685
"maven:io.opentelemetry.javaagent:opentelemetry-javaagent",
8786
otelJavaagentVersion));
88-
infoHolder.integrations.add("OpenTelemetry-Agent");
87+
versionInfo.integrations.add("OpenTelemetry-Agent");
88+
}
89+
if (name.equals("sentry.java.opentelemetry.agentless")) {
90+
SentryIntegrationPackageStorage.getInstance()
91+
.addIntegration("OpenTelemetry-Agentless");
92+
}
93+
if (name.equals("sentry.java.opentelemetry.agentless-spring")) {
94+
SentryIntegrationPackageStorage.getInstance()
95+
.addIntegration("OpenTelemetry-Agentless-Spring");
8996
}
90-
break;
9197
}
9298

9399
if (sdkName != null
@@ -105,13 +111,12 @@ public void readManifestFiles() {
105111
// ignore
106112
} finally {
107113
hasManifestBeenRead = true;
108-
versionInfo = infoHolder;
109114
}
110115
}
111116

112117
public static final class VersionInfoHolder {
113-
private @Nullable String sdkName;
114-
private @Nullable String sdkVersion;
118+
private volatile @Nullable String sdkName;
119+
private volatile @Nullable String sdkVersion;
115120
private List<SentryPackage> packages = new ArrayList<>();
116121
private List<String> integrations = new ArrayList<>();
117122

0 commit comments

Comments
 (0)