From 9c3e9a36a252b0382d4efdc92a99b77dc98bea23 Mon Sep 17 00:00:00 2001 From: Jean Bisutti Date: Wed, 8 Jan 2025 17:33:43 +0100 Subject: [PATCH] Add distro name and version to the SDK name --- .../utils/VersionGenerator.java | 51 +++++++++---------- 1 file changed, 25 insertions(+), 26 deletions(-) diff --git a/sdk/monitor/azure-monitor-opentelemetry-autoconfigure/src/main/java/com/azure/monitor/opentelemetry/autoconfigure/implementation/utils/VersionGenerator.java b/sdk/monitor/azure-monitor-opentelemetry-autoconfigure/src/main/java/com/azure/monitor/opentelemetry/autoconfigure/implementation/utils/VersionGenerator.java index ab4fe81ff2aca..4f35b3ec48149 100644 --- a/sdk/monitor/azure-monitor-opentelemetry-autoconfigure/src/main/java/com/azure/monitor/opentelemetry/autoconfigure/implementation/utils/VersionGenerator.java +++ b/sdk/monitor/azure-monitor-opentelemetry-autoconfigure/src/main/java/com/azure/monitor/opentelemetry/autoconfigure/implementation/utils/VersionGenerator.java @@ -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 properties - = CoreUtils.getProperties("azure-monitor-opentelemetry-autoconfigure.properties"); + String componentName = null; + String componentVersion = null; + + Map springDistroProperties + = CoreUtils.getProperties("azure-spring-cloud-azure-starter-monitor.properties"); + String springDistroVersion = springDistroProperties.get("version"); + if(springDistroVersion != null) { + componentName = "dss"; + componentVersion = springDistroVersion; + } + + Map 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 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() { @@ -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