Skip to content

Commit 26f4229

Browse files
adinauerclaude
andcommitted
fix(otel): Map messaging "create" to queue.create instead of queue.publish
The OTel messaging semconv defines "create" and "publish" as distinct operations: "create" represents message construction, "publish" the network send. Folding both into queue.publish risks double-counting producer transactions on instrumentations that emit a separate create span (per OTel semconv guidance). Per the Sentry Queues telemetry spec (https://develop.sentry.dev/sdk/telemetry/traces/modules/queues/), queue.create is a canonical op distinct from queue.publish, so map "create" to its spec-correct destination rather than dropping it. Empirically, current Kafka OTel instrumentation does not emit a separate create span, so this is a no-op for Kafka users today; the change future-proofs other systems and any future Kafka OTel version. Co-Authored-By: Claude <noreply@anthropic.com>
1 parent f85b2d7 commit 26f4229

2 files changed

Lines changed: 19 additions & 1 deletion

File tree

sentry-opentelemetry/sentry-opentelemetry-core/src/main/java/io/sentry/opentelemetry/SpanDescriptionExtractor.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,9 @@ private OtelSpanInfo descriptionForMessagingSystem(final @NotNull SpanData otelS
128128
switch (operationType) {
129129
case "publish":
130130
case "send":
131-
case "create":
132131
return "queue.publish";
132+
case "create":
133+
return "queue.create";
133134
case "receive":
134135
return "queue.receive";
135136
case "process":

sentry-opentelemetry/sentry-opentelemetry-core/src/test/kotlin/SpanDescriptionExtractorTest.kt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,23 @@ class SpanDescriptionExtractorTest {
282282
assertEquals(TransactionNameSource.TASK, info.transactionNameSource)
283283
}
284284

285+
@Test
286+
fun `maps messaging create operation type to queue create op`() {
287+
givenAttributes(
288+
mapOf(
289+
MessagingIncubatingAttributes.MESSAGING_SYSTEM to "kafka",
290+
MessagingIncubatingAttributes.MESSAGING_DESTINATION_NAME to "my-topic",
291+
MessagingIncubatingAttributes.MESSAGING_OPERATION_TYPE to "create",
292+
)
293+
)
294+
295+
val info = whenExtractingSpanInfo(queueTracingEnabled = true)
296+
297+
assertEquals("queue.create", info.op)
298+
assertEquals("my-topic", info.description)
299+
assertEquals(TransactionNameSource.TASK, info.transactionNameSource)
300+
}
301+
285302
@Test
286303
fun `maps messaging receive operation type to queue receive op`() {
287304
givenAttributes(

0 commit comments

Comments
 (0)