Skip to content

Commit

Permalink
Add log attribute limit configuration (open-telemetry#2861)
Browse files Browse the repository at this point in the history
Fixes open-telemetry#2860

Adds log attribute limit configuration.

These new environment variables bring more consistency between spans and logs.
  • Loading branch information
alanwest authored Jan 27, 2023
1 parent f003d4f commit 970a403
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 5 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
10 changes: 5 additions & 5 deletions specification/common/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
29 changes: 29 additions & 0 deletions specification/logs/sdk.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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`
Expand Down
11 changes: 11 additions & 0 deletions specification/sdk-environment-variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down

0 comments on commit 970a403

Please sign in to comment.