Browse Source

ref(hc): Use distributions for RPC request/response size (#64086)

A few small tweaks:
- Adds a new request size distribution metric
- Fixes the existing response size metric which was previously a gauge
- Now tracks all response sizes, including non-200 responses, matching
the behavior of the response code metric
Matt Duncan 1 year ago
parent
commit
89b3924eba
1 changed files with 10 additions and 5 deletions
  1. 10 5
      src/sentry/services/hybrid_cloud/rpc.py

+ 10 - 5
src/sentry/services/hybrid_cloud/rpc.py

@@ -492,6 +492,11 @@ class _RemoteSiloCall:
             "Authorization": f"Rpcsignature {signature}",
         }
 
+        metrics.distribution(
+            "hybrid_cloud.dispatch_rpc.request_size",
+            len(data),
+            tags=self._metrics_tags(),
+        )
         with self._open_request_context():
             if use_test_client:
                 response = self._fire_test_request(headers, data)
@@ -501,13 +506,13 @@ class _RemoteSiloCall:
                 "hybrid_cloud.dispatch_rpc.response_code",
                 tags=self._metrics_tags(status=response.status_code),
             )
+            metrics.distribution(
+                "hybrid_cloud.dispatch_rpc.response_size",
+                len(response.content),
+                tags=self._metrics_tags(status=response.status_code),
+            )
 
             if response.status_code == 200:
-                metrics.gauge(
-                    "hybrid_cloud.dispatch_rpc.response_size",
-                    len(response.content),
-                    tags=self._metrics_tags(),
-                )
                 return response.json()
             self._raise_from_response_status_error(response)