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

[ATO-2697] Stringify None attribute values to fix opentelemetry warning #1135

Merged
merged 2 commits into from
Aug 19, 2024
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
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
Loading