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 SDK prefix #43700

Merged
merged 4 commits into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from 3 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 @@ -25,8 +25,34 @@ public final class VersionGenerator {
artifactName = properties.get("name");
artifactVersion = properties.get("version");

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

private static String getPrefix() {
return getResourceProvider() + getOs() + "_";
}

private static String getResourceProvider() {
if ("java".equals(System.getenv("FUNCTIONS_WORKER_RUNTIME"))) {
return "f";
} else if (!Strings.isNullOrEmpty(System.getenv("WEBSITE_SITE_NAME"))) {
return "a";
} else if (!Strings.isNullOrEmpty(System.getenv("APPLICATIONINSIGHTS_SPRINGCLOUD_SERVICE_ID"))) {
return "s";
jeanbisutti marked this conversation as resolved.
Show resolved Hide resolved
} else if (!Strings.isNullOrEmpty(System.getenv("AKS_ARM_NAMESPACE_ID"))) {
return "k";
}
return "u";
jeanbisutti marked this conversation as resolved.
Show resolved Hide resolved
}

private static String getOs() {
if (SystemInformation.isWindows()) {
return "w";
} else if (SystemInformation.isLinux()) {
return "l";
}
return "u";
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ public void testArtifactVersion() {
public void testSdkVersion() {
// OpenTelemetry added version.properties files in 1.3.0
// but testing against OpenTelemetry 1.0.0, so it's unknown in this test
assertTrue(VersionGenerator.getSdkVersion().matches("java[0-9._]+:otel([0-9.]+|unknown):ext[0-9.]+.*"));
assertTrue(VersionGenerator.getSdkVersion().matches(".._java[0-9._]+:otel([0-9.]+|unknown):ext[0-9.]+.*"));
}
}
Loading