Skip to content
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

[PATCH] EB-203604: Adds metrics for origin and destination in message. #274

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1124,6 +1124,8 @@ These are all the metrics recorded in PySOA:
``sentinel_failover_retries`` is enabled)
- ``server.transport.redis_gateway.send``: A timer indicating how long it takes the Redis Gateway server transport to
send a response
- ``server.transport.redis_gateway.send_context``: A counter with fields ``from`` and ``to`` detailing origin and
destination of the response, for usage instrumentation.
- ``server.transport.redis_gateway.send.message_size``: A histogram indicating the total size of the response sent
back to the client.
- ``server.transport.redis_gateway.send.error.missing_reply_queue``: A counter incremented each time the Redis Gateway
Expand Down Expand Up @@ -1152,6 +1154,8 @@ These are all the metrics recorded in PySOA:
encounters an unknown error (logged) sending a message
- ``server.transport.redis_gateway.receive``: A timer indicating how long it takes the Redis Gateway server transport
to receive a response (however, this includes time waiting for an incoming request, so it may not be meaningful)
- ``server.transport.redis_gateway.receive_context``: A counter with fields ``from`` and ``to`` indicating the origin
and destination of it, for usage instrumentation.
- ``server.transport.redis_gateway.receive.get_redis_connection``: A timer indicating how long it takes the Redis
Gateway transport to get a connection to the Redis cluster or sentinel
- ``server.transport.redis_gateway.receive.pop_from_redis_queue``: A timer indicating how long it takes the Redis
Expand Down
14 changes: 13 additions & 1 deletion pysoa/common/transport/redis_gateway/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,21 @@ def receive_request_message(self):
timer = self.metrics.timer('server.transport.redis_gateway.receive', resolution=TimerResolution.MICROSECONDS)
timer.start()
stop_timer = True
message = None
try:
return self.core.receive_message(self._receive_queue_name)
message = self.core.receive_message(self._receive_queue_name)
except MessageReceiveTimeout:
stop_timer = False
raise
finally:
if stop_timer:
timer.stop()
if message:
self.metrics.counter('server.transport.redis_gateway.receive_context', tags={
'from': message.meta['reply_to'],
'to': self.service_name,
}).increment()
return message

def send_response_message(self, request_id, meta, body):
# type: (int, Dict[six.text_type, Any], Dict[six.text_type, Any]) -> None
Expand All @@ -69,3 +76,8 @@ def send_response_message(self, request_id, meta, body):

with self.metrics.timer('server.transport.redis_gateway.send', resolution=TimerResolution.MICROSECONDS):
self.core.send_message(queue_name, request_id, meta, body)

self.metrics.counter('server.transport.redis_gateway.send_context', tags={
'from': self.service_name,
'to': queue_name,
}).increment()