From b0768f8149ae2dea9b4d7d6d409c3c825bacd44b Mon Sep 17 00:00:00 2001 From: Anca Lita <27920906+ancalita@users.noreply.github.com> Date: Mon, 19 Aug 2024 13:51:00 +0100 Subject: [PATCH 1/2] stringify None values --- rasa_sdk/tracing/instrumentation/attribute_extractors.py | 2 +- rasa_sdk/tracing/utils.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/rasa_sdk/tracing/instrumentation/attribute_extractors.py b/rasa_sdk/tracing/instrumentation/attribute_extractors.py index ff389438c..40fd0051f 100644 --- a/rasa_sdk/tracing/instrumentation/attribute_extractors.py +++ b/rasa_sdk/tracing/instrumentation/attribute_extractors.py @@ -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: diff --git a/rasa_sdk/tracing/utils.py b/rasa_sdk/tracing/utils.py index 719b9f1ac..55b89dbfd 100644 --- a/rasa_sdk/tracing/utils.py +++ b/rasa_sdk/tracing/utils.py @@ -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(): From c0c4c57f9741d519306113262ba5fa7a5516ffb4 Mon Sep 17 00:00:00 2001 From: Anca Lita <27920906+ancalita@users.noreply.github.com> Date: Mon, 19 Aug 2024 13:59:57 +0100 Subject: [PATCH 2/2] add changelog entry --- changelog/1135.misc.md | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 changelog/1135.misc.md diff --git a/changelog/1135.misc.md b/changelog/1135.misc.md new file mode 100644 index 000000000..e4d7f9009 --- /dev/null +++ b/changelog/1135.misc.md @@ -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.