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

Add ability for SpanProcessor to mutate spans on end #4024

Merged
Merged
Show file tree
Hide file tree
Changes from 37 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
1722053
Clarified approach on how to extend SDK plugin interfaces
JonasKunz Apr 30, 2024
a4b411a
Added onEnding method to SpanProcessor
JonasKunz Apr 30, 2024
600c721
wording
JonasKunz Apr 30, 2024
1d3543d
Added changelog
JonasKunz Apr 30, 2024
d60594f
linting
JonasKunz Apr 30, 2024
6bf8266
more linting
JonasKunz Apr 30, 2024
19d5a77
Add experimental status
JonasKunz May 2, 2024
5bcce33
Merge remote-tracking branch 'otel/main' into spanprocessor-end-mutat…
JonasKunz May 2, 2024
598a9eb
Removed paragraph about SDK interface extensions
JonasKunz May 2, 2024
e34d828
Merge remote-tracking branch 'otel/main' into spanprocessor-end-mutat…
JonasKunz May 8, 2024
81bef44
Remove accidental merge leftover
JonasKunz May 8, 2024
b56fbb9
Disallow concurrent updates, specify invocation order
JonasKunz May 14, 2024
f54293d
Merge remote-tracking branch 'otel/main' into spanprocessor-end-mutat…
JonasKunz May 14, 2024
990c91a
Linting
JonasKunz May 14, 2024
e38a16d
Merge remote-tracking branch 'otel/main' into spanprocessor-end-mutat…
JonasKunz May 16, 2024
2cf024a
Update specification/trace/sdk.md
JonasKunz May 23, 2024
ae572ca
Apply suggestions from code review
JonasKunz May 24, 2024
303c8c2
Merge remote-tracking branch 'otel/main' into spanprocessor-end-mutat…
JonasKunz May 27, 2024
4d8422a
Merge remote-tracking branch 'otel/main' into spanprocessor-end-mutat…
JonasKunz Jun 5, 2024
218783f
Apply suggestions from code review
JonasKunz Jun 5, 2024
1a385b5
Merge branch 'main' into spanprocessor-end-mutations
JonasKunz Jun 7, 2024
b0f776c
Merge branch 'main' into spanprocessor-end-mutations
JonasKunz Jun 13, 2024
d680966
Merge branch 'main' into spanprocessor-end-mutations
JonasKunz Jun 19, 2024
1e5c7fa
Fix changelog after merge
JonasKunz Jun 19, 2024
ffcb614
Marked SpanProcessor.OnEnding as optional
JonasKunz Jun 26, 2024
7cdc995
Add to compliance matrix
JonasKunz Jun 26, 2024
a72ea8f
lint fix
JonasKunz Jun 26, 2024
fe34f57
Added missing methods, adjust formatting
JonasKunz Jun 27, 2024
a8da098
Merge remote-tracking branch 'otel/main' into spanprocessor-end-mutat…
JonasKunz Jun 27, 2024
afe1eec
Merge remote-tracking branch 'otel/main' into spanprocessor-end-mutat…
JonasKunz Jul 4, 2024
a97ca5f
Merge branch 'main' into spanprocessor-end-mutations
JonasKunz Jul 12, 2024
70f91d9
Merge branch 'main' into spanprocessor-end-mutations
JonasKunz Jul 12, 2024
6449448
Merge branch 'main' into spanprocessor-end-mutations
JonasKunz Jul 15, 2024
4997436
Review fixes
JonasKunz Jul 15, 2024
47854c9
Merge branch 'main' into spanprocessor-end-mutations
pellared Jul 15, 2024
1f75e17
Merge branch 'main' into spanprocessor-end-mutations
JonasKunz Jul 16, 2024
786ff95
Merge branch 'main' into spanprocessor-end-mutations
JonasKunz Jul 17, 2024
f246ff6
Merge branch 'main' into spanprocessor-end-mutations
JonasKunz Jul 24, 2024
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ release.

