Skip to content
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

Add distro name and version to the SDK name #43737

Merged
merged 5 commits into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,36 @@
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 +72,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
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,9 @@

import org.junit.jupiter.api.Test;

import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertTrue;

public class VersionTest {
@Test
public void testArtifactName() {
jeanbisutti marked this conversation as resolved.
Show resolved Hide resolved
assertThat(VersionGenerator.getArtifactName()).isEqualTo("azure-monitor-opentelemetry-autoconfigure");
}

@Test
public void testArtifactVersion() {
jeanbisutti marked this conversation as resolved.
Show resolved Hide resolved
assertTrue(VersionGenerator.getArtifactVersion().matches("[0-9].[0-9].[0-9].*"));
}

@Test
public void testSdkVersion() {
// OpenTelemetry added version.properties files in 1.3.0
Expand Down
Loading