Clean up dummy tags
parent
965427760b
commit
9ce4a3d906
|
|
@ -344,10 +344,10 @@ class MatrixFederationHttpClient(object):
|
||||||
TracerUtil.start_active_span(
|
TracerUtil.start_active_span(
|
||||||
"outgoing-federation-request",
|
"outgoing-federation-request",
|
||||||
tags={
|
tags={
|
||||||
TracerUtil.Tags.SPAN_KIND: TracerUtil.Tags.SPAN_KIND_RPC_CLIENT,
|
TracerUtil.tags.SPAN_KIND: TracerUtil.tags.SPAN_KIND_RPC_CLIENT,
|
||||||
TracerUtil.Tags.PEER_ADDRESS: request.destination,
|
TracerUtil.tags.PEER_ADDRESS: request.destination,
|
||||||
TracerUtil.Tags.HTTP_METHOD: request.method,
|
TracerUtil.tags.HTTP_METHOD: request.method,
|
||||||
TracerUtil.Tags.HTTP_URL: request.path,
|
TracerUtil.tags.HTTP_URL: request.path,
|
||||||
},
|
},
|
||||||
finish_on_close=True,
|
finish_on_close=True,
|
||||||
)
|
)
|
||||||
|
|
@ -436,7 +436,7 @@ class MatrixFederationHttpClient(object):
|
||||||
response.phrase.decode("ascii", errors="replace"),
|
response.phrase.decode("ascii", errors="replace"),
|
||||||
)
|
)
|
||||||
|
|
||||||
TracerUtil.set_tag(TracerUtil.Tags.HTTP_STATUS_CODE, response.code)
|
TracerUtil.set_tag(TracerUtil.tags.HTTP_STATUS_CODE, response.code)
|
||||||
|
|
||||||
if 200 <= response.code < 300:
|
if 200 <= response.code < 300:
|
||||||
pass
|
pass
|
||||||
|
|
|
||||||
|
|
@ -241,10 +241,10 @@ class SynapseRequest(Request):
|
||||||
"incoming-federation-request",
|
"incoming-federation-request",
|
||||||
tags={
|
tags={
|
||||||
"request_id": self.get_request_id(),
|
"request_id": self.get_request_id(),
|
||||||
TracerUtil.Tags.SPAN_KIND: TracerUtil.Tags.SPAN_KIND_RPC_SERVER,
|
TracerUtil.tags.SPAN_KIND: TracerUtil.tags.SPAN_KIND_RPC_SERVER,
|
||||||
TracerUtil.Tags.HTTP_METHOD: self.get_method(),
|
TracerUtil.tags.HTTP_METHOD: self.get_method(),
|
||||||
TracerUtil.Tags.HTTP_URL: self.get_redacted_uri(),
|
TracerUtil.tags.HTTP_URL: self.get_redacted_uri(),
|
||||||
TracerUtil.Tags.PEER_HOST_IPV6: self.getClientIP(),
|
TracerUtil.tags.PEER_HOST_IPV6: self.getClientIP(),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,38 @@ from functools import wraps
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
class _DumTagNames(object):
|
||||||
|
"""wrapper of opentracings tags. We need to have them if we
|
||||||
|
want to reference them without opentracing around. Clearly they
|
||||||
|
should never actually show up in a trace. `set_tags` overwrites
|
||||||
|
these with the correct ones."""
|
||||||
|
|
||||||
|
INVALID_TAG = "invalid-tag"
|
||||||
|
COMPONENT = INVALID_TAG
|
||||||
|
DATABASE_INSTANCE = INVALID_TAG
|
||||||
|
DATABASE_STATEMENT = INVALID_TAG
|
||||||
|
DATABASE_TYPE = INVALID_TAG
|
||||||
|
DATABASE_USER = INVALID_TAG
|
||||||
|
ERROR = INVALID_TAG
|
||||||
|
HTTP_METHOD = INVALID_TAG
|
||||||
|
HTTP_STATUS_CODE = INVALID_TAG
|
||||||
|
HTTP_URL = INVALID_TAG
|
||||||
|
MESSAGE_BUS_DESTINATION = INVALID_TAG
|
||||||
|
PEER_ADDRESS = INVALID_TAG
|
||||||
|
PEER_HOSTNAME = INVALID_TAG
|
||||||
|
PEER_HOST_IPV4 = INVALID_TAG
|
||||||
|
PEER_HOST_IPV6 = INVALID_TAG
|
||||||
|
PEER_PORT = INVALID_TAG
|
||||||
|
PEER_SERVICE = INVALID_TAG
|
||||||
|
SAMPLING_PRIORITY = INVALID_TAG
|
||||||
|
SERVICE = INVALID_TAG
|
||||||
|
SPAN_KIND = INVALID_TAG
|
||||||
|
SPAN_KIND_CONSUMER = INVALID_TAG
|
||||||
|
SPAN_KIND_PRODUCER = INVALID_TAG
|
||||||
|
SPAN_KIND_RPC_CLIENT = INVALID_TAG
|
||||||
|
SPAN_KIND_RPC_SERVER = INVALID_TAG
|
||||||
|
|
||||||
|
|
||||||
def only_if_tracing(func):
|
def only_if_tracing(func):
|
||||||
"""Executes the function only if we're tracing. Otherwise return.
|
"""Executes the function only if we're tracing. Otherwise return.
|
||||||
Assumes the function wrapped may return None"""
|
Assumes the function wrapped may return None"""
|
||||||
|
|
@ -41,6 +73,8 @@ class TracerUtil(object):
|
||||||
# Block everything by default
|
# Block everything by default
|
||||||
_homeserver_whitelist = None
|
_homeserver_whitelist = None
|
||||||
|
|
||||||
|
tags = _DumTagNames
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def init_tracer(cls, config):
|
def init_tracer(cls, config):
|
||||||
"""Set the whitelists and initialise the JaegerClient tracer
|
"""Set the whitelists and initialise the JaegerClient tracer
|
||||||
|
|
@ -55,7 +89,7 @@ class TracerUtil(object):
|
||||||
return
|
return
|
||||||
|
|
||||||
cls.import_opentracing()
|
cls.import_opentracing()
|
||||||
cls.set_tags()
|
cls.setup_tags()
|
||||||
cls.setup_tracing(config)
|
cls.setup_tracing(config)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
|
@ -71,7 +105,6 @@ class TracerUtil(object):
|
||||||
raise
|
raise
|
||||||
|
|
||||||
cls._opentracing = opentracing
|
cls._opentracing = opentracing
|
||||||
cls.set_tags()
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def setup_tracing(cls, config):
|
def setup_tracing(cls, config):
|
||||||
|
|
@ -96,40 +129,10 @@ class TracerUtil(object):
|
||||||
)
|
)
|
||||||
jaeger_config.initialize_tracer()
|
jaeger_config.initialize_tracer()
|
||||||
|
|
||||||
class Tags(object):
|
|
||||||
"""wrapper of opentracings tags. We need to have them if we
|
|
||||||
want to reference them without opentracing around. Clearly they
|
|
||||||
should never actually show up in a trace. `set_tags` overwrites
|
|
||||||
these with the correct ones."""
|
|
||||||
|
|
||||||
COMPONENT = "invlalid-tag"
|
|
||||||
DATABASE_INSTANCE = "invlalid-tag"
|
|
||||||
DATABASE_STATEMENT = "invlalid-tag"
|
|
||||||
DATABASE_TYPE = "invlalid-tag"
|
|
||||||
DATABASE_USER = "invlalid-tag"
|
|
||||||
ERROR = "invlalid-tag"
|
|
||||||
HTTP_METHOD = "invlalid-tag"
|
|
||||||
HTTP_STATUS_CODE = "invlalid-tag"
|
|
||||||
HTTP_URL = "invlalid-tag"
|
|
||||||
MESSAGE_BUS_DESTINATION = "invlalid-tag"
|
|
||||||
PEER_ADDRESS = "invlalid-tag"
|
|
||||||
PEER_HOSTNAME = "invlalid-tag"
|
|
||||||
PEER_HOST_IPV4 = "invlalid-tag"
|
|
||||||
PEER_HOST_IPV6 = "invlalid-tag"
|
|
||||||
PEER_PORT = "invlalid-tag"
|
|
||||||
PEER_SERVICE = "invlalid-tag"
|
|
||||||
SAMPLING_PRIORITY = "invlalid-tag"
|
|
||||||
SERVICE = "invlalid-tag"
|
|
||||||
SPAN_KIND = "invlalid-tag"
|
|
||||||
SPAN_KIND_CONSUMER = "invlalid-tag"
|
|
||||||
SPAN_KIND_PRODUCER = "invlalid-tag"
|
|
||||||
SPAN_KIND_RPC_CLIENT = "invlalid-tag"
|
|
||||||
SPAN_KIND_RPC_SERVER = "invlalid-tag"
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@only_if_tracing
|
@only_if_tracing
|
||||||
def set_tags(cls):
|
def setup_tags(cls):
|
||||||
cls.Tags = cls._opentracing.tags
|
cls.tags = cls._opentracing.tags
|
||||||
|
|
||||||
# Could use kwargs but I want these to be explicit
|
# Could use kwargs but I want these to be explicit
|
||||||
@classmethod
|
@classmethod
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue