summary refs log tree commit diff
path: root/synapse/logging/opentracing.py
diff options
context:
space:
mode:
authorJorik Schellekens <joriks@matrix.org>2019-07-15 11:23:43 +0100
committerJorik Schellekens <joriks@matrix.org>2019-07-17 14:20:48 +0100
commitaca1141a62aa8bb4ad74f846ffcee6da4c6a7635 (patch)
tree83850b0c8d8604a899e529a2cb066bd8f0755bc9 /synapse/logging/opentracing.py
parentSectioning comments (diff)
downloadsynapse-aca1141a62aa8bb4ad74f846ffcee6da4c6a7635.tar.xz
Rebase doctoring
Diffstat (limited to 'synapse/logging/opentracing.py')
-rw-r--r--synapse/logging/opentracing.py42
1 files changed, 8 insertions, 34 deletions
diff --git a/synapse/logging/opentracing.py b/synapse/logging/opentracing.py

index a6743a7139..35a94001ff 100644 --- a/synapse/logging/opentracing.py +++ b/synapse/logging/opentracing.py
@@ -278,7 +278,7 @@ def start_active_span_from_edu( @only_if_tracing def set_tag(key, value): - """Set's a tag on the active span""" + """Sets a tag on the active span""" opentracing.tracer.active_span.set_tag(key, value) @@ -308,6 +308,9 @@ def set_operation_name(operation_name): opentracing.tracer.active_span.set_operation_name(operation_name) +##### Injection and extraction + + @only_if_tracing def inject_active_span_twisted_headers(headers, destination): """ @@ -339,9 +342,6 @@ def inject_active_span_twisted_headers(headers, destination): headers.addRawHeaders(key, value) -##### Injection and extraction - - @only_if_tracing def inject_active_span_byte_dict(headers, destination): """ @@ -413,33 +413,6 @@ def trace_deferred(func): """Decorator to trace a deferred function. Sets the operation name to that of the function's.""" - -def trace_servlet(servlet_name, func): - """Decorator which traces a serlet. It starts a span with some servlet specific - tags such as the servlet_name and request information""" - - @wraps(func) - @defer.inlineCallbacks - def _trace_servlet_inner(request, *args, **kwargs): - with start_active_span_from_context( - request.requestHeaders, - "incoming-client-request", - tags={ - "request_id": request.get_request_id(), - tags.SPAN_KIND: tags.SPAN_KIND_RPC_SERVER, - tags.HTTP_METHOD: request.get_method(), - tags.HTTP_URL: request.get_redacted_uri(), - tags.PEER_HOST_IPV6: request.getClientIP(), - "servlet_name": servlet_name, - }, - ): - result = yield defer.maybeDeferred(func, request, *args, **kwargs) - defer.returnValue(result) - - return _trace_servlet_inner - - -def trace_defered_function(func): @wraps(func) @defer.inlineCallbacks def _trace_deferred_inner(self, *args, **kwargs): @@ -508,10 +481,10 @@ def wrap_in_span(func): which is a complete break from the current logcontext. This function creates a non active span from the current context and closes it after the function executes.""" - + global opentracing # I haven't use this function yet - if not TracerUtil._opentracing: + if not opentracing: return func parent_span = opentracing.tracer.active_span @@ -532,7 +505,8 @@ def wrap_in_span(func): def trace_servlet(servlet_name, func): - """Decorator to trace a servlet""" + """Decorator which traces a serlet. It starts a span with some servlet specific + tags such as the servlet_name and request information""" if not opentracing: return func