WIP: Low cardinality span names + callback for WSGI#440
WIP: Low cardinality span names + callback for WSGI#440Skeen wants to merge 2 commits intoopen-telemetry:masterfrom
Conversation
Signed-off-by: Emil Madsen <sovende@gmail.com>
…rdinality_span_names
|
I see the issues with the flask integration, I'll look into it. |
| """ | ||
|
|
||
| def __init__(self, wsgi): | ||
| def __init__(self, wsgi, name_callback=None): |
There was a problem hiding this comment.
You can just use get_default_span_name as default here:
def function(argument):
return "prefix_0_" + argument
class Middleware:
def __init__(self, callback=function):
self.callback = callback
print(Middleware().callback("argument"))
print(Middleware(lambda x: "prefix_1_" + x).callback("argument"))prefix_0_argument
prefix_1_argument
There was a problem hiding this comment.
The middleware is initialized only once per process right? Is it worth it adding a dedicated callback to init for this? What if the get_default_span_name() is a method on the middleware class? Users can then just override the class and change the default logic. If we don't want users to go through overriding classes, may be we can provide option constructors in addition? Something like, OpenTelemetryMiddleware.with_span_name_setter(name_setter_func).
I don't think this is a big deal but it feels we'll end up adding more and more args to init to allow customizing some behaviour. Might be worth it prescribing sub-classing instead.
Either that or perhaps the callback could be a generic span callback that gets the whole span and can modify the span in any way, setting the name being one.
This PR fixes #409, and has an ASGI counterpart here: ede28b2