-
Notifications
You must be signed in to change notification settings - Fork 626
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
Tornado attributes #706
Tornado attributes #706
Changes from 3 commits
06c83f7
6e6a036
e6220f6
d3f7a6e
71b06cc
514048d
5ab9247
1f8ec7c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -235,11 +235,8 @@ def _get_attributes_from_request(request): | |
SpanAttributes.HTTP_TARGET: request.path, | ||
} | ||
|
||
if request.host: | ||
attrs[SpanAttributes.HTTP_HOST] = request.host | ||
|
||
if request.remote_ip: | ||
attrs[SpanAttributes.NET_PEER_IP] = request.remote_ip | ||
attrs[SpanAttributes.HTTP_CLIENT_IP] = request.remote_ip | ||
|
||
return extract_attributes_from_object( | ||
request, _traced_request_attrs, attrs | ||
|
@@ -252,6 +249,11 @@ def _get_operation_name(handler, request): | |
return f"{class_name}.{request.method.lower()}" | ||
|
||
|
||
def _get_full_handler_name(handler): | ||
klass = type(handler) | ||
return f"{klass.__module__}.{klass.__qualname__}" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. would this work fine for dynamically generated handlers within a function? I know that is not very common but sounds like an edge case. Any concerns regarding that? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe |
||
|
||
|
||
def _start_span(tracer, handler, start_time) -> _TraceContext: | ||
token = context.attach(extract(handler.request.headers)) | ||
|
||
|
@@ -264,6 +266,7 @@ def _start_span(tracer, handler, start_time) -> _TraceContext: | |
attributes = _get_attributes_from_request(handler.request) | ||
for key, value in attributes.items(): | ||
span.set_attribute(key, value) | ||
span.set_attribute("handler", _get_full_handler_name(handler)) | ||
srikanthccv marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
activation = trace.use_span(span, end_on_exit=True) | ||
activation.__enter__() # pylint: disable=E1101 | ||
|
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.
Please add a comment here for future contributors describing why we assign these to different attributes.