Skip to content

Commit

Permalink
Finalize SpanLimits definition, add option to configure it
Browse files Browse the repository at this point in the history
Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
  • Loading branch information
bogdandrutu committed Feb 9, 2021
1 parent 2349ab4 commit 1f57b50
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 8 deletions.
4 changes: 3 additions & 1 deletion specification/sdk-environment-variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
| ------------------------------- | ------------------------------------ | ------- | ----- |
Expand Down
42 changes: 35 additions & 7 deletions specification/trace/sdk.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* [Sampling](#sampling)
* [Tracer Provider](#tracer-provider)
* [Additional Span Interfaces](#additional-span-interfaces)
* [Limits on Span Collections](#limits-on-span-collections)
* [Span Limits](#span-limits)
* [Id Generator](#id-generators)
* [Span Processor](#span-processor)
* [Span Exporter](#span-exporter)
Expand Down Expand Up @@ -212,9 +212,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 them, 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`),
Expand Down Expand Up @@ -284,17 +285,44 @@ Thus, the SDK specification defines sets of possible requirements for
(for example, the `Span` could be one of the parameters passed to such a function,
or a getter could be provided).

## 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,
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 1000 elements. SDKs MAY provide a way to change this limit.
the recommended limit of 1000 elements.

If there is a configurable limit, the SDK SHOULD honor the environment variables
The SDKs MAY provide a way to change these limits, via a configuration to the
TracerProvider, by allowing users to configure individual limits like the java
example bellow. The name of the cofiguration class MAY be `SpanLimits`, and the
name of the properties SHOULD be `AttributeCountLimit`, `EventCountLimit`,
`LinkCountLimit`. Implementation MAY provide additional configuration such as
`AttributePerEventCountLimit`, `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` - Maximum allowed span attribute count;
* `EventCountLimit` - Maximum allowed span event count;
* `LinkCountLimit` - Maximum allowed span link count;
* `AttributePerEventCountLimit` - Maximum allowed attribute per span event count;
* `AttributePerLinkCountLimit` - Maximum allowed attribute per span link count;

If there is a configurable provided, the SDK SHOULD honor the environment variables
specified in [SDK environment variables](../sdk-environment-variables.md#span-collection-limits).

There SHOULD be a log emitted to indicate to the user that an attribute, event,
Expand Down

0 comments on commit 1f57b50

Please sign in to comment.