Skip to content

Commit

Permalink
SDK Trace: Adding span collection limits
Browse files Browse the repository at this point in the history
Fixes open-telemetry#182

To help safeguard against a common error, adding default limits
to the number of events per span in the SDK.
  • Loading branch information
toumorokoshi committed Sep 13, 2020
1 parent 48b3433 commit c8b13ab
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
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 | | | | | | | | | | |
|[Span attributes](https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/trace/api.md#set-attributes)|
|SetAttribute | + | + | + | + | + | + | + | + | + | + |
|Set order preserved | + | - | + | + | + | + | + | + | + | + |
Expand Down
22 changes: 21 additions & 1 deletion specification/trace/sdk.md
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,27 @@ 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).


## Span Event Limits

Erroneous code can add unintended events to a span. If these containers 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 MUST be a log message emitted by the SDK for each object discarded.

The following interfaces MUST exist:

- `TracerProvider`: a method to set a maximum collection size
- `TracerProvider`: a method to retrieve the maximum collection size
- `Span`: a method to set a maximum collection size for the span

The default for this limit SHOULD be 1000. A value of 0 indicates no limit.

## Span processor

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

0 comments on commit c8b13ab

Please sign in to comment.