-
Notifications
You must be signed in to change notification settings - Fork 153
Client enhancements #30
Conversation
Add report_spans method to Reporter Interface to formally support batch sending spans accumulated by an external entity.
This enables accumulating finished requests and reporting them all together using the new 'report_spans' interface
Add option to override default one-span-per-rpc behaviour. This is useful to visualize RPC calls as nested spans.
Add options to provide extra codecs to the tracer. This allows extending or overriding the tracer's codec during initialization.
|
def report_span(self, span): | ||
self.reporter.report_span(span) | ||
|
||
def report_spans(self, spans): |
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.
nothing calls this method, why do we need it?
|
||
self.end_time = finish_time or time.time() # no locking | ||
self.tracer.report_span(self) | ||
if not defer_report: |
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.
why is this needed? What else would trigger reporting if not span.finish()
?
Regarding the objectives of this PR:
|
Regarding the batch reporting I went with the interface and the external entity approach for two reasons:
What I am trying to achieve, is to have a SpanManager which does something similar to the opetracing-instrumentation python module. The goal is to track the Spans created during the execution of a request, accumulate them, (possibly on a thread local variable), and submit them for reporting when the request is finished. This way the SpanManager knows when to submit all the relative spans and keep the reporter unaware of this. I understand that having a reporter which is capable of batch sending the requests both in terms of getting them out of the critical path and of delivering them to the trace collector is also an advantage. Perhaps the best approach is a combination of both solutions, as having an external SpanManager submitting spans in batches to the Reporter, will allow a Reporter's helper thread (or something similar) to wake-up less frequently or to submit requests to the trace collector more efficiently. |
SpanManager would be something that only knows about OpenTracing API. The Reporter and the relevant methods are the internal implementation detail of Jaeger tracer, SpanManager cannot make use of them. The only thing SpanManager can do is call |
I understand what you are saying, but I was aiming to have a SpanManager that checked if the tracer supports batch reporting and gave a hint to the Tracer that the Span will be reported later in a batch, otherwise fallback to standard OpenTracing API and just call Anyway, if you object on having this merged, I will withdraw the changes and make only two new PRs with the first two bullets, and maybe proceed with a different approach. |
I am definitely not in favor of extending the API, mostly because I still do not understand your use case. Maybe you have some instrumentation code you can demonstrate? Whatever the responsibilities of your SpanManager are, it cannot control when with tracer.start_span('my function', child_of=get_current_span()) as span:
# do the work
# maybe log to span
span.log(..) This will automatically call |
SpanManager has to manage/accumulate/batch report only the spans it manages. And for those, it can require that they are finished only through it, and disallow manual The point is not to prevent or make batch reporting mandatory, but to facilitate towards this direction. I understand how the This extension was not meant to be compatible with a certain API, but enable certain functionality without breaking any API compatibility. Anyway, as I said, I totally understand your objection and I if your are not still convinced of the functionality it enables, I will withdraw this PR and work towards a different direction. |
At this point I would advise perhaps just monkey-patching the methods onto the tracer and reporter in your own module. It goes without saying that you're making your module dependent on implementation details of Jaeger, as other OpenTracing tracers may not even have the concept of a "reporter" (at minimum it might be called differently). We try to keep to the "three strikes" rule, i.e. not introduce API changes or features unless there are 3 use cases for them. I am happy to revisit if you release your span manager code in the future so that we can talk in more concrete terms. In fact, if you think you're building some useful generic functionality, it might be worth opening an issue in opentracing-python repo (or even the specification repo) so that other people can weigh in. I think your use case sits between two audiences, the end users using OT for instrumentation on one hand, and the maintainers of the tracers on the other hand. So far OT has had no opinion on how the maintainers implement their OT API, this common functionality that affects how tracers work largely does not exist. For example, the process of registering custom codecs is implementation-specific. |
OK. Thx for the comments. I'm closing this now as discussed. I've opened #32 as 1/2 PRs |
This PR add three things:
This is quite useful for visualizing the server-side spans on a call as nested spans.