### Traces

- Add in-development `OnEnding` callback to SDK `SpanProcessor` interface.
([#4024](https://github.com/open-telemetry/opentelemetry-specification/pull/4024))
JonasKunz marked this conversation as resolved.
Show resolved Hide resolved

### Metrics

### Logs
Expand Down
1 change: 1 addition & 0 deletions spec-compliance-matrix.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ formats is required. Implementing more than one format is optional.
| events collection size limit | | + | + | + | + | + | + | + | + | - | - | + |
| attribute collection size limit | | + | + | + | + | + | + | + | + | - | - | + |
| links collection size limit | | + | + | + | + | + | + | + | + | - | - | + |
| [SpanProcessor.OnEnding](specification/trace/sdk.md#onending) | X | - | - | - | - | - | - | - | - | - | - | - |
| [Span attributes](specification/trace/api.md#set-attributes) | Optional | Go | Java | JS | Python | Ruby | Erlang | PHP | Rust | C++ | .NET | Swift |
| SetAttribute | | + | + | + | + | + | + | + | + | + | + | + |
| Set order preserved | X | + | - | + | + | + | + | + | + | + | + | + |
Expand Down
34 changes: 33 additions & 1 deletion specification/trace/sdk.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ linkTitle: SDK
- [Span processor](#span-processor)
* [Interface definition](#interface-definition)
+ [OnStart](#onstart)
+ [OnEnding](#onending)
+ [OnEnd(Span)](#onendspan)
+ [Shutdown()](#shutdown)
+ [ForceFlush()](#forceflush)
Expand Down Expand Up @@ -569,11 +570,23 @@ in the SDK:

### Interface definition

The `SpanProcessor` interface MUST declare the following methods:
JonasKunz marked this conversation as resolved.
Show resolved Hide resolved

* [OnStart](#onstart)
* [OnEnd](#onendspan)
* [Shutdown](#shutdown-1)
* [ForceFlush](#forceflush-1)

The `SpanProcessor` interface SHOULD declare the following methods:

* [OnEnding](#onending) method.

#### OnStart

`OnStart` is called when a span is started. This method is called synchronously
on the thread that started the span, therefore it should not block or throw
exceptions.
exceptions. If multiple `SpanProcessors` are registered, their `OnStart` callbacks
are invoked in the order they have been registered.

**Parameters:**

Expand All @@ -588,6 +601,25 @@ exceptions.

**Returns:** `Void`

#### OnEnding
JonasKunz marked this conversation as resolved.
Show resolved Hide resolved
JonasKunz marked this conversation as resolved.
Show resolved Hide resolved

**Status**: [Development](../document-status.md)

`OnEnding` is called during the span `End()` operation, after the end timestamp has been set. The Span object is still mutable (i.e., `SetAttribute`, `AddLink`, `AddEvent` can be called) while `OnEnding` is called.
This method MUST be called synchronously within the [`Span.End()` API](api.md#end),
therefore it should not block or throw an exception.
jack-berg marked this conversation as resolved.
Show resolved Hide resolved
If multiple `SpanProcessors` are registered, their `OnEnding` callbacks
are invoked in the order they have been registered.
The SDK MUST guarantee that the span can no longer be modified by any other thread
before invoking `OnEnding` of the first `SpanProcessor`. From that point on, modifications
are only allowed synchronously from within the invoked `OnEnding` callbacks. All registered SpanProcessor `OnEnding` callbacks are executed before any SpanProcessor's `OnEnd` callback is invoked.
pellared marked this conversation as resolved.
Show resolved Hide resolved

**Parameters:**

* `span` - a [read/write span object](#additional-span-interfaces) for the span which is about to be ended.

**Returns:** `Void`

#### OnEnd(Span)

`OnEnd` is called after a span is ended (i.e., the end timestamp is already set).
Expand Down
Loading