Skip to content

Commit bde13a9

Browse files
committed
Add test for contexts
1 parent 6cd522a commit bde13a9

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

sentry/src/test/java/io/sentry/SentryTracerTest.kt

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,31 @@ class SentryTracerTest {
207207
)
208208
}
209209

210+
@Test
211+
fun `when transaction is finished, context is set`() {
212+
val tracer = fixture.getSut()
213+
val otelContext = mapOf(
214+
"attributes" to mapOf(
215+
"db.connection_string" to "hsqldb:mem:",
216+
"db.statement" to "CREATE TABLE person ( id INTEGER IDENTITY PRIMARY KEY, firstName VARCHAR(?) NOT NULL, lastName VARCHAR(?) NOT NULL )"
217+
),
218+
"resource" to mapOf(
219+
"process.runtime.version" to "17.0.4.1+1",
220+
"telemetry.auto.version" to "sentry-6.7.0-otel-1.19.2"
221+
)
222+
)
223+
tracer.setContext("otel", otelContext)
224+
tracer.finish()
225+
226+
verify(fixture.hub).captureTransaction(
227+
check {
228+
assertEquals(otelContext, it.contexts["otel"])
229+
},
230+
anyOrNull<TraceContext>(),
231+
anyOrNull()
232+
)
233+
}
234+
210235
@Test
211236
fun `returns sentry-trace header`() {
212237
val tracer = fixture.getSut()

0 commit comments

Comments
 (0)