-
Notifications
You must be signed in to change notification settings - Fork 879
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 span processing function from application code #6191
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be good to keep new public API here in a separate incubator artifact if needing to merge this soon. As there isn't any instrumentation-specific issue here, at a glance it seems that the SDK is a better place for this, though as usual I generally wouldn't stop active avoidance of the spec process if that's the main motivation :)
...on-api/src/main/java/io/opentelemetry/instrumentation/api/util/ContextSpanProcessorUtil.java
Outdated
Show resolved
Hide resolved
javaagent-tooling/src/main/java/io/opentelemetry/javaagent/tooling/ContextSpanProcessor.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some users wish to add extra attributes or update the name of http client spans. This can be troublesome because there isn't an obvious place where you could stick
Span.current()
and add the attributes.
If not using the Javaagent, would registering a SpanProcessor
solve this use case?
And if so, what do you think about providing a javaagent-only hook to register/bridge SpanProcessor
, instead of introducing new concept?
.../io/opentelemetry/javaagent/instrumentation/instrumentationapi/ContextSpanProcessorTest.java
Outdated
Show resolved
Hide resolved
.../io/opentelemetry/javaagent/instrumentation/instrumentationapi/ContextSpanProcessorTest.java
Outdated
Show resolved
Hide resolved
Realized also that attributesextractor also should be able to hook this and maybe is simpler than span processor. |
Co-authored-by: Trask Stalnaker <trask.stalnaker@gmail.com>
I believe so. It should be possible to implement a
You mean using |
* will be applied to all spans create while the context is active. Processing function is called | ||
* synchronously on the execution thread, it should not throw or block the execution thread. | ||
*/ | ||
public interface ContextSpanProcessor extends ImplicitContextKeyed { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you move this class to instrumentation-api-semconv
? (I guess it's probably the best place for incubating code?) As we want to release stable instrumentation-api
soon, we shouldn't add new experimental utils there.
Also, there are other angles that we might want to consider in the future:
- making it possible to load SPI implementations directly from the application code; you could add a
SpanProcessor
without an extension this way; - or going through spec with this -- there's an OTEP about
Context
-scoped attributes (Propose Context-scoped attributes. oteps#207) that looks really similar to this.
If any of these get implemented at some point we'll want to deprecate and remove theContextSpanProcessor
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh interesting I hadn't made the connection with the context-scoped attributes OTEP 👍
...src/main/java/io/opentelemetry/instrumentation/api/internal/ContextSpanProcessorInvoker.java
Outdated
Show resolved
Hide resolved
...src/main/java/io/opentelemetry/instrumentation/api/internal/ContextSpanProcessorInvoker.java
Show resolved
Hide resolved
Co-authored-by: Mateusz Rzeszutek <mrzeszutek@splunk.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are we comfortable dropping backwards compatibility for this in future Javaagent versions (e.g. if open-telemetry/oteps#207 gets implemented)?
I don't mean without a deprecation cycle, but rather as opposed to ServerSpan
which we continue to preserve backwards compatibility for in the Javaagent to avoid breaking users of older instrumentation-api.
@trask I added a note to the javadoc that marks this as experimental. We'll sooner or later wish to introduce experimental APIs, we might as well start with this one and see how it plays out. By clearly stating that this API can be removed we should absolve ourselves of the consequences of removing it. Not that something particularly bad would happen, the way it is built when agent drops support for it there will just be a loss of functionality not exceptions flying around. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
might be nice to get rename suggested into same release to avoid breaking/dealing with deprecation right away #6310 (comment)
let's hold this until after 1.16.0, so we can sort out #6310 first |
Some users wish to add extra attributes or update the name of http client spans. This can be troublesome because there isn't an obvious place where you could stick
Span.current()
and add the attributes. This pr introduces an api for adding a span processing function to context and a span processor that applies that function when the span is created.