opentelemetry-instrumentation-logging: fix documented name of code attributes env var - #4912
Open
krrishapatel wants to merge 2 commits into
Open
Conversation
…tributes env var The envvar directive in constants.py documented this option as OTEL_PYTHON_CODE_ATTRIBUTES, but the instrumentation reads OTEL_PYTHON_LOG_CODE_ATTRIBUTES, so following the published docs had no effect. The surrounding prose in the same module, environment_variables.py, and the test suite all use the LOG_ form. Written with assistance from Claude Opus 5 (Anthropic), which located the mismatch, verified it against the installed package, and drafted this change.
2 tasks
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
The
envvardirective inconstants.pydocuments the code-attributes option asOTEL_PYTHON_CODE_ATTRIBUTES, but the instrumentation readsOTEL_PYTHON_LOG_CODE_ATTRIBUTES. Users who follow the published documentation set a variable that nothing reads, socodeattributes silently never appear on emitted log records.The
LOG_form is the correct one, and everything else in the package already agrees with it:environment_variables.pydefinesOTEL_PYTHON_LOG_CODE_ATTRIBUTES__init__.pyreadsenviron.get(OTEL_PYTHON_LOG_CODE_ATTRIBUTES, "false")constants.pyitself refers toOTEL_PYTHON_LOG_CODE_ATTRIBUTEStests/test_logging.pypatchesOTEL_PYTHON_LOG_CODE_ATTRIBUTESThe directive at line 59 is the only place in the repository using the shorter name. It appears to be a typo introduced in #4210.
This changes documentation only. No env var handling changes, so there is no behavior change and nothing to deprecate.
Verification
I installed the package and set each name in turn, then checked whether
code.*attributes appeared on an exported log record:After the fix, every
envvardirective inconstants.pymatches a name defined inenvironment_variables.py, with no extras in either direction.pytest tests/foropentelemetry-instrumentation-logging: 71 passed.Type of change
Does This PR Require a Core Repo Change?
Checklist
tests/test_logging.py:405already covers the correct variable nameWritten with assistance from Claude Opus 5 (Anthropic), which located the mismatch, verified it against the installed package, and drafted this description.