|
| 1 | +/* |
| 2 | + * Copyright The OpenTelemetry Authors |
| 3 | + * SPDX-License-Identifier: Apache-2.0 |
| 4 | + */ |
| 5 | + |
| 6 | +package io.opentelemetry.contrib.inferredspans; |
| 7 | + |
| 8 | +import static org.assertj.core.api.Assertions.assertThat; |
| 9 | + |
| 10 | +import io.opentelemetry.contrib.inferredspans.internal.ProfilingActivationListener; |
| 11 | +import io.opentelemetry.contrib.inferredspans.internal.util.OtelReflectionUtils; |
| 12 | +import io.opentelemetry.sdk.OpenTelemetrySdk; |
| 13 | +import io.opentelemetry.sdk.extension.incubator.fileconfig.DeclarativeConfiguration; |
| 14 | +import java.io.ByteArrayInputStream; |
| 15 | +import java.nio.charset.StandardCharsets; |
| 16 | +import org.junit.jupiter.api.AfterEach; |
| 17 | +import org.junit.jupiter.api.BeforeEach; |
| 18 | +import org.junit.jupiter.api.Test; |
| 19 | + |
| 20 | +class InferredSpansCustomizerProviderTest { |
| 21 | + |
| 22 | + @BeforeEach |
| 23 | + @AfterEach |
| 24 | + public void resetGlobalOtel() { |
| 25 | + ProfilingActivationListener.ensureInitialized(); |
| 26 | + OtelReflectionUtils.shutdownAndResetGlobalOtel(); |
| 27 | + } |
| 28 | + |
| 29 | + @Test |
| 30 | + void declarativeConfig() { |
| 31 | + String yaml = |
| 32 | + "file_format: 0.4\n" |
| 33 | + + "tracer_provider:\n" |
| 34 | + + " processors:\n" |
| 35 | + + " - inferred_spans:\n" |
| 36 | + + " backup:\n" |
| 37 | + + " diagnostic:\n" |
| 38 | + + " files: true\n"; |
| 39 | + |
| 40 | + OpenTelemetrySdk sdk = |
| 41 | + DeclarativeConfiguration.parseAndCreate( |
| 42 | + new ByteArrayInputStream(yaml.getBytes(StandardCharsets.UTF_8))); |
| 43 | + |
| 44 | + assertThat(sdk) |
| 45 | + .extracting("tracerProvider") |
| 46 | + .extracting("delegate") |
| 47 | + .extracting("sharedState") |
| 48 | + .extracting("activeSpanProcessor") |
| 49 | + .extracting("profiler") |
| 50 | + .extracting("config") |
| 51 | + .extracting("backupDiagnosticFiles") |
| 52 | + .isEqualTo(true); |
| 53 | + } |
| 54 | +} |
0 commit comments