-
Notifications
You must be signed in to change notification settings - Fork 718
OTEL attribute count limit not respected, causing columns dropped #4677
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
OTEL attribute count limit not respected, causing columns dropped #4677
Conversation
889a3ec
to
d2ac2c3
Compare
opentelemetry-sdk/src/opentelemetry/sdk/_logs/_internal/__init__.py
Outdated
Show resolved
Hide resolved
opentelemetry-sdk/src/opentelemetry/sdk/_logs/_internal/__init__.py
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reverting my approval pending https://github.com/open-telemetry/opentelemetry-python/pull/4677/files#r2198591904
Hi @pmcollins , can this change be merged so we can patch our code? |
Hi @giongto35 -- we'll need one of the maintainers to review the change. Once a maintainer has approved, then the change can be merged. In the meantime, I have approved the workflows to run. |
Description
Fixes #4671
This PR fixes a bug where the
LoggingHandler
in the OpenTelemetry Python SDK does not respect theOTEL_ATTRIBUTE_COUNT_LIMIT
environment variable. When this environment variable is set, it should limit the number of attributes in log records, but the LoggingHandler was ignoring this setting entirely and only use the default value 128.It means:
Changes Made
Fixed the Root Cause Bug
The core issue was that
LogRecord
was created with_UnsetLogLimits
which usedUNSET
values, and theLogLimits._from_env_if_absent
method had a bug where it returnedNone
immediately whenvalue == cls.UNSET
, never checking environment variables.Implementation Benefits
This implementation allows users to:
OTEL_ATTRIBUTE_COUNT_LIMIT
)Type of change
How Has This Been Tested?
You can run the tests using pytest:
Test Coverage
Added comprehensive tests to verify the fix works correctly:
test_otel_attribute_count_limit_respected_in_logging_handler
- Tests that whenOTEL_ATTRIBUTE_COUNT_LIMIT=3
, only 3 attributes are kept and the rest are droppedtest_otel_attribute_count_limit_includes_code_attributes
- Tests that whenOTEL_ATTRIBUTE_COUNT_LIMIT=5
, only 5 attributes are kept and the limit applies to all attribute types including code attributestest_logging_handler_without_env_var_uses_default_limit
- Tests that without the environment variable, the default limit of 128 is appliedAll tests pass, confirming the fix works correctly across all these scenarios.
Does This PR Require a Contrib Repo Change?
Checklist: