From 3eb0dcd92ded08493de07062396d354cf8c3e705 Mon Sep 17 00:00:00 2001 From: Obinna Okafor Date: Mon, 2 Dec 2024 20:34:03 +0100 Subject: [PATCH] Ensure non-null check for attribute --- src/langtrace_python_sdk/instrumentation/dspy/patch.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/langtrace_python_sdk/instrumentation/dspy/patch.py b/src/langtrace_python_sdk/instrumentation/dspy/patch.py index 8a02afcb..cddd680c 100644 --- a/src/langtrace_python_sdk/instrumentation/dspy/patch.py +++ b/src/langtrace_python_sdk/instrumentation/dspy/patch.py @@ -50,7 +50,7 @@ def traced_method(wrapped, instance, args, kwargs): ), } span_attributes["dspy.optimizer.module.prog"] = json.dumps(prog) - if hasattr(instance, "metric"): + if hasattr(instance, "metric") and getattr(instance, "metric") is not None: span_attributes["dspy.optimizer.metric"] = getattr( instance, "metric" ).__name__