Skip to content

oss_21_logger_provider_log_record_limits#42

Open
ocelotl wants to merge 2 commits into
mainfrom
oss_21_logger_provider_log_record_limits
Open

oss_21_logger_provider_log_record_limits#42
ocelotl wants to merge 2 commits into
mainfrom
oss_21_logger_provider_log_record_limits

Conversation

@ocelotl

@ocelotl ocelotl commented Jul 22, 2026

Copy link
Copy Markdown
Owner

Closes #37

LoggerProvider now accepts a programmatic limits (LogRecordLimits, analogous to TracerProvider's SpanLimits); threaded into Logger and _from_api_log_record so attribute count/length limits apply to emitted log records (Linear OSS-21, finding L2). Backward compatible (defaults unchanged).

Validation: scope contained to opentelemetry-sdk + changelog; logs suite 115 passed.

Linear issue: https://linear.app/dash0/issue/OSS-21/l2-loggerprovider-cannot-configure-logrecordlimits-programmatically

LoggerProvider.__init__ gains a `limits` argument accepting a
LogRecordLimits, mirroring how TracerProvider accepts SpanLimits. The
limits are stored on the provider, threaded through each Logger, and
applied when building ReadWriteLogRecord instances so attribute count
and value-length limits are enforced on emitted log records.

Previously LogRecordLimits could only be configured via environment
variables; there was no way to set them programmatically, so
_from_api_log_record always used the default limits.

Default behavior (no limits argument) is unchanged.
@ocelotl

ocelotl commented Jul 22, 2026

Copy link
Copy Markdown
Owner Author

🔒 Internal (dash0) — not for upstream.

@ocelotl

ocelotl commented Jul 22, 2026

Copy link
Copy Markdown
Owner Author

📣 Public-facing draft — to be used for the upstream PR in open-telemetry/opentelemetry-python. No internal references; copy verbatim.

Title: Add programmatic LogRecordLimits support to LoggerProvider

What

LoggerProvider.__init__ now accepts a keyword-only limits argument of type LogRecordLimits. The provider stores it, passes it to each Logger it creates, and threads it into ReadWriteLogRecord._from_api_log_record, so attribute-count and attribute-value-length limits are enforced on emitted log records.

Why

TracerProvider already accepts SpanLimits programmatically, but the logs SDK only exposed LogRecordLimits through environment variables — _from_api_log_record always used default limits, so there was no way to set log-record limits in code. This aligns the logs SDK with the tracing SDK and the spec's "LogRecord Limits" section (mirrors Java's SdkLoggerProviderBuilder.setLogLimits / LogLimits).

Spec

specification/logs/sdk.md — "LogRecord Limits".

Compatibility

Fully backward compatible: when limits is omitted, the provider constructs a default LogRecordLimits(), preserving the previous env-var/default behavior.

Tests

New TestLoggerProviderLimits emits records through a real LoggerProvider(limits=...) + SimpleLogRecordProcessor + in-memory exporter and asserts: default provider applies the default attribute-count limit and reports dropped attributes; programmatic max_log_record_attributes bounds attribute count; max_log_record_attribute_length truncates values; and the global max_attributes/max_attribute_length act as fallbacks. Full logs suite passes (115).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

oss_21_logger_provider_log_record_limits

1 participant