Skip to content

Commit

Permalink
rename telemetry.auto.version to telemetry.distro.version and add tel…
Browse files Browse the repository at this point in the history
…emetry.distro.name (#9065)

Co-authored-by: Lauri Tulmin <tulmin@gmail.com>
  • Loading branch information
zeitlinger and laurit committed Dec 13, 2023
1 parent bede684 commit 1a054a5
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public void springBootSmokeTestOnJDK() throws IOException, InterruptedException
Assertions.assertEquals(1, countSpansByName(traces, "WebController.withSpan"));
Assertions.assertEquals(2, countSpansByAttributeValue(traces, "custom", "demo"));
Assertions.assertNotEquals(
0, countResourcesByValue(traces, "telemetry.auto.version", currentAgentVersion));
0, countResourcesByValue(traces, "telemetry.distro.version", currentAgentVersion));
Assertions.assertNotEquals(0, countResourcesByValue(traces, "custom.resource", "demo"));

stopTarget();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ private void testAndVerify() throws IOException, InterruptedException {
Assertions.assertEquals(1, countSpansByName(traces, "WebController.withSpan"));
Assertions.assertEquals(2, countSpansByAttributeValue(traces, "custom", "demo"));
Assertions.assertNotEquals(
0, countResourcesByValue(traces, "telemetry.auto.version", currentAgentVersion));
0, countResourcesByValue(traces, "telemetry.distro.version", currentAgentVersion));
Assertions.assertNotEquals(0, countResourcesByValue(traces, "custom.resource", "demo"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,22 @@
import io.opentelemetry.sdk.resources.Resource;

@AutoService(ResourceProvider.class)
public class AutoVersionResourceProvider implements ResourceProvider {
public class DistroVersionResourceProvider implements ResourceProvider {

private static final AttributeKey<String> TELEMETRY_AUTO_VERSION =
AttributeKey.stringKey("telemetry.auto.version");
private static final AttributeKey<String> TELEMETRY_DISTRO_NAME =
AttributeKey.stringKey("telemetry.distro.name");
private static final AttributeKey<String> TELEMETRY_DISTRO_VERSION =
AttributeKey.stringKey("telemetry.distro.version");

@Override
public Resource createResource(ConfigProperties config) {
return AgentVersion.VERSION == null
? Resource.empty()
: Resource.create(Attributes.of(TELEMETRY_AUTO_VERSION, AgentVersion.VERSION));
: Resource.create(
Attributes.of(
TELEMETRY_DISTRO_NAME,
"opentelemetry-java-instrumentation",
TELEMETRY_DISTRO_VERSION,
AgentVersion.VERSION));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
package io.opentelemetry.smoketest

import io.opentelemetry.proto.trace.v1.Span
import io.opentelemetry.semconv.ResourceAttributes
import io.opentelemetry.semconv.SemanticAttributes
import spock.lang.Shared
import spock.lang.Unroll
Expand All @@ -28,6 +27,8 @@ abstract class AppServerTest extends SmokeTest {
@Shared
boolean isWindows

private static final String TELEMETRY_DISTRO_VERSION = "telemetry.distro.version"

def setupSpec() {
(serverVersion, jdk) = getAppServer()
isWindows = System.getProperty("os.name").toLowerCase().contains("windows") &&
Expand Down Expand Up @@ -126,7 +127,7 @@ abstract class AppServerTest extends SmokeTest {
traces.countFilteredAttributes(SemanticAttributes.NETWORK_PROTOCOL_VERSION.key, "1.1") == 3

and: "Number of spans tagged with current otel library version"
traces.countFilteredResourceAttributes(ResourceAttributes.TELEMETRY_AUTO_VERSION.key, currentAgentVersion) == 3
traces.countFilteredResourceAttributes(TELEMETRY_DISTRO_VERSION, currentAgentVersion) == 3

and: "Number of spans tagged with expected OS type"
traces.countFilteredResourceAttributes(OS_TYPE.key, isWindows ? WINDOWS : LINUX) == 3
Expand Down Expand Up @@ -161,7 +162,7 @@ abstract class AppServerTest extends SmokeTest {
traces.countFilteredAttributes(SemanticAttributes.URL_PATH.key, "/app/hello.txt") == 1

and: "Number of spans tagged with current otel library version"
traces.countFilteredResourceAttributes(ResourceAttributes.TELEMETRY_AUTO_VERSION.key, currentAgentVersion) == 1
traces.countFilteredResourceAttributes(TELEMETRY_DISTRO_VERSION, currentAgentVersion) == 1

and: "Number of spans tagged with expected OS type"
traces.countFilteredResourceAttributes(OS_TYPE.key, isWindows ? WINDOWS : LINUX) == 1
Expand Down Expand Up @@ -195,7 +196,7 @@ abstract class AppServerTest extends SmokeTest {
traces.countFilteredAttributes(SemanticAttributes.URL_PATH.key, "/app/file-that-does-not-exist") == 1

and: "Number of spans tagged with current otel library version"
traces.countFilteredResourceAttributes(ResourceAttributes.TELEMETRY_AUTO_VERSION.key, currentAgentVersion) == traces.countSpans()
traces.countFilteredResourceAttributes(TELEMETRY_DISTRO_VERSION, currentAgentVersion) == traces.countSpans()

and: "Number of spans tagged with expected OS type"
traces.countFilteredResourceAttributes(OS_TYPE.key, isWindows ? WINDOWS : LINUX) == traces.countSpans()
Expand Down Expand Up @@ -234,7 +235,7 @@ abstract class AppServerTest extends SmokeTest {
traces.countFilteredAttributes(SemanticAttributes.NETWORK_PROTOCOL_VERSION.key, "1.1") == 1

and: "Number of spans tagged with current otel library version"
traces.countFilteredResourceAttributes(ResourceAttributes.TELEMETRY_AUTO_VERSION.key, currentAgentVersion) == traces.countSpans()
traces.countFilteredResourceAttributes(TELEMETRY_DISTRO_VERSION, currentAgentVersion) == traces.countSpans()

and: "Number of spans tagged with expected OS type"
traces.countFilteredResourceAttributes(OS_TYPE.key, isWindows ? WINDOWS : LINUX) == traces.countSpans()
Expand Down Expand Up @@ -273,7 +274,7 @@ abstract class AppServerTest extends SmokeTest {
traces.countFilteredAttributes(SemanticAttributes.URL_PATH.key, "/app/exception") == 1

and: "Number of spans tagged with current otel library version"
traces.countFilteredResourceAttributes(ResourceAttributes.TELEMETRY_AUTO_VERSION.key, currentAgentVersion) == traces.countSpans()
traces.countFilteredResourceAttributes(TELEMETRY_DISTRO_VERSION, currentAgentVersion) == traces.countSpans()

and: "Number of spans tagged with expected OS type"
traces.countFilteredResourceAttributes(OS_TYPE.key, isWindows ? WINDOWS : LINUX) == traces.countSpans()
Expand Down Expand Up @@ -311,7 +312,7 @@ abstract class AppServerTest extends SmokeTest {
traces.countFilteredAttributes(SemanticAttributes.NETWORK_PROTOCOL_VERSION.key, "1.1") == 1

and: "Number of spans tagged with current otel library version"
traces.countFilteredResourceAttributes(ResourceAttributes.TELEMETRY_AUTO_VERSION.key, currentAgentVersion) == traces.countSpans()
traces.countFilteredResourceAttributes(TELEMETRY_DISTRO_VERSION, currentAgentVersion) == traces.countSpans()

and: "Number of spans tagged with expected OS type"
traces.countFilteredResourceAttributes(OS_TYPE.key, isWindows ? WINDOWS : LINUX) == traces.countSpans()
Expand Down Expand Up @@ -358,7 +359,7 @@ abstract class AppServerTest extends SmokeTest {
traces.countFilteredAttributes(SemanticAttributes.NETWORK_PROTOCOL_VERSION.key, "1.1") == 3

and: "Number of spans tagged with current otel library version"
traces.countFilteredResourceAttributes(ResourceAttributes.TELEMETRY_AUTO_VERSION.key, currentAgentVersion) == 3
traces.countFilteredResourceAttributes(TELEMETRY_DISTRO_VERSION, currentAgentVersion) == 3

and: "Number of spans tagged with expected OS type"
traces.countFilteredResourceAttributes(OS_TYPE.key, isWindows ? WINDOWS : LINUX) == 3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class GrpcSmokeTest extends SmokeTest {
countSpansByName(traces, 'opentelemetry.proto.collector.trace.v1.TraceService/Export') == 1
countSpansByName(traces, 'TestService.withSpan') == 1

[currentAgentVersion] as Set == findResourceAttribute(traces, "telemetry.auto.version")
[currentAgentVersion] as Set == findResourceAttribute(traces, "telemetry.distro.version")
.map { it.stringValue }
.collect(toSet())

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class QuarkusSmokeTest extends SmokeTest {
countSpansByName(traces, 'GET /hello') == 1
countSpansByName(traces, 'HelloResource.hello') == 1

[currentAgentVersion] as Set == findResourceAttribute(traces, "telemetry.auto.version")
[currentAgentVersion] as Set == findResourceAttribute(traces, "telemetry.distro.version")
.map { it.stringValue }
.collect(toSet())

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class SpringBootSmokeTest extends SmokeTest {
.allMatch { it.attributesList.stream().map { it.key }.collect(toSet()).containsAll(["thread.id", "thread.name"]) }

then: "correct agent version is captured in the resource"
[currentAgentVersion] as Set == findResourceAttribute(traces, "telemetry.auto.version")
[currentAgentVersion] as Set == findResourceAttribute(traces, "telemetry.distro.version")
.map { it.stringValue }
.collect(toSet())

Expand Down

0 comments on commit 1a054a5

Please sign in to comment.