Skip to content

Commit eebdf85

Browse files
committed
use abstracted handle error
1 parent aa97bad commit eebdf85

File tree

1 file changed

+2
-9
lines changed
  • src/langtrace_python_sdk/instrumentation/pymongo

1 file changed

+2
-9
lines changed

src/langtrace_python_sdk/instrumentation/pymongo/patch.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
set_span_attributes,
55
set_span_attribute,
66
)
7-
from langtrace_python_sdk.utils import deduce_args_and_kwargs
8-
from opentelemetry.trace.status import Status, StatusCode
7+
from langtrace_python_sdk.utils import deduce_args_and_kwargs, handle_span_error
98
from opentelemetry.trace import SpanKind
109
from langtrace_python_sdk.constants.instrumentation.common import SERVICE_PROVIDERS
1110
from langtrace.trace_attributes import DatabaseSpanAttributes
@@ -48,13 +47,7 @@ def traced_method(wrapped, instance, args, kwargs):
4847
)
4948
return result
5049
except Exception as err:
51-
# Record the exception in the span
52-
span.record_exception(err)
53-
54-
# Set the span status to indicate an error
55-
span.set_status(Status(StatusCode.ERROR, str(err)))
56-
57-
# Reraise the exception to ensure it's not swallowed
50+
handle_span_error(span, err)
5851
raise
5952

6053
return traced_method

0 commit comments

Comments
 (0)