Skip to content

Commit b808538

Browse files
committed
pr review
1 parent 48a4105 commit b808538

File tree

3 files changed

+27
-5
lines changed

3 files changed

+27
-5
lines changed

smoke-tests/src/test/groovy/io/opentelemetry/smoketest/DeclarativeConfigurationSmokeTest.groovy

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,20 @@ class DeclarativeConfigurationSmokeTest extends SmokeTest {
5050
then: "There is one trace"
5151
traces.size() > 0
5252

53+
then: "explicitly set attribute is present"
54+
hasResourceAttribute(traces, "service.name", "declarative-config-smoke-test")
55+
56+
then: "explicitly set container detector is used"
57+
findResourceAttribute(traces, "container.id").findAny().isPresent()
58+
59+
then: "explicitly set container process detector is used"
60+
findResourceAttribute(traces, "process.executable.path").findAny().isPresent()
61+
62+
then: "explicitly set container host detector is used"
63+
findResourceAttribute(traces, "host.name").findAny().isPresent()
64+
5365
then: "distro detector is added by customizer"
54-
def distroName = findResourceAttribute(traces, "telemetry.distro.name")
55-
.map { it.stringValue }
56-
.findAny()
57-
distroName.isPresent()
58-
distroName.get() == "opentelemetry-javaagent"
66+
hasResourceAttribute(traces, "telemetry.distro.name", "opentelemetry-javaagent")
5967

6068
cleanup:
6169
stopTarget()

smoke-tests/src/test/groovy/io/opentelemetry/smoketest/SmokeTest.groovy

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,15 @@ abstract class SmokeTest extends Specification {
118118
.map { it.value }
119119
}
120120

121+
protected static boolean hasResourceAttribute(Collection<ExportTraceServiceRequest> traces,
122+
String attributeKey,
123+
String attributeValue) {
124+
return findResourceAttribute(traces, attributeKey)
125+
.filter { it.stringValue == attributeValue }
126+
.findAny()
127+
.isPresent()
128+
}
129+
121130
protected static int countSpansByName(Collection<ExportTraceServiceRequest> traces, String spanName) {
122131
return getSpanStream(traces).filter { it.name == spanName }.count()
123132
}

smoke-tests/src/test/resources/declarative-config.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ tracer_provider:
1111

1212
# add extra resource attributes to verify that declarative config is picked up
1313
resource:
14+
detection/development:
15+
detectors:
16+
- container:
17+
- host:
18+
- process:
1419
attributes:
1520
- name: service.name
1621
value: declarative-config-smoke-test

0 commit comments

Comments
 (0)