Skip to content

Commit 57a134e

Browse files
authored
feat(core): add support for observation events (#1190)
1 parent 7af5dbc commit 57a134e

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

langfuse/_client/client.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1120,7 +1120,8 @@ def _create_observation_id(self, *, seed: Optional[str] = None) -> str:
11201120

11211121
return sha256(seed.encode("utf-8")).digest()[:8].hex()
11221122

1123-
def create_trace_id(self, *, seed: Optional[str] = None) -> str:
1123+
@staticmethod
1124+
def create_trace_id(*, seed: Optional[str] = None) -> str:
11241125
"""Create a unique trace ID for use with Langfuse.
11251126
11261127
This method generates a unique trace ID for use with various Langfuse APIs.
@@ -1164,7 +1165,7 @@ def create_trace_id(self, *, seed: Optional[str] = None) -> str:
11641165
if not seed:
11651166
trace_id_int = RandomIdGenerator().generate_trace_id()
11661167

1167-
return self._format_otel_trace_id(trace_id_int)
1168+
return Langfuse._format_otel_trace_id(trace_id_int)
11681169

11691170
return sha256(seed.encode("utf-8")).digest()[:16].hex()
11701171

@@ -1178,7 +1179,8 @@ def _get_otel_span_id(self, otel_span: otel_trace_api.Span):
11781179

11791180
return self._format_otel_span_id(span_context.span_id)
11801181

1181-
def _format_otel_span_id(self, span_id_int: int) -> str:
1182+
@staticmethod
1183+
def _format_otel_span_id(span_id_int: int) -> str:
11821184
"""Format an integer span ID to a 16-character lowercase hex string.
11831185
11841186
Internal method to convert an OpenTelemetry integer span ID to the standard
@@ -1192,7 +1194,8 @@ def _format_otel_span_id(self, span_id_int: int) -> str:
11921194
"""
11931195
return format(span_id_int, "016x")
11941196

1195-
def _format_otel_trace_id(self, trace_id_int: int) -> str:
1197+
@staticmethod
1198+
def _format_otel_trace_id(trace_id_int: int) -> str:
11961199
"""Format an integer trace ID to a 32-character lowercase hex string.
11971200
11981201
Internal method to convert an OpenTelemetry integer trace ID to the standard
@@ -1482,9 +1485,6 @@ def score_current_trace(
14821485
config_id=config_id,
14831486
)
14841487

1485-
def update_finished_trace(self):
1486-
pass
1487-
14881488
def flush(self):
14891489
"""Force flush all pending spans and events to the Langfuse API.
14901490

langfuse/_client/span.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1140,8 +1140,8 @@ def __init__(
11401140
Args:
11411141
otel_span: The OpenTelemetry span to wrap
11421142
langfuse_client: Reference to the parent Langfuse client
1143-
input: Input data for the generation (e.g., prompts)
1144-
output: Output from the generation (e.g., completions)
1143+
input: Input data for the event
1144+
output: Output from the event
11451145
metadata: Additional metadata to associate with the generation
11461146
environment: The tracing environment
11471147
"""

0 commit comments

Comments
 (0)