Skip to content

fix(logs): correlate V2 log records with their span context - #137

Open
pedropombeiro wants to merge 2 commits into
DEVtheOPS:mainfrom
pedropombeiro:fix/log-trace-context
Open

pedropombeiro wants to merge 2 commits into
DEVtheOPS:mainfrom
pedropombeiro:fix/log-trace-context

Conversation

@pedropombeiro

Copy link
Copy Markdown
Contributor

Description

V2 event logs omit native trace/span IDs because event dispatch has no active OTel context. Capture the matching
LLM, tool, or execution context before cleanup and pass it explicitly to the log SDK. Logs without a matching
span stay uncorrelated, and disabled-log policies remain unchanged.

Type of change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactoring (no functional changes)
  • Chore (dependency updates, etc.)

Checklist

  • I have read the CONTRIBUTING.md document
  • My code follows the style guidelines of this project
  • bun run lint passes with no errors
  • bun run check:jsdoc-coverage passes with no errors
  • bun run typecheck passes with no errors
  • bun test passes with no errors
  • I have added tests that prove my fix is effective or that my feature works
  • I have updated the documentation accordingly
  • My commits follow the Conventional Commits specification

Related issues

Related: #121 and #129 address the same problem using the previous V1 handlers. This change targets the current
V2 implementation.

Additional context

Validated commit 6cafc37: 213 tests pass, including real OpenCode OTLP/JSON assertions for LLM and tool log IDs.
Type-checking, linting, and JSDoc coverage pass. Regression cases cover overlapping calls, separate sessions,
failed executions, disabled signals, and missing start events.

On the QTS test host, Bun runs with a compatible userspace loader and a test-only subprocess-launch adapter.
The adapter does not change the plugin or OTLP assertions and is not included in this PR.

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.

1 participant