Skip to content

Commit 1d3f9ff

Browse files
committed
Fix span_types not being passed in for all observe() cases.
1 parent cf2adbb commit 1d3f9ff

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

judgeval/common/tracer.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,8 @@ def record_output(self, output: Any):
252252

253253
def add_entry(self, entry: TraceEntry):
254254
"""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=}")
255257
self.entries.append(entry)
256258
return self
257259

@@ -400,23 +402,25 @@ def get_current_trace(self) -> Optional[TraceClient]:
400402
"""
401403
return self._current_trace
402404

403-
def observe(self, func=None, *, name=None, span_type="span"):
405+
def observe(self, func=None, *, name=None, span_type: SpanType = "span"):
404406
"""
405407
Decorator to trace function execution with detailed entry/exit information.
406408
407409
Args:
408410
func: The function to trace
409411
name: Optional custom name for the function
412+
span_type: The type of span to use for this observation (default: "span")
410413
"""
411414
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)
413416

414417
if asyncio.iscoroutinefunction(func):
415418
@functools.wraps(func)
416419
async def async_wrapper(*args, **kwargs):
417420
if self._current_trace:
418421
span_name = name or func.__name__
419422

423+
print(f"span_name: {span_name=}, {span_type=}")
420424
with self._current_trace.span(span_name, span_type=span_type) as span:
421425
# Set the span type
422426
span.span_type = span_type
@@ -443,6 +447,7 @@ def wrapper(*args, **kwargs):
443447
if self._current_trace:
444448
span_name = name or func.__name__
445449

450+
print(f"span_name: {span_name=}, {span_type=}")
446451
with self._current_trace.span(span_name, span_type=span_type) as span:
447452
# Set the span type
448453
span.span_type = span_type

0 commit comments

Comments
 (0)