-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Expand file tree
/
Copy pathSpringBootSmokeTest.java
More file actions
73 lines (62 loc) · 3.14 KB
/
Copy pathSpringBootSmokeTest.java
File metadata and controls
73 lines (62 loc) · 3.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/
package io.opentelemetry.smoketest;
import static io.opentelemetry.api.common.AttributeKey.stringKey;
import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.assertThat;
import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.satisfies;
import static io.opentelemetry.semconv.ServiceAttributes.SERVICE_NAME;
import static io.opentelemetry.semconv.ServiceAttributes.SERVICE_VERSION;
import static io.opentelemetry.semconv.TelemetryAttributes.TELEMETRY_DISTRO_VERSION;
import static io.opentelemetry.semconv.incubating.OsIncubatingAttributes.OS_TYPE;
import static io.opentelemetry.semconv.incubating.ThreadIncubatingAttributes.THREAD_ID;
import static io.opentelemetry.semconv.incubating.ThreadIncubatingAttributes.THREAD_NAME;
import org.junit.jupiter.api.condition.DisabledIf;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
@DisabledIf("io.opentelemetry.smoketest.TestContainerManager#useWindowsContainers")
class SpringBootSmokeTest extends AbstractSmokeTest<Integer> {
@Override
protected void configure(SmokeTestOptions<Integer> options) {
options
.springBoot()
.setServiceName(false)
.env("OTEL_METRICS_EXPORTER", "otlp")
.env("OTEL_RESOURCE_ATTRIBUTES", "foo=bar");
}
@ParameterizedTest
@ValueSource(ints = {8, 11, 17, 21, 25})
void springBootSmokeTest(int jdk) {
SmokeTestOutput output = start(jdk);
var response = client().get("/greeting").aggregate().join();
assertThat(response.contentUtf8()).isEqualTo("Hi!");
testing.waitAndAssertTraces(
trace ->
trace.hasSpansSatisfyingExactly(
span ->
span.hasName("GET /greeting")
.hasAttribute(satisfies(THREAD_ID, val -> val.isNotNull()))
.hasAttribute(satisfies(THREAD_NAME, val -> val.isNotBlank()))
.hasResourceSatisfying(
resource ->
resource
.hasAttribute(TELEMETRY_DISTRO_VERSION, getAgentVersion())
.hasAttribute(satisfies(OS_TYPE, val -> val.isNotNull()))
.hasAttribute(stringKey("foo"), "bar")
.hasAttribute(SERVICE_NAME, "otel-spring-test-app")
.hasAttribute(SERVICE_VERSION, "1.2.3")),
span -> span.hasName("WebController.withSpan")));
// Check agent version is logged on startup
output.assertAgentVersionLogged();
// Check trace IDs are logged via MDC instrumentation
assertThat(output.getLoggedTraceIds()).isEqualTo(getSpanTraceIds());
// Check JVM metrics are exported
testing.waitAndAssertMetrics(
"io.opentelemetry.runtime-telemetry-java8",
metric -> metric.hasName("jvm.memory.used"),
metric -> metric.hasName("jvm.memory.committed"),
metric -> metric.hasName("jvm.memory.limit"),
metric -> metric.hasName("jvm.memory.used_after_last_gc"));
}
}