diff --git a/CHANGELOG.md b/CHANGELOG.md index 5304ace65bd..e44aeb577d2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -210,6 +210,9 @@ release. - Specify handling of invalid numeric environment variables ([#2963](https://github.com/open-telemetry/opentelemetry-specification/pull/2963)) +- Add log-specific attribute limit configuration and clarify that general + attribute limit configuration also apply to log records. + ([#2861](https://github.com/open-telemetry/opentelemetry-specification/pull/2861)) ### Telemetry Schemas diff --git a/specification/common/README.md b/specification/common/README.md index 2b377a731cd..f36cb92b85c 100644 --- a/specification/common/README.md +++ b/specification/common/README.md @@ -91,11 +91,11 @@ limits programmatically. Names of the configuration options SHOULD be the same a in the list below. An SDK MAY implement model-specific limits, for example -`SpanAttributeCountLimit`. If both a general and a model-specific limit are -implemented, then the SDK MUST first attempt to use the model-specific limit, if -it isn't set, then the SDK MUST attempt to use the general limit. If neither are -defined, then the SDK MUST try to use the model-specific limit default value, -followed by the global limit default value. +`SpanAttributeCountLimit` or `LogRecordAttributeCountLimit`. If both a general +and a model-specific limit are implemented, then the SDK MUST first attempt to +use the model-specific limit, if it isn't set, then the SDK MUST attempt to use +the general limit. If neither are defined, then the SDK MUST try to use the +model-specific limit default value, followed by the global limit default value. #### Configurable Parameters diff --git a/specification/logs/sdk.md b/specification/logs/sdk.md index 939dac982bf..9c61504f362 100644 --- a/specification/logs/sdk.md +++ b/specification/logs/sdk.md @@ -14,6 +14,7 @@ - [Additional LogRecord interfaces](#additional-logrecord-interfaces) * [ReadableLogRecord](#readablelogrecord) * [ReadWriteLogRecord](#readwritelogrecord) +- [LogRecord Limits](#logrecord-limits) - [LogRecordProcessor](#logrecordprocessor) * [LogRecordProcessor operations](#logrecordprocessor-operations) + [OnEmit](#onemit) @@ -127,6 +128,34 @@ information that was added to the `LogRecord` (as with [ReadableLogRecord](#readablelogrecord)). +## LogRecord Limits + +`LogRecord` attributes MUST adhere to the [common rules of attribute limits](../common/README.md#attribute-limits). + +If the SDK implements attribute limits it MUST provide a way to change these +limits, via a configuration to the `LoggerProvider`, by allowing users to +configure individual limits like in the Java example below. + +The options MAY be bundled in a class, which then SHOULD be called +`LogRecordLimits`. + +```java +public interface LogRecordLimits { + public int getAttributeCountLimit(); + + public int getAttributeValueLengthLimit(); +} +``` + +**Configurable parameters:** + +* [all common options applicable to attributes](../common/README.md#configurable-parameters) + +There SHOULD be a message printed in the SDK's log to indicate to the user +that an attribute was discarded due to such a limit. +To prevent excessive logging, the message should not be printed once per +`LogRecord` or per discarded attribute. + ## LogRecordProcessor `LogRecordProcessor` is an interface which allows hooks for `LogRecord` diff --git a/specification/sdk-environment-variables.md b/specification/sdk-environment-variables.md index 3b8530d3156..52582156e3a 100644 --- a/specification/sdk-environment-variables.md +++ b/specification/sdk-environment-variables.md @@ -157,6 +157,17 @@ See the SDK [Span Limits](trace/sdk.md#span-limits) section for the definition o | OTEL_EVENT_ATTRIBUTE_COUNT_LIMIT | Maximum allowed attribute per span event count | 128 | | | OTEL_LINK_ATTRIBUTE_COUNT_LIMIT | Maximum allowed attribute per span link count | 128 | | +## LogRecord Limits + +**Status**: [Experimental](document-status.md) + +See the SDK [LogRecord Limits](logs/sdk.md#logrecord-limits) section for the definition of the limits. + +| Name | Description | Default | Notes | +| ------------------------------------------- | -------------------------------------------| -------- | ----- | +| OTEL_LOGRECORD_ATTRIBUTE_VALUE_LENGTH_LIMIT | Maximum allowed attribute value size | no limit | | +| OTEL_LOGRECORD_ATTRIBUTE_COUNT_LIMIT | Maximum allowed log record attribute count | 128 | | + ## OTLP Exporter See [OpenTelemetry Protocol Exporter Configuration Options](./protocol/exporter.md).