Repository navigation
Conversation
Lancetnik
left a comment
There was a problem hiding this comment.
Please preserve the legacy topic key on same-topic batch spans when the SDK runs out of attribute slots.
One scope question: the Kafka backend rule calls for mirroring these fixes. Confluent still only reports the legacy key for single records and batches. Can we mirror the fix here, or explicitly keep this PR aiokafka-only?
| MESSAGING_DESTINATION_PUBLISH_NAME: raw_message.topic, | ||
| } | ||
|
|
||
| if all(record.topic == raw_message.topic for record in msg.raw_message): |
There was a problem hiding this comment.
Please add the canonical key before the legacy key, as the single-record provider does. With two orders records from different partitions and SpanLimits(max_span_attributes=2), the base exports messaging.destination_publish.name=orders and messaging.operation=process. This revision exports the canonical key and the operation instead. The SDK drops the older legacy attribute, so existing queries can miss the span.
I reproduced this with OpenTelemetry SDK 1.44.0 and verified that reordering preserves the legacy key under the same limit and exports both keys when there is room. Please pin the two-slot case on the exported process span.
There was a problem hiding this comment.
I moved the canonical key ahead of the legacy key in ac2445ce. The regression test checks that the exported process span keeps the legacy topic and operation when the SDK allows only two attributes. With the default limit, both topic keys are present.
| ) | ||
| message = StreamMessage(raw_message=records, body=[b"message", b"message"]) | ||
|
|
||
| attrs = BatchKafkaTelemetrySettingsProvider().get_consume_attrs_from_message( |
There was a problem hiding this comment.
Can we check the exported process span here? The provider test would still pass if the middleware filled in the missing canonical key from the first topic. I tried that change, a first/last-only comparison, and a guard that skips singleton batches separately; all 16 tests passed each time.
With normal attribute limits, [orders:0, payments:1, orders:2] should export no canonical key and keep legacy orders. A singleton batch [orders:0] should export orders under both keys.
There was a problem hiding this comment.
The tests now check exported process spans. [orders, payments, orders] keeps only the legacy topic, and [orders] exports both keys. I tried the three changes you described separately, and each one failed the new tests.
|
I mirrored the fix in Confluent and ran the same batch cases against both backends. Both connected suites passed in CI. CI run |
Summary
Stock aiokafka and Confluent consumer spans currently expose the topic only as
messaging.destination_publish.name. Emitmessaging.destination.namefrom the consumed record and emit it for a batch only when all records share the topic. Retain the legacy attribute for existing telemetry consumers. On batches, insert the canonical attribute before the legacy attribute so the latter survives SDK eviction when a process span has room for only two attributes.OpenTelemetry semantics
The Kafka Process span convention makes
messaging.destination.nameconditionally required for a single message or when the same value applies to all messages in a batch. The value identifies the Kafka topic. OpenTelemetry deprecated themessaging.destination_publish.*namespace.FastStream's batch subscriber flattens records across topic partitions. A batch can contain more than one topic, so using the first record's topic for the canonical attribute could mislabel the whole span.
CONSUMERprocessspanorders, payments, ordersprocessoperationLocal verification
KeyError: 'messaging.destination.name'.AI assistance was used for research, implementation, and test development.