-
Notifications
You must be signed in to change notification settings - Fork 316
Consider adding an Observer API #136
Comments
I did an experiment of using the Observer API for emitting RPC metrics (jaegertracing/jaeger-client-go#103). A few considerations:
|
@yurishkuro I've been thinking about this, and so far can't come up with a better approach than your observer pattern. The only things I don't like about it:
Currently, I have no good answer to these issues. I think we may have to live with them. A meta-observation: because SpanContext is opaque and does not provide a unique SpanId, we can't have an effective a stateless event listener pattern. If spans had type StartSpanObserver func (sp Span, operationName string, options StartSpanOptions)
type SetOperationNameObserver func (sp Span, operationName string)
type SetTagObserver func (sp Span, key string, value interface{})
type FinishObserver func (sp Span, options FinishOptions)
// ...etc I understand that OT does not currently require spans to have a unique ID... but I wonder if there are other examples of how this lack of ID ends up creating convoluted code and extra management mechanisms. Even if that ID was only defined as a string or byte array, I wonder how much would be simplified by having it. Anyways, given all of that, I think your Observer looks like a good tradeoff. It sucks that people will have to tack on methods they don't care about or have their observer break when we change the Span API, but hopefully we don't do that very often. :) |
another option here is to move this Observer to a contrib project, to incubate. |
@yurishkuro I think that would be great... certainly would allow us to make faster progress since the stakes are lower. cc @hkshaw1990 |
Yeah, I agree a contrib project is a good idea. These Observers/hooks are consumed by the tracer implementations, optionally supported, and aren't directly part of the OT-API, so contrib might be a better place for them anyways. |
Yup, seems like a good idea, since observers will be anyway optional. @bhs if you will create a repo (maybe opentracing-contrib/observer?) for this, I will move the PR there. |
Thanks @bhs, I have moved the PR to : opentracing-contrib/go-observer#1 |
Per the discussion here: #135 (comment) ... and the non-portable work here: jaegertracing/jaeger-client-go#94
Should OpenTracing-Go provide an observer interface? basictracer-go has something like this, too. By baking it into OT proper, we would most likely end up with separate API and SPI layers (otherwise Tracer implementations would have to do a bunch of redundant work).
The text was updated successfully, but these errors were encountered: