Skip to content

fix(instrumentation): re-add span_id and trace_id to logs - #42647

Merged
jamietanna merged 1 commit into
mainfrom
fix/span
Apr 15, 2026
Merged

jamietanna merged 1 commit into
mainfrom
fix/span

Conversation

@jamietanna

@jamietanna jamietanna commented Apr 15, 2026 •

Copy link
Copy Markdown
Contributor

Changes

As part of recent changes to how our logger is initialised, we
accidentally broke the propagation of OpenTelemtry span_id and
trace_id into the Bunyan log context.

We already registered BunyanInstrumentation, but because of the
import, the instrumentation could not man-in-the-middle the import and
register the instrumentation.

This is slightly more complex, and brittle, test, but does capture the
current behaviour of BunyanInstrumentation, if it were removed.

Context

Please select one of the following:

AI assistance disclosure

Did you use AI tools to create any part of this pull request?

Please select one option and, if yes, briefly describe how AI was used (e.g., code, tests, docs) and which tool(s) you used.

  • No — I did not use AI for this contribution.
  • Yes — minimal assistance (e.g., IDE autocomplete, small code completions, grammar fixes).
  • Yes — substantive assistance (AI-generated non‑trivial portions of code, tests, or documentation).
  • Yes — other (please describe): Claude Sonnet 4.6

Documentation (please check one with an [x])

  • I have updated the documentation, or
  • No documentation update is required

How I've tested my work (please select one)

I have verified these changes via:

  • Code inspection only, or
  • Newly added/modified unit tests, or
  • No unit tests, but ran on a real repository, or
  • Both unit tests + ran on a real repository

The public repository:

As part of recent changes to how our logger is initialised, we
accidentally broke the propagation of OpenTelemtry `span_id` and
`trace_id` into the Bunyan log context.

We already registered `BunyanInstrumentation`, but because of the
`import`, the instrumentation could not man-in-the-middle the import and
register the instrumentation.

This is slightly more complex, and brittle, test, but does capture the
current behaviour of `BunyanInstrumentation`, if it were removed.

Co-authored-by: Claude Sonnet 4.6 <jamie.tanna+claude-code@mend.io>
@jamietanna
jamietanna requested a review from a team April 15, 2026 16:03
@jamietanna
jamietanna marked this pull request as ready for review April 15, 2026 16:03
@jamietanna
jamietanna added this pull request to the merge queue Apr 15, 2026
Merged via the queue into main with commit 63618c6 Apr 15, 2026
54 of 68 checks passed
@jamietanna
jamietanna deleted the fix/span branch April 15, 2026 17:31
@github-actions

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 43.123.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

Comment thread lib/logger/bunyan.ts
Comment on lines +10 to +12
const bunyan = createRequire(import.meta.url)(
'bunyan',
) as typeof import('bunyan');

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

we should refactor to use our expost.ts (like we do with prettier and re2). will send a pr later

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators May 18, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Instrumentation is no longer adding trace_id and span_id to logs

3 participants