Skip to content

Commit

Permalink
[ATO-2697] Stringify None attribute values to fix opentelemetry warni…
Browse files Browse the repository at this point in the history
…ng (#1135)

* stringify None values

* add changelog entry
  • Loading branch information
ancalita authored Aug 19, 2024
1 parent a4bac8e commit 8733d14
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions changelog/1135.misc.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Stringify `None` values for `message_id` and `sender_id` tracing tags to fix the
`opentelemetry` warning about invalid type `NoneType` for these tags.
2 changes: 1 addition & 1 deletion rasa_sdk/tracing/instrumentation/attribute_extractors.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def extract_attrs_for_action_executor(
:param action_call: The `ActionCall` argument.
:return: A dictionary containing the attributes.
"""
attributes = {"sender_id": action_call["sender_id"]}
attributes = {"sender_id": action_call.get("sender_id", "None")}
action_name = action_call.get("next_action")

if action_name:
Expand Down
2 changes: 1 addition & 1 deletion rasa_sdk/tracing/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def set_span_attributes(span: Any, action_call: dict) -> None:
"next_action": action_call.get("next_action"),
"version": action_call.get("version"),
"sender_id": tracker.get("sender_id"),
"message_id": tracker.get("latest_message", {}).get("message_id"),
"message_id": tracker.get("latest_message", {}).get("message_id", "None"),
}

if span.is_recording():
Expand Down

0 comments on commit 8733d14

Please sign in to comment.