From e65aff391f479351b1f3f96104b661a9b97d8ef7 Mon Sep 17 00:00:00 2001 From: James Cunningham Date: Tue, 28 May 2019 15:30:35 -0700 Subject: [PATCH] Add integrations metrics production. --- src/sentry/integrations/client.py | 41 ++++++++++++++++++++----------- 1 file changed, 27 insertions(+), 14 deletions(-) diff --git a/src/sentry/integrations/client.py b/src/sentry/integrations/client.py index 565cf38b68c59b..1aeb188a4cb8e3 100644 --- a/src/sentry/integrations/client.py +++ b/src/sentry/integrations/client.py @@ -114,11 +114,14 @@ def json(self): return self -def track_response_code(host, code): - metrics.incr('integrations.http_response', tags={ - 'host': host, - 'status': code - }) +def track_response_code(integration, code): + metrics.incr( + 'integrations.http_response', + sample_rate=1.0, + tags={ + 'integration': integration, + 'status': code + }) class ApiClient(object): @@ -162,7 +165,11 @@ def _request(self, method, path, headers=None, data=None, params=None, full_url = self.build_url(path) session = build_session() - metrics.incr('integrations.http_request', tags={'integration': self.integration_name}) + metrics.incr( + 'integrations.http_request', + sample_rate=1.0, + tags={'integration': self.integration_name} + ) try: resp = getattr(session, method.lower())( url=full_url, @@ -177,16 +184,22 @@ def _request(self, method, path, headers=None, data=None, params=None, ) resp.raise_for_status() except ConnectionError as e: - metrics.incr('integrations.http_response', tags={ - 'integration': self.integration_name, - 'status': 'connection_error' - }) + metrics.incr( + 'integrations.http_response', + sample_rate=1.0, + tags={ + 'integration': self.integration_name, + 'status': 'connection_error' + }) raise ApiHostError.from_exception(e) except Timeout as e: - metrics.incr('integrations.http_response', tags={ - 'integration': self.integration_name, - 'status': 'timeout' - }) + metrics.incr( + 'integrations.http_response', + sample_rate=1.0, + tags={ + 'integration': self.integration_name, + 'status': 'timeout' + }) raise ApiTimeoutError.from_exception(e) except HTTPError as e: resp = e.response