[core] provide a wrap_executor#221
Conversation
4bc41e3 to
cd07a05
Compare
cd07a05 to
8f50372
Compare
| span_name, | ||
| service=service, | ||
| resource=resource, | ||
| span_type=span_type, |
There was a problem hiding this comment.
In the default signature for wrap_executor, are service, resource, span_type kwargs or args? This usage, and the one in your test are inconsistent.
There was a problem hiding this comment.
| eq_(writer.spans[0].name, 'wrap.overwrite') | ||
| eq_(writer.spans[0].get_tag('args'), '(42,)') | ||
| eq_(writer.spans[0].get_tag('kwargs'), '{\'kw_param\': 42}') | ||
|
|
There was a problem hiding this comment.
can we expand to this to check a nested case i.e. wrapped_function by another traced function -> check if service is correctly propagated
There was a problem hiding this comment.
| :param object context_provider: The ``ContextProvider`` that will be used to retrieve | ||
| automatically the current call context | ||
|
|
||
| :param object wrap_executor: callable that is used when a function is decorated with |
There was a problem hiding this comment.
We could add a comment that context_provider/wrap_executor are advanced options that the user should not modify.
There was a problem hiding this comment.
Added a comment like: This is an advanced option that usually doesn't need to be changed from the default value
|
@LotharSee merged because this one doesn't introduce any incompatibility changes |
What it does
Adds a
wrap_executorcallback to theTracer.configure()method, so that a contrib module can change the behavior ofTracer.wrap(). This is required because in some frameworks (i.e. Tornado), theTracer.wrap()must handle "coroutine" executions that returns immediately aFutureinstance. On the other hand, we can't pollute theTracer.wrap()withcontribcode and PR goals are:wrap_executoris not defined, theTracer.wrap()behaves as usual for regular functions orasynciocoroutineswrap_executoris defined, decorated functions are handled using this callableUsage
Integration example
Look at the Tornado integration and usage.
Limitation
The
wrap_executoris executed each time the decorator is called. We can't use awrap_factorythat returns a new decorator because it could be too late. Indeed, users can decorate their functions before calling thetracer.configure()method. This may add a little overhead (order of nanoseconds) because the following is always evaluated for each call: