2929from opentelemetry import trace
3030from opentelemetry import trace as otel_trace_api
3131from opentelemetry .sdk .trace .id_generator import RandomIdGenerator
32- from opentelemetry .util ._decorator import _agnosticcontextmanager
32+ from opentelemetry .util ._decorator import (
33+ _AgnosticContextManager ,
34+ _agnosticcontextmanager ,
35+ )
3336
3437from langfuse ._client .attributes import (
3538 LangfuseOtelSpanAttributes ,
@@ -310,7 +313,6 @@ def start_span(
310313 metadata = metadata ,
311314 )
312315
313- # TODO: add return typing
314316 def start_as_current_span (
315317 self ,
316318 * ,
@@ -323,7 +325,7 @@ def start_as_current_span(
323325 level : Optional [SpanLevel ] = None ,
324326 status_message : Optional [str ] = None ,
325327 end_on_exit : Optional [bool ] = None ,
326- ):
328+ ) -> _AgnosticContextManager [ LangfuseSpan ] :
327329 """Create a new span and set it as the current span in a context manager.
328330
329331 This method creates a new span and sets it as the current span within a context
@@ -529,7 +531,7 @@ def start_as_current_generation(
529531 cost_details : Optional [Dict [str , float ]] = None ,
530532 prompt : Optional [PromptClient ] = None ,
531533 end_on_exit : Optional [bool ] = None ,
532- ):
534+ ) -> _AgnosticContextManager [ LangfuseGeneration ] :
533535 """Create a new generation span and set it as the current span in a context manager.
534536
535537 This method creates a specialized span for AI model generations and sets it as the
@@ -954,7 +956,7 @@ def _is_valid_span_id(self, span_id):
954956
955957 return bool (re .match (pattern , span_id ))
956958
957- def create_observation_id (self , * , seed : Optional [str ] = None ) -> str :
959+ def _create_observation_id (self , * , seed : Optional [str ] = None ) -> str :
958960 """Create a unique observation ID for use with Langfuse.
959961
960962 This method generates a unique observation ID (span ID in OpenTelemetry terms)
@@ -1167,7 +1169,7 @@ def create_score(
11671169 if not self .tracing_enabled :
11681170 return
11691171
1170- score_id = score_id or self .create_observation_id ()
1172+ score_id = score_id or self ._create_observation_id ()
11711173
11721174 try :
11731175 score_event = {
0 commit comments