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

Conversation

JonasKunz
Copy link
Contributor

@JonasKunz JonasKunz commented Apr 30, 2024

Fixes #1089.

In addition to the comments on the issue, this was discussed in the spec SIG Meeting on 2024/23/04:

  • The filtering use-case explained in this comment should rather be solved by the upcoming samplerV2 instead of SpanProcessors due to better conceptual fit
  • The buffering use-case also explained in this comment seems to be not relevant enough to influence the design decision
  • Apparently there was a discussion around building the SpanProcessors in a chaining fashion during the initial SDK spec design and it was actively decided against it. However, no one could recall the reason why.

Based on this input, I decided to not move the chaining-based solution forward and stay with the original proposal of adding a new callback to be invoked just before a span is ended.

I also decided to name the new callback OnEnding instead of BeforeEnd as suggested in this comment. The name OnEnding is more precise about when the callback is invoked.

A big discussion point in the SIG Meeting on 2024/23/04 also was the problem of evolving SDK plugin interfaces without breaking backwards compatibility. This PR contains a proposal to clarify how this should be handled: If the language allows it, interfaces should be directly extended. If not possible, implementations will need to introduce new interfaces and accept them in addition to the existing ones for backwards compatibility. I feel like this allow every language to implement changes to interfaces in the best way possible. Of course, changes to interfaces should still be kept to a necessary minimum.

I also wasn't sure whether this change warrants an addition to the spec-compliance-matrix, so I've left it out for now.
Please leave a comment if you think this is required, then I'll add it.

Changes

CHANGELOG.md Show resolved Hide resolved
@JonasKunz JonasKunz marked this pull request as ready for review April 30, 2024 09:18
@JonasKunz JonasKunz requested review from a team April 30, 2024 09:18
specification/trace/sdk.md Show resolved Hide resolved
specification/versioning-and-stability.md Outdated Show resolved Hide resolved
@Flarna
Copy link
Member

Flarna commented May 8, 2024

What is the benefit of onEnding() compared to pass the read/write span to onEnd()?
Both are sync, both are called at the same time (within the Span.End() api).

To my understanding both changes are breaking for SpanProcessor implementers. Either they have to add a method or change the type.

@jack-berg
Copy link
Member

What is the benefit of onEnding() compared to pass the read/write span to onEnd()?

One benefit is that while order of span processor registration matters for onEnding(), it doesn't today and wouldn't with this change with onEnd(). Implementers of onEnd() can continue to rely on semantics where the they get an immutable span which cannot be impacted by other span processors.

To my understanding both changes are breaking for SpanProcessor implementers. Either they have to add a method or change the type.

We're working out the details of that in #4030, but I disagree that adding a new method to an SDK plugin interface is a breaking change. Languages vary in terms of how they expose these plugin interfaces and the language features for evolving interfaces, but there it should be possible for all SDKs to accommodate this type of change, albeit with some creativity in some cases. For example, its simple in java to add a new default method to an interface which existing implementers don't need to implement. This doesn't exist in some language like go, but there you can offer a new ExtendedSpanProcessor interface which includes the new method, and provide a new mechanism for registering that new span processor interface with TracerProvider.

@jmacd jmacd self-assigned this May 20, 2024
Copy link

This PR was marked stale due to lack of activity. It will be closed in 7 days.

@github-actions github-actions bot added the Stale label Jul 12, 2024
@carlosalberto
Copy link
Contributor

@pellared I'd say we are ready to merge as this is in-development - but yes, once we want to go stable, we will need a few prototypes actually. WDYT?

@github-actions github-actions bot removed the Stale label Jul 13, 2024
spec-compliance-matrix.md Outdated Show resolved Hide resolved
Co-authored-by: Damien Mathieu <[email protected]>
@pellared pellared requested a review from dashpole July 15, 2024 20:16
@carlosalberto
Copy link
Contributor

This has enough approvals and as it is experimental, merging it will help us motivate SIGs to prototype this. Will merge by EOD if there are no concerns.

@carlosalberto carlosalberto merged commit c55650e into open-telemetry:main Jul 25, 2024
6 checks passed
@JonasKunz JonasKunz deleted the spanprocessor-end-mutations branch August 7, 2024 10:03
carlosalberto pushed a commit to carlosalberto/opentelemetry-specification that referenced this pull request Oct 31, 2024
…4024)

Fixes open-telemetry#1089.

In addition to the comments on the issue, this was discussed in the spec
SIG Meeting on 2024/23/04:
* The filtering use-case explained in [this
comment](open-telemetry#1089 (comment))
should rather be solved by the upcoming samplerV2 instead of
`SpanProcessor`s due to better conceptual fit
* The buffering use-case also explained in [this
comment](open-telemetry#1089 (comment))
seems to be not relevant enough to influence the design decision
* Apparently there was a discussion around building the `SpanProcessor`s
in a chaining fashion during the initial SDK spec design and it was
actively decided against it. However, no one could recall the reason
why.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add BeforeEnd to have a callback where the span is still writeable