Repository navigation
Conversation
`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
Assisted-by: Doubao
Contributor
There was a problem hiding this comment.
🟢 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.
Pull request dashboard statusMerged · refreshed 2026-10-13 16:07 UTC Status above doesn't look right?
|
lmolkova
approved these changes
Oct 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Log a warning when the completion hook named by
OTEL_INSTRUMENTATION_GENAI_COMPLETION_HOOKcannot be loaded.
load_completion_hookfell back to_NoOpCompletionHookwithout logging anything when theconfigured name is not registered in the
opentelemetry_genai_completion_hookentry pointgroup, 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 explainwhy. 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
How has this been tested?
util/opentelemetry-util-genai/tests/test_completion_hook.pyaddstest_load_completion_hook_not_found_warnsandtest_load_completion_hook_invalid_warns. Bothfail on main -- the call logs nothing at warning level -- and pass with the change. The
util-genaisuite is 617 passed.ruff checkandruff format --preview(0.16.1, the pinnedversion) are clean.
Checklist
I used an AI coding assistant to help investigate and draft this change; I reviewed and verified
the result myself.