|
12 | 12 | import io.opentelemetry.api.common.AttributeKey; |
13 | 13 | import io.opentelemetry.api.common.Attributes; |
14 | 14 | import io.opentelemetry.api.trace.SpanKind; |
| 15 | +import io.opentelemetry.instrumentation.api.internal.SemconvStability; |
15 | 16 | import io.opentelemetry.instrumentation.spring.autoconfigure.internal.properties.OtelResourceProperties; |
16 | 17 | import io.opentelemetry.instrumentation.spring.autoconfigure.internal.properties.OtelSpringProperties; |
17 | 18 | import io.opentelemetry.instrumentation.spring.autoconfigure.internal.properties.OtlpExporterProperties; |
|
26 | 27 | import io.opentelemetry.semconv.HttpAttributes; |
27 | 28 | import io.opentelemetry.semconv.ServerAttributes; |
28 | 29 | import io.opentelemetry.semconv.UrlAttributes; |
| 30 | +import io.opentelemetry.semconv.incubating.CodeIncubatingAttributes; |
29 | 31 | import io.opentelemetry.semconv.incubating.DbIncubatingAttributes; |
30 | 32 | import io.opentelemetry.semconv.incubating.ServiceIncubatingAttributes; |
31 | 33 | import java.net.URI; |
|
35 | 37 | import java.util.List; |
36 | 38 | import org.assertj.core.api.AbstractCharSequenceAssert; |
37 | 39 | import org.assertj.core.api.AbstractIterableAssert; |
| 40 | +import org.assertj.core.api.MapAssert; |
38 | 41 | import org.junit.jupiter.api.MethodOrderer; |
39 | 42 | import org.junit.jupiter.api.Test; |
40 | 43 | import org.junit.jupiter.api.TestMethodOrder; |
@@ -147,6 +150,7 @@ void propertyConversion() { |
147 | 150 |
|
148 | 151 | @Test |
149 | 152 | @org.junit.jupiter.api.Order(1) |
| 153 | + @SuppressWarnings("deprecation") // testing deprecated code semconv |
150 | 154 | void shouldSendTelemetry() { |
151 | 155 | HttpHeaders headers = new HttpHeaders(); |
152 | 156 | headers.add("key", "value"); |
@@ -246,11 +250,22 @@ void shouldSendTelemetry() { |
246 | 250 | .as("Should instrument logs") |
247 | 251 | .startsWith("Starting ") |
248 | 252 | .contains(this.getClass().getSimpleName()); |
249 | | - assertThat(firstLog.getAttributes().asMap()) |
250 | | - .as("Should capture code attributes") |
251 | | - .containsEntry( |
252 | | - CodeAttributes.CODE_FUNCTION_NAME, |
253 | | - "org.springframework.boot.StartupInfoLogger.logStarting"); |
| 253 | + |
| 254 | + MapAssert<AttributeKey<?>, Object> attributesAssert = |
| 255 | + assertThat(firstLog.getAttributes().asMap()).as("Should capture code attributes"); |
| 256 | + |
| 257 | + if (SemconvStability.emitStableDatabaseSemconv()) { |
| 258 | + attributesAssert.containsEntry( |
| 259 | + CodeAttributes.CODE_FUNCTION_NAME, |
| 260 | + "org.springframework.boot.StartupInfoLogger.logStarting"); |
| 261 | + } |
| 262 | + if (SemconvStability.isEmitOldCodeSemconv()) { |
| 263 | + attributesAssert |
| 264 | + .containsEntry( |
| 265 | + CodeIncubatingAttributes.CODE_NAMESPACE, |
| 266 | + "org.springframework.boot.StartupInfoLogger") |
| 267 | + .containsEntry(CodeIncubatingAttributes.CODE_FUNCTION, "logStarting"); |
| 268 | + } |
254 | 269 | } |
255 | 270 | } |
256 | 271 |
|
|
0 commit comments