Skip to content

Commit 1ba9b55

Browse files
committed
Add distro name and version to the SDK name
1 parent 32092fb commit 1ba9b55

File tree

2 files changed

+25
-36
lines changed
  • sdk/monitor/azure-monitor-opentelemetry-autoconfigure/src
    • main/java/com/azure/monitor/opentelemetry/autoconfigure/implementation/utils
    • test/java/com/azure/monitor/opentelemetry/autoconfigure/implementation/utils

2 files changed

+25
-36
lines changed

sdk/monitor/azure-monitor-opentelemetry-autoconfigure/src/main/java/com/azure/monitor/opentelemetry/autoconfigure/implementation/utils/VersionGenerator.java

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,37 @@
1313
public final class VersionGenerator {
1414
private static final String UNKNOWN_VERSION_VALUE = "unknown";
1515

16-
private static final String artifactName;
17-
private static final String artifactVersion;
18-
1916
private static final String sdkVersionString;
2017

2118
static {
22-
Map<String, String> properties
23-
= CoreUtils.getProperties("azure-monitor-opentelemetry-autoconfigure.properties");
19+
String componentName = null;
20+
String componentVersion = null;
21+
22+
Map<String, String> springDistroProperties
23+
= CoreUtils.getProperties("azure-spring-cloud-azure-starter-monitor.properties");
24+
String springDistroVersion = springDistroProperties.get("version");
25+
if(springDistroVersion != null) {
26+
componentName = "dss";
27+
componentVersion = springDistroVersion;
28+
}
29+
30+
Map<String, String> quarkusProperties
31+
= CoreUtils.getProperties("quarkus-exporter.properties");
32+
String quarkusVersion = quarkusProperties.get("version");
33+
if(quarkusVersion != null) {
34+
componentName = "dsq";
35+
componentVersion = quarkusVersion;
36+
}
2437

25-
artifactName = properties.get("name");
26-
artifactVersion = properties.get("version");
38+
if(componentName == null) {
39+
componentName = "ext";
40+
Map<String, String> otelAutoconfigureProperties
41+
= CoreUtils.getProperties("azure-monitor-opentelemetry-autoconfigure.properties");
42+
componentVersion = otelAutoconfigureProperties.get("version");
43+
}
2744

2845
sdkVersionString = getPrefix() + "java" + getJavaVersion() + getJavaRuntime() + ":" + "otel"
29-
+ getOpenTelemetryApiVersion() + ":" + "ext" + artifactVersion;
46+
+ getOpenTelemetryApiVersion() + ":" + componentName + componentVersion;
3047
}
3148

3249
private static String getPrefix() {
@@ -56,24 +73,6 @@ private static String getOs() {
5673
return "u";
5774
}
5875

59-
/**
60-
* This method returns artifact name.
61-
*
62-
* @return artifactName.
63-
*/
64-
public static String getArtifactName() {
65-
return artifactName;
66-
}
67-
68-
/**
69-
* This method returns artifact version.
70-
*
71-
* @return artifactVersion.
72-
*/
73-
public static String getArtifactVersion() {
74-
return artifactVersion;
75-
}
76-
7776
/**
7877
* This method returns sdk version string as per the below format javaX:otelY:extZ X = Java
7978
* version, Y = opentelemetry version, Z = exporter version

sdk/monitor/azure-monitor-opentelemetry-autoconfigure/src/test/java/com/azure/monitor/opentelemetry/autoconfigure/implementation/utils/VersionTest.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,6 @@
99
import static org.junit.jupiter.api.Assertions.assertTrue;
1010

1111
public class VersionTest {
12-
@Test
13-
public void testArtifactName() {
14-
assertThat(VersionGenerator.getArtifactName()).isEqualTo("azure-monitor-opentelemetry-autoconfigure");
15-
}
16-
17-
@Test
18-
public void testArtifactVersion() {
19-
assertTrue(VersionGenerator.getArtifactVersion().matches("[0-9].[0-9].[0-9].*"));
20-
}
21-
2212
@Test
2313
public void testSdkVersion() {
2414
// OpenTelemetry added version.properties files in 1.3.0

0 commit comments

Comments
 (0)