Skip to content

fix: preserve explicit parent for child events - #2045

Merged
hassiebp merged 1 commit into
langfuse:mainfrom
AryanRG:fix-child-event-explicit-parent
Oct 23, 2026
Merged

hassiebp merged 1 commit into
langfuse:mainfrom
AryanRG:fix-child-event-explicit-parent

Conversation

@AryanRG

@AryanRG AryanRG commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do?

Child events created with parent.start_observation(as_type="event") currently use the ambient span instead of the explicit parent. With no active span, they start a separate trace.

Activate the explicit parent while creating the event, matching the existing child-span and create_event paths. Added coverage for absent, matching and unrelated ambient spans, context restoration and event attributes.

Type of change

  • Bug fix

Verification

python -m pytest tests/unit/test_otel.py::test_child_observation_uses_explicit_parent tests/unit/test_resource_manager.py
ruff check .
ruff format --check .
mypy langfuse --no-error-summary

The adjacent OTel/context tests also pass. No live-provider or e2e runs; the change is covered with the in-memory exporter.

Checklist

  • I self-reviewed the diff using code_review.md.
  • I added tests for the behavior change.
  • No docs, examples or environment changes are needed.
  • No generated files were hand-edited.
  • No secrets or credentials were committed.

RetriggerView in GreptileConfidence Score: 5/5

The PR appears safe to merge.

Summary

Fixes child events so they use the explicit parent instead of the current active span.

  • Child events follow the parent selected by the caller.

No actionable issues found. Tests were reviewed but not run.

Reviews (1) · Last reviewed commit: "fix: preserve explicit parent for child ..." · Reviewed by Greptile

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

@CLAassistant

CLAassistant commented Oct 23, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@hassiebp

Copy link
Copy Markdown
Collaborator

THanks a lot for your contribution, @AryanRG !

@hassiebp
hassiebp enabled auto-merge (squash) October 23, 2026 13:26
@hassiebp
hassiebp merged commit 05765e8 into langfuse:main Oct 23, 2026
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants