Skip to content

opentelemetry-instrumentation-logging: fix documented name of code attributes env var - #4912

Open
krrishapatel wants to merge 2 commits into
open-telemetry:mainfrom
krrishapatel:fix/log-code-attributes-envvar-name
Open

opentelemetry-instrumentation-logging: fix documented name of code attributes env var#4912
krrishapatel wants to merge 2 commits into
open-telemetry:mainfrom
krrishapatel:fix/log-code-attributes-envvar-name

Conversation

@krrishapatel

Copy link
Copy Markdown

Description

The envvar directive in constants.py documents the code-attributes option as OTEL_PYTHON_CODE_ATTRIBUTES, but the instrumentation reads OTEL_PYTHON_LOG_CODE_ATTRIBUTES. Users who follow the published documentation set a variable that nothing reads, so code attributes 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.py defines OTEL_PYTHON_LOG_CODE_ATTRIBUTES
  • __init__.py reads environ.get(OTEL_PYTHON_LOG_CODE_ATTRIBUTES, "false")
  • The prose earlier in constants.py itself refers to OTEL_PYTHON_LOG_CODE_ATTRIBUTES
  • tests/test_logging.py patches OTEL_PYTHON_LOG_CODE_ATTRIBUTES

The 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:

set OTEL_PYTHON_CODE_ATTRIBUTES=true      -> code attributes present: False  []
set OTEL_PYTHON_LOG_CODE_ATTRIBUTES=true  -> code attributes present: True   ['code.file.path', 'code.function.name', 'code.line.number']

After the fix, every envvar directive in constants.py matches a name defined in environment_variables.py, with no extras in either direction.

pytest tests/ for opentelemetry-instrumentation-logging: 71 passed.

Type of change

  • This change requires a documentation update

Does This PR Require a Core Repo Change?

  • Yes.
  • No.

Checklist

  • Followed the style guidelines of this project
  • Unit tests have been added — n/a, documentation-only change; the existing test at tests/test_logging.py:405 already covers the correct variable name
  • Documentation has been updated

Written with assistance from Claude Opus 5 (Anthropic), which located the mismatch, verified it against the installed package, and drafted this description.

…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.
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.

1 participant