Skip to content

Commit 503ee39

Browse files
committed
fix small bugs
1 parent ff9b8ed commit 503ee39

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

src/lmnr/opentelemetry_lib/decorators/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ def _process_input(
7979
try:
8080
if input_formatter is not None:
8181
inp = input_formatter(*args, **kwargs)
82+
if not isinstance(inp, str):
83+
inp = json_dumps(inp)
8284
else:
8385
inp = get_input_from_func_args(
8486
fn,
@@ -115,6 +117,8 @@ def _process_output(
115117
try:
116118
if output_formatter is not None:
117119
output = output_formatter(result)
120+
if not isinstance(output, str):
121+
output = json_dumps(output)
118122
else:
119123
output = result
120124

src/lmnr/sdk/laminar.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -880,11 +880,13 @@ def use_span(
880880
raise
881881

882882
finally:
883-
context_api.detach(context_token)
884-
detach_context(isolated_context_token)
885-
wrapper.pop_span_context()
886-
if end_on_exit:
887-
span.end()
883+
try:
884+
context_api.detach(context_token)
885+
detach_context(isolated_context_token)
886+
wrapper.pop_span_context()
887+
finally:
888+
if end_on_exit:
889+
span.end()
888890

889891
@classmethod
890892
def start_active_span(

0 commit comments

Comments
 (0)