Skip to content

Commit 37c284b

Browse files
committed
rename spanwrapper to observation wrapper
1 parent 55dce5b commit 37c284b

1 file changed

Lines changed: 18 additions & 18 deletions

File tree

langfuse/_client/span.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
creating, updating, and scoring various types of spans used in AI application tracing.
66
77
Classes:
8-
- LangfuseSpanWrapper: Abstract base class for all Langfuse spans
8+
- LangfuseObservationWrapper: Abstract base class for all Langfuse spans
99
- LangfuseSpan: Implementation for general-purpose spans
1010
- LangfuseGeneration: Specialized span implementation for LLM generations
1111
@@ -54,10 +54,10 @@
5454
# Factory mapping for observation classes
5555
# Note: "event" is handled separately due to special instantiation logic
5656
# Populated after class definitions
57-
_OBSERVATION_CLASS_MAP: Dict[str, Type["LangfuseSpanWrapper"]] = {}
57+
_OBSERVATION_CLASS_MAP: Dict[str, Type["LangfuseObservationWrapper"]] = {}
5858

5959

60-
class LangfuseSpanWrapper:
60+
class LangfuseObservationWrapper:
6161
"""Abstract base class for all Langfuse span types.
6262
6363
This class provides common functionality for all Langfuse span types, including
@@ -191,7 +191,7 @@ def __init__(
191191
{k: v for k, v in attributes.items() if v is not None}
192192
)
193193

194-
def end(self, *, end_time: Optional[int] = None) -> "LangfuseSpanWrapper":
194+
def end(self, *, end_time: Optional[int] = None) -> "LangfuseObservationWrapper":
195195
"""End the span, marking it as completed.
196196
197197
This method ends the wrapped OpenTelemetry span, marking the end of the
@@ -217,7 +217,7 @@ def update_trace(
217217
metadata: Optional[Any] = None,
218218
tags: Optional[List[str]] = None,
219219
public: Optional[bool] = None,
220-
) -> "LangfuseSpanWrapper":
220+
) -> "LangfuseObservationWrapper":
221221
"""Update the trace that this span belongs to.
222222
223223
This method updates trace-level attributes of the trace that this span
@@ -559,7 +559,7 @@ def update(
559559
cost_details: Optional[Dict[str, float]] = None,
560560
prompt: Optional[PromptClient] = None,
561561
**kwargs: Any,
562-
) -> "LangfuseSpanWrapper":
562+
) -> "LangfuseObservationWrapper":
563563
"""Update this observation with new information.
564564
565565
This method updates the observation with new information that becomes available
@@ -646,11 +646,11 @@ def update(
646646
return self
647647

648648

649-
class LangfuseSpan(LangfuseSpanWrapper):
649+
class LangfuseSpan(LangfuseObservationWrapper):
650650
"""Standard span implementation for general operations in Langfuse.
651651
652652
This class represents a general-purpose span that can be used to trace
653-
any operation in your application. It extends the base LangfuseSpanWrapper
653+
any operation in your application. It extends the base LangfuseObservationWrapper
654654
with specific methods for creating child spans, generations, and updating
655655
span-specific attributes.
656656
"""
@@ -1462,11 +1462,11 @@ def start_as_current_observation( # type: ignore[misc]
14621462
)
14631463

14641464

1465-
class LangfuseGeneration(LangfuseSpanWrapper):
1465+
class LangfuseGeneration(LangfuseObservationWrapper):
14661466
"""Specialized span implementation for AI model generations in Langfuse.
14671467
14681468
This class represents a generation span specifically designed for tracking
1469-
AI/LLM operations. It extends the base LangfuseSpanWrapper with specialized
1469+
AI/LLM operations. It extends the base LangfuseObservationWrapper with specialized
14701470
attributes for model details, token usage, and costs.
14711471
"""
14721472

@@ -1528,7 +1528,7 @@ def __init__(
15281528
)
15291529

15301530

1531-
class LangfuseEvent(LangfuseSpanWrapper):
1531+
class LangfuseEvent(LangfuseObservationWrapper):
15321532
"""Specialized span implementation for Langfuse Events."""
15331533

15341534
def __init__(
@@ -1571,7 +1571,7 @@ def __init__(
15711571
)
15721572

15731573

1574-
class LangfuseAgent(LangfuseSpanWrapper):
1574+
class LangfuseAgent(LangfuseObservationWrapper):
15751575
"""Specialized span for agent observations in agentic workflows."""
15761576

15771577
def __init__(self, **kwargs: Any) -> None:
@@ -1580,7 +1580,7 @@ def __init__(self, **kwargs: Any) -> None:
15801580
super().__init__(**kwargs)
15811581

15821582

1583-
class LangfuseTool(LangfuseSpanWrapper):
1583+
class LangfuseTool(LangfuseObservationWrapper):
15841584
"""Specialized span for tool observations in agentic workflows."""
15851585

15861586
def __init__(self, **kwargs: Any) -> None:
@@ -1589,7 +1589,7 @@ def __init__(self, **kwargs: Any) -> None:
15891589
super().__init__(**kwargs)
15901590

15911591

1592-
class LangfuseChain(LangfuseSpanWrapper):
1592+
class LangfuseChain(LangfuseObservationWrapper):
15931593
"""Specialized span for chain observations in agentic workflows."""
15941594

15951595
def __init__(self, **kwargs: Any) -> None:
@@ -1598,7 +1598,7 @@ def __init__(self, **kwargs: Any) -> None:
15981598
super().__init__(**kwargs)
15991599

16001600

1601-
class LangfuseRetriever(LangfuseSpanWrapper):
1601+
class LangfuseRetriever(LangfuseObservationWrapper):
16021602
"""Specialized span for retriever observations in agentic workflows."""
16031603

16041604
def __init__(self, **kwargs: Any) -> None:
@@ -1607,7 +1607,7 @@ def __init__(self, **kwargs: Any) -> None:
16071607
super().__init__(**kwargs)
16081608

16091609

1610-
class LangfuseEmbedding(LangfuseSpanWrapper):
1610+
class LangfuseEmbedding(LangfuseObservationWrapper):
16111611
"""Specialized span for embedding observations in agentic workflows."""
16121612

16131613
def __init__(self, **kwargs: Any) -> None:
@@ -1616,7 +1616,7 @@ def __init__(self, **kwargs: Any) -> None:
16161616
super().__init__(**kwargs)
16171617

16181618

1619-
class LangfuseEvaluator(LangfuseSpanWrapper):
1619+
class LangfuseEvaluator(LangfuseObservationWrapper):
16201620
"""Specialized span for evaluator observations in agentic workflows."""
16211621

16221622
def __init__(self, **kwargs: Any) -> None:
@@ -1625,7 +1625,7 @@ def __init__(self, **kwargs: Any) -> None:
16251625
super().__init__(**kwargs)
16261626

16271627

1628-
class LangfuseGuardrail(LangfuseSpanWrapper):
1628+
class LangfuseGuardrail(LangfuseObservationWrapper):
16291629
"""Specialized span for guardrail observations in agentic workflows."""
16301630

16311631
def __init__(self, **kwargs: Any) -> None:

0 commit comments

Comments
 (0)