File tree Expand file tree Collapse file tree 2 files changed +11
-5
lines changed
opentelemetry_lib/decorators Expand file tree Collapse file tree 2 files changed +11
-5
lines changed Original file line number Diff line number Diff 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
Original file line number Diff line number Diff 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 (
You can’t perform that action at this time.
0 commit comments