1111)
1212
1313from  opentelemetry  import  context , trace 
14- from  opentelemetry .trace  import  StatusCode , Tracer , Span ,  Link ,  get_tracer 
14+ from  opentelemetry .trace  import  StatusCode , Tracer , Span 
1515
1616from  guardrails .settings  import  settings 
1717from  guardrails .classes .generic .stack  import  Stack 
@@ -188,11 +188,11 @@ def trace_guard_execution(
188188                if  isinstance (result , Iterator ) and  not  isinstance (
189189                    result , ValidationOutcome 
190190                ):
191-                     for   res   in   trace_stream_guard (guard_span , result , history ): 
192-                          yield   res 
193-                 else : 
194-                      add_guard_attributes (guard_span ,  history ,  result )
195-                      add_user_attributes ( guard_span ) 
191+                     return   trace_stream_guard (guard_span , result , history )
192+ 
193+                 # add_guard_attributes(guard_span, history, result) 
194+                 # add_user_attributes (guard_span)
195+                 return   result 
196196            except  Exception  as  e :
197197                guard_span .set_status (status = StatusCode .ERROR , description = str (e ))
198198                raise  e 
@@ -210,17 +210,17 @@ async def trace_async_stream_guard(
210210        try :
211211            res  =  await  anext (result )  # type: ignore 
212212            # if not guard_span.is_recording(): 
213-                  # Assuming you have a tracer instance 
214-                  # tracer = get_tracer(__name__) 
215-                  # # Create a new span and link it to the previous span 
216-                  # with tracer.start_as_current_span( 
217-                  #     "new_guard_span",  # type: ignore 
218-                  #     links=[Link(guard_span.get_span_context())], 
219-                  # ) as new_span: 
220-                  #     guard_span = new_span 
221- 
222-                  #     add_guard_attributes(guard_span, history, res) 
223-                  #     add_user_attributes(guard_span) 
213+             # Assuming you have a tracer instance 
214+             # tracer = get_tracer(__name__) 
215+             # # Create a new span and link it to the previous span 
216+             # with tracer.start_as_current_span( 
217+             #     "new_guard_span",  # type: ignore 
218+             #     links=[Link(guard_span.get_span_context())], 
219+             # ) as new_span: 
220+             #     guard_span = new_span 
221+ 
222+             #     add_guard_attributes(guard_span, history, res) 
223+             #     add_user_attributes(guard_span) 
224224            yield  res 
225225        except  StopIteration :
226226            next_exists  =  False 
0 commit comments