Skip to content

feat: honor Laminar parent span context - #8

Merged
kolbeyang merged 3 commits into
mainfrom
feat/parent-span-context
Jul 14, 2026
Merged

kolbeyang merged 3 commits into
mainfrom
feat/parent-span-context

Conversation

@kolbeyang

@kolbeyang kolbeyang commented Jul 14, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

read LMNR_PARENT_SPAN_CONTEXT and use it as the remote parent for Claude Code turn root spans\n- preserve standalone trace behavior when the env var is absent or invalid\n- add OTLP coverage for parented roots\n- document the env var and rebuild dist/hook.cjs\n\n## Testing\n- npm run build\n- npm test\n- npm run typecheck\n\nNote: I attempted an end-to-end Laminar SQL verification with a temporary script, but deleted the script per request before commit. The attempted query used the Codex test project id and returned no rows, likely because the Claude Code plugin config's API key belongs to a different Laminar project.


Note

Low Risk
Observability-only parent-context wiring with validation and unchanged export/auth paths; invalid env values preserve prior standalone-trace behavior.

Overview
Adds optional trace linking so Claude Code sessions can appear under an existing Laminar trace when a caller sets LMNR_SPAN_CONTEXT (serialized span context from Laminar.serialize_span_context() or the SDK).

TraceEmitter reads and validates that JSON at construction (supports traceId/trace_id, spanId/span_id, optional traceFlags), normalizes hex IDs, and uses the result as the remote parent for turn root spans when no explicit parent is passed. Invalid or missing values are ignored with debug logging and standalone traces behave as before. Child spans (e.g. LLM) still parent under the turn root.

Docs (README, CLAUDE.md) describe the env var; dist/hook.cjs is rebuilt. An OTLP test asserts parent trace/span IDs on roots and on the wire payload.

Reviewed by Cursor Bugbot for commit 2d45c51. Bugbot is set up for automated code reviews on this repo. Configure here.

@kolbeyang kolbeyang self-assigned this Jul 14, 2026
@kolbeyang
kolbeyang merged commit 42337ed into main Jul 14, 2026
2 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.

2 participants