Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

### Fixes

- Update `SentryTraced` so that it now honors `options.setIgnoredSpanOrigins` ([#6058](https://github.com/getsentry/sentry-java/pull/6058))
- `SentryTraced` now checks for its owning transaction dynamically rather than once per app process. The latter caused `SentryTraced` spans to be dropped process-wide once the original transaction finished ([#6057](https://github.com/getsentry/sentry-java/pull/6057))
- Fix typos in Spring GraphQL integration names (`GrahQL` to `GraphQL`) ([#6061](https://github.com/getsentry/sentry-java/pull/6061))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,15 @@ private fun recordCompositionSpan(
) {
val bucketSpan = BucketSpans.getOrCreateCompositionSpan(ownerSpan, startTimestamp) ?: return

bucketSpan.startChild(OP_COMPOSITION_SPAN, tag, startTimestamp).apply {
spanContext.origin = OP_TRACE_ORIGIN
finish(null, endTimestamp)
}
bucketSpan
.startChild(
OP_COMPOSITION_SPAN,
tag,
startTimestamp,
Instrumenter.SENTRY,
Comment thread
0xadam-brown marked this conversation as resolved.
SpanOptions().apply { origin = OP_TRACE_ORIGIN },
)
.run { finish(null, endTimestamp) }
}

/**
Expand All @@ -145,10 +150,15 @@ private fun recordRenderSpan(
) {
val bucketSpan = BucketSpans.getOrCreateRenderSpan(ownerSpan, startTimestamp) ?: return

bucketSpan.startChild(OP_RENDER_SPAN, tag, startTimestamp).apply {
spanContext.origin = OP_TRACE_ORIGIN
finish(null, endTimestamp)
}
bucketSpan
.startChild(
OP_RENDER_SPAN,
tag,
startTimestamp,
Instrumenter.SENTRY,
SpanOptions().apply { origin = OP_TRACE_ORIGIN },
)
.run { finish(null, endTimestamp) }
}

/**
Expand Down Expand Up @@ -237,6 +247,7 @@ private class BucketSpans {
startTimestamp,
Instrumenter.SENTRY,
SpanOptions().apply {
origin = OP_TRACE_ORIGIN
isTrimStart = true
isTrimEnd = true
isIdle = true
Expand All @@ -246,8 +257,6 @@ private class BucketSpans {
if (bucketSpan.dropsChildSpans) {
return null
}

bucketSpan.spanContext.origin = OP_TRACE_ORIGIN
setCached(WeakReference(bucketSpan))
return bucketSpan
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,26 @@ class SentryTracedTest {
assertThat(tx.countSpans(OP_RENDER)).isEqualTo(0)
}

@Test
fun `does not create spans when origin is ignored`() {
val tx =
initSentryAndStartTransaction("tx") { options ->
options.setIgnoredSpanOrigins(listOf(OP_TRACE_ORIGIN))
}

rule.setContent {
SentryTraced(tag = "product_info") { Box(Modifier.size(1.dp).testTag("content")) }
}
rule.waitForIdle()
drawContent()

rule.onNodeWithTag("content").assertExists()
assertThat(tx.countSpans(OP_PARENT_COMPOSITION)).isEqualTo(0)
assertThat(tx.countSpans(OP_COMPOSE)).isEqualTo(0)
assertThat(tx.countSpans(OP_PARENT_RENDER)).isEqualTo(0)
assertThat(tx.countSpans(OP_RENDER)).isEqualTo(0)
}

@Test
fun `sibling traced composables with the same owner share the composition parent`() {
val tx = initSentryAndStartTransaction("tx")
Expand Down Expand Up @@ -381,13 +401,17 @@ class SentryTracedTest {
assertThat(renderingTx.countSpans(OP_RENDER)).isEqualTo(0)
}

private fun initSentryAndStartTransaction(name: String): ITransaction {
private fun initSentryAndStartTransaction(
name: String,
configureOptions: (SentryOptions) -> Unit = {},
): ITransaction {
lateinit var tx: ITransaction
rule.runOnUiThread {
Sentry.init(
{ options: SentryOptions ->
options.dsn = "https://key@sentry.io/proj"
options.tracesSampleRate = 1.0
configureOptions(options)
},
true,
)
Expand Down
Loading