Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(kafka): cast topic to str since it can return None #10691

Merged
merged 9 commits into from
Sep 20, 2024
4 changes: 2 additions & 2 deletions ddtrace/contrib/internal/kafka/patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ def _instrument_message(messages, pin, start_ns, instance, err):

for message in messages:
if message is not None and first_message is not None:
core.set_item("kafka_topic", first_message.topic())
core.set_item("kafka_topic", str(first_message.topic()))
core.dispatch("kafka.consume.start", (instance, first_message, span))

span.set_tag_str(MESSAGING_SYSTEM, kafkax.SERVICE)
Expand All @@ -260,7 +260,7 @@ def _instrument_message(messages, pin, start_ns, instance, err):
if first_message is not None:
message_key = first_message.key() or ""
message_offset = first_message.offset() or -1
span.set_tag_str(kafkax.TOPIC, first_message.topic())
span.set_tag_str(kafkax.TOPIC, str(first_message.topic()))

# If this is a deserializing consumer, do not set the key as a tag since we
# do not have the serialization function
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
fixes:
- |
kafka: Fixed an issue where a ``TypeError`` exception would be raised if the first message's ``topic()`` returned ``None`` during consumption.
Loading