Skip to content

Warn when the configured GenAI completion hook cannot be loaded - #891

Merged
lmolkova merged 2 commits into
open-telemetry:mainfrom
RichardoMrMu:fix/genai-completion-hook-fallback-warning
Oct 13, 2026
Merged

lmolkova merged 2 commits into
open-telemetry:mainfrom
RichardoMrMu:fix/genai-completion-hook-fallback-warning

Conversation

@RichardoMrMu

Copy link
Copy Markdown
Contributor

Description

Log a warning when the completion hook named by OTEL_INSTRUMENTATION_GENAI_COMPLETION_HOOK
cannot be loaded.

load_completion_hook fell back to _NoOpCompletionHook without logging anything when the
configured name is not registered in the opentelemetry_genai_completion_hook entry point
group, and it logged at debug level when the named entry point loaded something that is not a
CompletionHook. Content capture was disabled in both cases with nothing in the logs to explain
why. The "configuration failed" path in the same function already logs at error level; the
function docstring now mentions the warning as well.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How has this been tested?

util/opentelemetry-util-genai/tests/test_completion_hook.py adds
test_load_completion_hook_not_found_warns and test_load_completion_hook_invalid_warns. Both
fail on main -- the call logs nothing at warning level -- and pass with the change. The
util-genai suite is 617 passed. ruff check and ruff format --preview (0.16.1, the pinned
version) are clean.

Checklist

  • Followed the style guidelines of this project
  • Changelog updated if the change requires an entry
  • Unit tests added
  • Documentation updated

I used an AI coding assistant to help investigate and draft this change; I reviewed and verified
the result myself.

`load_completion_hook` returned a no-op hook without logging anything when
`OTEL_INSTRUMENTATION_GENAI_COMPLETION_HOOK` named a hook that is not
registered in the `opentelemetry_genai_completion_hook` entry point group,
and it logged at debug level only when the named entry point loaded an
object that is not a `CompletionHook`. Content capture was disabled in
both cases with nothing in the logs to explain it.

Log a warning in both cases. The path for a hook that fails to load already
logs at error level.

Assisted-by: Doubao
Copilot AI balanced review requested due to automatic review settings October 13, 2026 15:13
@RichardoMrMu
RichardoMrMu requested a review from a team as a code owner October 13, 2026 15:13

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The implementation matches the stated behavior and includes focused regression coverage.

0 open findings

What changed in this PR

Adds warnings when a configured GenAI completion hook is missing or invalid.

Changes:

  • Promotes invalid-hook logging from debug to warning.
  • Warns when the configured entry point is unavailable and adds regression tests.
File Description
util/​opentelemetry-util-genai/​src/​opentelemetry/​util/​genai/​completion_hook.py Adds warning behavior and updates documentation.
util/​opentelemetry-util-genai/​tests/​test_completion_hook.py Verifies missing and invalid hooks emit warnings.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@opentelemetry-pr-dashboard

opentelemetry-pr-dashboard Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Pull request dashboard status

Merged · refreshed 2026-10-13 16:07 UTC

Status above doesn't look right?
  • Anything look wrong? Report it with what you expected; it helps us improve the dashboard.

@lmolkova
lmolkova added this pull request to the merge queue Oct 13, 2026
Merged via the queue into open-telemetry:main with commit 6a78261 Oct 13, 2026
78 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants