Skip to content

fix(logging): invoke log hooks without active spans - #5072

Open
git-jxj wants to merge 2 commits into
open-telemetry:mainfrom
git-jxj:fix/log-hook-without-span
Open

git-jxj wants to merge 2 commits into
open-telemetry:mainfrom
git-jxj:fix/log-hook-without-span

Conversation

@git-jxj

@git-jxj git-jxj commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

Description

Invoke LoggingInstrumentor log hooks for every log record, including records emitted without an active span. In that case, the hook receives OpenTelemetry's INVALID_SPAN sentinel. This lets hooks enrich records independently of tracing context and makes the documented hook behavior consistent.

Fixes #5069

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • This change requires a documentation update

How Has This Been Tested?

  • Added a regression test covering hook invocation without an active span
  • tox run-parallel -e py310-test-instrumentation-logging,py312-test-instrumentation-logging,py314-test-instrumentation-logging,lint-instrumentation-logging

Does This PR Require a Core Repo Change?

  • No.

Checklist:

  • Followed the style guidelines of this project
  • Changelogs have been updated
  • Unit tests have been added
  • Documentation has been updated

@opentelemetry-pr-dashboard

opentelemetry-pr-dashboard Bot commented Sep 18, 2026 •

Copy link
Copy Markdown

Pull request dashboard status

Waiting on reviewers · refreshed 2026-10-17 04:33 UTC

Review the latest changes.

Status above doesn't look right?
  • Just replied or pushed? Anything around or after the refresh time above may not be picked up yet — give it a few minutes.
  • Anything look wrong? Report it with what you expected; it helps us improve the dashboard.

@github-actions

github-actions Bot commented Oct 2, 2026

Copy link
Copy Markdown

This PR has been automatically marked as stale because it has not had any activity for 14 days. It will be closed if no further activity occurs within 14 days of this comment.
If you're still working on this, please add a comment or push new commits.

@github-actions github-actions Bot added the Stale label Oct 2, 2026
@git-jxj

git-jxj commented Oct 2, 2026

Copy link
Copy Markdown
Contributor Author

I'd still like to move this fix for #5069 forward; it is awaiting maintainer review. The CI and changelog workflows for the current head require GitHub Actions approval and have not run. Could a maintainer review the change and approve those workflow runs?

@git-jxj
git-jxj force-pushed the fix/log-hook-without-span branch from b2ef82c to db61705 Compare October 2, 2026 14:56
@github-actions github-actions Bot removed the Stale label Oct 3, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

LoggingInstrumentor log_hook only runs when there is an active span

1 participant