Repository navigation
Conversation
|
|
There was a problem hiding this comment.
Pull request overview
Adds support for explicitly setting observation start timestamps (nanoseconds since epoch) when manually creating root and child observations, enabling accurate historical durations for delayed span emission workflows (e.g., replaying OpenTelemetry spans from stored exports).
Changes:
- Extend
start_observation(...)(client + child observations) to accept an optionalstart_time: Optional[int]and forward it to the underlying OpenTelemetry tracer. - Ensure
event-type child observations can use an explicitstart_time(otherwise defaulting totime_ns()). - Add a unit test asserting that provided historical
start_timevalues are preserved on exported spans.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
langfuse/_client/client.py |
Adds start_time to root observation creation and forwards it to _otel_tracer.start_span(...). |
langfuse/_client/span.py |
Adds start_time to child observation creation (including event handling) and forwards it to _otel_tracer.start_span(...). |
tests/unit/test_otel.py |
Adds coverage verifying historical start/end timestamps are preserved for manual root + child observations. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
What does this PR do?
Adds an optional nanosecond
start_timeto manual root and child observations. This makes manual observation creation symmetric withend(end_time=...)and preserves historical durations when an integration emits spans after the underlying work has completedFixes #1377
Type of change
Verification
Checklist
code_review.md..env.templateif needed.Greptile Summary
This PR adds explicit start times for manually created observations. The main changes are:
start_timeto root and child observation APIs.Confidence Score: 5/5
This looks safe to merge.
start_timeis omitted.Reviews (1): Last reviewed commit: "feat(tracing): allow explicit observatio..." | Re-trigger Greptile