Skip to content

Commit 070ee32

Browse files
adinauerclaude
andcommitted
fix(test): Add back test for inject with invalid span
The previous commit replaced the invalid-span inject test with a no-span-in-context test. These are distinct scenarios: an explicitly invalid span vs no span at all. Restore the invalid span test and keep both. Co-Authored-By: Claude <noreply@anthropic.com>
1 parent f029100 commit 070ee32

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

sentry-opentelemetry/sentry-opentelemetry-otlp/src/test/kotlin/OtelSentryPropagatorTest.kt

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ class OpenTelemetryOtlpPropagatorTest {
172172
}
173173

174174
@Test
175-
fun `does not inject headers if span is invalid`() {
175+
fun `does not inject headers when no span in context`() {
176176
val propagator = OpenTelemetryOtlpPropagator()
177177
val carrier = mutableMapOf<String, String>()
178178

@@ -182,6 +182,17 @@ class OpenTelemetryOtlpPropagatorTest {
182182
assertNull(carrier["baggage"])
183183
}
184184

185+
@Test
186+
fun `does not inject headers when span is invalid`() {
187+
val propagator = OpenTelemetryOtlpPropagator()
188+
val carrier = mutableMapOf<String, String>()
189+
190+
propagator.inject(Context.root().with(Span.getInvalid()), carrier, MapSetter())
191+
192+
assertNull(carrier["sentry-trace"])
193+
assertNull(carrier["baggage"])
194+
}
195+
185196
@Test
186197
fun `does not inject baggage header when baggage is missing from context`() {
187198
val propagator = OpenTelemetryOtlpPropagator()

0 commit comments

Comments
 (0)