@@ -85,7 +85,7 @@ def __init__(
8585 self ._langfuse_client = langfuse_client
8686
8787 self .trace_id = self ._langfuse_client ._get_otel_trace_id (otel_span )
88- self .observation_id = self ._langfuse_client ._get_otel_span_id (otel_span )
88+ self .id = self ._langfuse_client ._get_otel_span_id (otel_span )
8989
9090 # Handle media only if span is sampled
9191 if self ._otel_span .is_recording :
@@ -122,6 +122,8 @@ def end(self, *, end_time: Optional[int] = None):
122122 """
123123 self ._otel_span .end (end_time = end_time )
124124
125+ return self
126+
125127 @abstractmethod
126128 def update (self , ** kwargs ) -> Union ["LangfuseSpan" , "LangfuseGeneration" ]:
127129 """Update the span with new information.
@@ -257,7 +259,7 @@ def score(
257259 name = name ,
258260 value = cast (str , value ),
259261 trace_id = self .trace_id ,
260- observation_id = self .observation_id ,
262+ observation_id = self .id ,
261263 score_id = score_id ,
262264 data_type = cast (Literal ["CATEGORICAL" ], data_type ),
263265 comment = comment ,
@@ -462,7 +464,7 @@ def _process_media_in_attribute(
462464 data = data ,
463465 field = field ,
464466 trace_id = self .trace_id ,
465- observation_id = self .observation_id ,
467+ observation_id = self .id ,
466468 project_id = self ._langfuse_client .langfuse_tracer .project_id ,
467469 )
468470
0 commit comments