Skip to content

Commit

Permalink
Add distro name and version to the SDK name
Browse files Browse the repository at this point in the history
  • Loading branch information
jeanbisutti committed Jan 8, 2025
1 parent 32092fb commit 9c3e9a3
Showing 1 changed file with 25 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,37 @@
public final class VersionGenerator {
private static final String UNKNOWN_VERSION_VALUE = "unknown";

private static final String artifactName;
private static final String artifactVersion;

private static final String sdkVersionString;

static {
Map<String, String> properties
= CoreUtils.getProperties("azure-monitor-opentelemetry-autoconfigure.properties");
String componentName = null;
String componentVersion = null;

Map<String, String> springDistroProperties
= CoreUtils.getProperties("azure-spring-cloud-azure-starter-monitor.properties");
String springDistroVersion = springDistroProperties.get("version");
if(springDistroVersion != null) {
componentName = "dss";
componentVersion = springDistroVersion;
}

Map<String, String> quarkusProperties
= CoreUtils.getProperties("quarkus-exporter.properties");
String quarkusVersion = quarkusProperties.get("version");
if(quarkusVersion != null) {
componentName = "dsq";
componentVersion = quarkusVersion;
}

artifactName = properties.get("name");
artifactVersion = properties.get("version");
if(componentName == null) {
componentName = "ext";
Map<String, String> otelAutoconfigureProperties
= CoreUtils.getProperties("azure-monitor-opentelemetry-autoconfigure.properties");
componentVersion = otelAutoconfigureProperties.get("version");
}

sdkVersionString = getPrefix() + "java" + getJavaVersion() + getJavaRuntime() + ":" + "otel"
+ getOpenTelemetryApiVersion() + ":" + "ext" + artifactVersion;
+ getOpenTelemetryApiVersion() + ":" + componentName + componentVersion;
}

private static String getPrefix() {
Expand Down Expand Up @@ -56,24 +73,6 @@ private static String getOs() {
return "u";
}

/**
* This method returns artifact name.
*
* @return artifactName.
*/
public static String getArtifactName() {
return artifactName;
}

/**
* This method returns artifact version.
*
* @return artifactVersion.
*/
public static String getArtifactVersion() {
return artifactVersion;
}

/**
* This method returns sdk version string as per the below format javaX:otelY:extZ X = Java
* version, Y = opentelemetry version, Z = exporter version
Expand Down

0 comments on commit 9c3e9a3

Please sign in to comment.