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 4 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 @@ -23,6 +23,8 @@ New:
([#697](https://github.com/open-telemetry/opentelemetry-specification/pull/697))
* API was extended to allow adding arbitrary event attributes ([#874](https://github.com/open-telemetry/opentelemetry-specification/pull/874))
* `exception.escaped` was added ([#784](https://github.com/open-telemetry/opentelemetry-specification/pull/784))
- Add default limits to the number of events in SDK Spans
([#942](https://github.com/open-telemetry/opentelemetry-specification/pull/942))

Updates:

Expand Down
4 changes: 4 additions & 0 deletions spec-compliance-matrix.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ status of the feature is not known.
|[TracerProvider](https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/trace/api.md#tracerprovider-operations)|
|Create TracerProvider | + | + | + | + | + | + | + | + | + | + |
|Get a Tracer | + | + | + | + | + | + | + | + | + | + |
|Set a collection limit | | | | | | | | | | |
|Get a collection limit | | | | | | | | | | |
|Safe for concurrent calls | + | + | + | | + | + | + | + | + | + |
|[Tracer](https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/trace/api.md#tracer-operations)|
|Create a new Span | + | + | + | + | + | + | + | + | + | + |
Expand All @@ -37,6 +39,8 @@ status of the feature is not known.
|IsRecording | + | + | + | + | + | + | + | | + | + |
|Set status | + | + | + | + | + | + | + | + | + | + |
|Safe for concurrent calls | + | + | + | | + | + | + | + | + | + |
|Set a collection limit | | | | | | | | | | |
|Discard events greater than collection limit | | | | | | | | | | |
toumorokoshi marked this conversation as resolved.
Show resolved Hide resolved
|[Span attributes](https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/trace/api.md#set-attributes)|
|SetAttribute | + | + | + | + | + | + | + | + | + | + |
|Set order preserved | + | - | + | + | + | + | + | + | + | + |
Expand Down
32 changes: 30 additions & 2 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 @@ -215,7 +216,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 @@ -236,7 +237,34 @@ 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 MUST discard attributes, links, and
events that would increase the size of each collection beyond a limit configured
in the `TracerProvider`, or for the span specifically.

There SHOULD be a log message emitted by the SDK for the first time a span has
discarded a span due to a limit. This message should be emitted once for
toumorokoshi marked this conversation as resolved.
Show resolved Hide resolved
attributes, events, and links, and MUST be configurable on or off, with
toumorokoshi marked this conversation as resolved.
Show resolved Hide resolved
a default of on.

The following interfaces MUST exist:

- `TracerProvider`: a method to set a maximum collection size
- `TracerProvider`: a method to retrieve the maximum collection size
toumorokoshi marked this conversation as resolved.
Show resolved Hide resolved

The default for this limit SHOULD be 1000. A value of -1 indicates no limit,
while a value of 0 would result in no events being collected.

Implementations MAY also enable configuration for the maximum size of individual
collections: attributes, events, and links. These limits would take precedence
over the general collection limit.

## Span processor

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