From b90702303a8ed770a213855f9a40d02e1d2cb6ce Mon Sep 17 00:00:00 2001 From: Bogdan Drutu Date: Wed, 10 Feb 2021 11:01:30 -0800 Subject: [PATCH] Finalize SpanLimits definition, add option to configure it (#1416) * Finalize SpanLimits definition, add option to configure it Signed-off-by: Bogdan Drutu * Address some of the feedback Signed-off-by: Bogdan Drutu * Update default for limits per event and link Signed-off-by: Bogdan Drutu * Add entry to the spec matrix Signed-off-by: Bogdan Drutu * Fix last feedback, allow this to be a class or not Signed-off-by: Bogdan Drutu * Mark span-limits optional in the compliance matrix Signed-off-by: Bogdan Drutu --- CHANGELOG.md | 1 + spec-compliance-matrix.md | 1 + specification/sdk-environment-variables.md | 4 +- specification/trace/sdk.md | 43 ++++++++++++++++++---- 4 files changed, 40 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1e0d7edbe15..e494e471afc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ New: - Add `cloud.infrastructure_service` resource attribute ([#1112](https://github.com/open-telemetry/opentelemetry-specification/pull/1112)) +- Add `SpanLimits` as a configuration for the TracerProvider([#1416](https://github.com/open-telemetry/opentelemetry-specification/pull/1416)) Updates: diff --git a/spec-compliance-matrix.md b/spec-compliance-matrix.md index dc042978e17..8b4ddf4bbe1 100644 --- a/spec-compliance-matrix.md +++ b/spec-compliance-matrix.md @@ -70,6 +70,7 @@ status of the feature is not known. | ShouldSample gets full parent Context | | | + | + | + | + | + | | | + | - | + | | [New Span ID created also for non-recording Spans](specification/trace/sdk.md#sdk-span-creation) | | | | | + | + | | | | | - | + | | [IdGenerators](specification/trace/sdk.md#id-generators) ] | | | | | | | | | | | | | +| [SpanLimits](specification/trace/sdk.md#span-limits) ] | X | | | | | | | | | | | | ## Baggage diff --git a/specification/sdk-environment-variables.md b/specification/sdk-environment-variables.md index 23112ea5d15..809fb228db6 100644 --- a/specification/sdk-environment-variables.md +++ b/specification/sdk-environment-variables.md @@ -73,7 +73,9 @@ Depending on the value of `OTEL_TRACES_SAMPLER`, `OTEL_TRACES_SAMPLER_ARG` may b ## Span Collection Limits -**Status**: [Experimental](document-status.md) +**Status**: [Stable](document-status.md) + +See the SDK [Span Limits](trace/sdk.md#span-limits) section for the definition of the limits. | Name | Description | Default | Notes | | ------------------------------- | ------------------------------------ | ------- | ----- | diff --git a/specification/trace/sdk.md b/specification/trace/sdk.md index 89da29878d7..c3dd528bc3c 100644 --- a/specification/trace/sdk.md +++ b/specification/trace/sdk.md @@ -9,7 +9,7 @@ * [Tracer Provider](#tracer-provider) * [Additional Span Interfaces](#additional-span-interfaces) * [Sampling](#sampling) -* [Limits on Span Collections](#limits-on-span-collections) +* [Span Limits](#span-limits) * [Id Generator](#id-generators) * [Span Processor](#span-processor) * [Span Exporter](#span-exporter) @@ -26,9 +26,10 @@ supplied to the `TracerProvider` must be used to create an [`InstrumentationLibrary`][otep-83] instance which is stored on the created `Tracer`. -Configuration (i.e., [Span processors](#span-processor), [IdGenerator](#id-generators), -and [`Sampler`](#sampling)) MUST be managed solely by the `TracerProvider` and it -MUST provide some way to configure them, at least when creating or initializing it. +Configuration (i.e., [SpanProcessors](#span-processor), [IdGenerator](#id-generators), +[SpanLimits](#span-limits) and [`Sampler`](#sampling)) MUST be managed solely by +the `TracerProvider` and it MUST provide some way to configure all of them that +are implemented in the SDK, at least when creating or initializing it. The TracerProvider MAY provide methods to update the configuration. If configuration is updated (e.g., adding a `SpanProcessor`), @@ -292,7 +293,7 @@ Optional parameters: |present|false|true|`localParentSampled()`| |present|false|false|`localParentNotSampled()`| -## Limits on Span Collections +## Span Limits Erroneous code can add unintended attributes, events, and links to a span. If these collections are unbounded, they can quickly exhaust available memory, @@ -300,10 +301,36 @@ resulting in crashes that are difficult to recover from safely. To protect against such errors, SDK Spans MAY discard attributes, links, and events that would increase the number of elements of each collection beyond -the recommended limit of 128 elements. SDKs MAY provide a way to change this limit. +the configured limit. -If there is a configurable limit, the SDK SHOULD honor the environment variables -specified in [SDK environment variables](../sdk-environment-variables.md#span-collection-limits). +It the SDK implements the limits above it MUST provide a way to change these +limits, via a configuration to the TracerProvider, by allowing users to +configure individual limits like in the Java example bellow. + +The name of the configuration options SHOULD be `AttributeCountLimit`, +`EventCountLimit` and `LinkCountLimit`. The options MAY be bundled in a class, +which then SHOULD be called `SpanLimits`. Implementations MAY provide additional +configuration such as `AttributePerEventCountLimit` and `AttributePerLinkCountLimit`. + +```java +public final class SpanLimits { + SpanLimits(int attributeCountLimit, int linkCountLimit, int eventCountLimit); + + public int getAttributeCountLimit(); + + public int getEventCountLimit(); + + public int getLinkCountLimit(); +} +``` + +**Configurable parameters:** + +* `AttributeCountLimit` (Default=1000) - Maximum allowed span attribute count; +* `EventCountLimit` (Default=1000) - Maximum allowed span event count; +* `LinkCountLimit` (Default=1000) - Maximum allowed span link count; +* `AttributePerEventCountLimit` (Default=128) - Maximum allowed attribute per span event count; +* `AttributePerLinkCountLimit` (Default=128) - Maximum allowed attribute per span link count; There SHOULD be a log emitted to indicate to the user that an attribute, event, or link was discarded due to such a limit. To prevent excessive logging, the log