Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SDK Trace: Adding span collection limits #942

Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ New:
([#981](https://github.com/open-telemetry/opentelemetry-specification/pull/981))
- Define PropagationOnly Span to simplify active Span logic in Context
([#994](https://github.com/open-telemetry/opentelemetry-specification/pull/994))
- Add limits to the number of attributes, events, and links in SDK Spans
([#942](https://github.com/open-telemetry/opentelemetry-specification/pull/942))
- Add Metric SDK specification (partial): covering terminology and Accumulator component
([#626](https://github.com/open-telemetry/opentelemetry-specification/pull/626))

Expand Down
8 changes: 8 additions & 0 deletions specification/sdk-environment-variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ Additional values can be specified in the respective SDK's documentation, in cas
| OTEL_BSP_MAX_QUEUE_SIZE | Maximum queue size | 2048 | |
| OTEL_BSP_MAX_EXPORT_BATCH_SIZE | Maximum batch size | 512 | Must be less than or equal to OTEL_BSP_MAX_QUEUE_SIZE |

## Span Collection Limits

| Name | Description | Default | Notes |
| ------------------------------- | ------------------------------------ | ------- | ----- |
| OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT | Maximum allowed span attribute count | 1000 | |
| OTEL_SPAN_EVENT_COUNT_LIMIT | Maximum allowed span event count | 1000 | |
| OTEL_SPAN_LINK_COUNT_LIMIT | Maximum allowed span link count | 1000 | |

## OTLP Exporter

See [OpenTelemetry Protocol Exporter Configuration Options](./protocol/exporter.md).
Expand Down
25 changes: 22 additions & 3 deletions specification/trace/sdk.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* [Sampling](#sampling)
* [Tracer Creation](#tracer-creation)
* [Additional Span Interfaces](#additional-span-interfaces)
* [Limits on Span Collections](#limits-on-span-collections)
* [Span Processor](#span-processor)
* [Span Exporter](#span-exporter)

Expand Down Expand Up @@ -35,7 +36,7 @@ The OpenTelemetry API has two properties responsible for the data collection:
specification](https://www.w3.org/TR/trace-context/#sampled-flag). This flag indicates that the `Span` has been
`sampled` and will be exported. [Span Exporters](#span-exporter) MUST
receive those spans which have `Sampled` flag set to true and they SHOULD NOT receive the ones
that do not.
that do not.

The flag combination `SampledFlag == false` and `IsRecording == true`
means that the current `Span` does record information, but most likely the child
Expand Down Expand Up @@ -220,7 +221,7 @@ Thus, the SDK specification defines sets of possible requirements for
It must also be able to reliably determine whether the Span has ended
(some languages might implement this by having an end timestamp of `null`,
others might have an explicit `hasEnded` boolean).

A function receiving this as argument might not be able to modify the Span.

Note: Typically this will be implemented with a new interface or
Expand All @@ -241,7 +242,25 @@ Thus, the SDK specification defines sets of possible requirements for
that the [span creation API](api.md#span-creation) returned (or will return) to the user
(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

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,
toumorokoshi marked this conversation as resolved.
Show resolved Hide resolved

If there is a configurable limit, the SDK MAY honor the environment variables
toumorokoshi marked this conversation as resolved.
Show resolved Hide resolved
specified in [SDK environment variables](../sdk-environment-variables.md#span-collection-limits).

There SHOULD be a log message emitted by the SDK the first time per process where
a span attribute, event, or link is discarded due to a limit. This message should be
once per attributes, events, and links, and MUST be configurable on or off, with
a default of on.

## Span processor

Span processor is an interface which allows hooks for span start and end method
Expand Down