@@ -252,6 +252,8 @@ def record_output(self, output: Any):
252
252
253
253
def add_entry (self , entry : TraceEntry ):
254
254
"""Add a trace entry to this trace context"""
255
+ if entry .type == "enter" :
256
+ print (f"Adding entry with span_type: { entry .span_type = } , { entry = } " )
255
257
self .entries .append (entry )
256
258
return self
257
259
@@ -400,23 +402,25 @@ def get_current_trace(self) -> Optional[TraceClient]:
400
402
"""
401
403
return self ._current_trace
402
404
403
- def observe (self , func = None , * , name = None , span_type = "span" ):
405
+ def observe (self , func = None , * , name = None , span_type : SpanType = "span" ):
404
406
"""
405
407
Decorator to trace function execution with detailed entry/exit information.
406
408
407
409
Args:
408
410
func: The function to trace
409
411
name: Optional custom name for the function
412
+ span_type: The type of span to use for this observation (default: "span")
410
413
"""
411
414
if func is None :
412
- return lambda f : self .observe (f , name = name )
415
+ return lambda f : self .observe (f , name = name , span_type = span_type )
413
416
414
417
if asyncio .iscoroutinefunction (func ):
415
418
@functools .wraps (func )
416
419
async def async_wrapper (* args , ** kwargs ):
417
420
if self ._current_trace :
418
421
span_name = name or func .__name__
419
422
423
+ print (f"span_name: { span_name = } , { span_type = } " )
420
424
with self ._current_trace .span (span_name , span_type = span_type ) as span :
421
425
# Set the span type
422
426
span .span_type = span_type
@@ -443,6 +447,7 @@ def wrapper(*args, **kwargs):
443
447
if self ._current_trace :
444
448
span_name = name or func .__name__
445
449
450
+ print (f"span_name: { span_name = } , { span_type = } " )
446
451
with self ._current_trace .span (span_name , span_type = span_type ) as span :
447
452
# Set the span type
448
453
span .span_type = span_type
0 commit comments