Skip to content

Commit

Permalink
Add integrations metrics production.
Browse files Browse the repository at this point in the history
  • Loading branch information
James Cunningham committed May 28, 2019
1 parent 294f9a0 commit e65aff3
Showing 1 changed file with 27 additions and 14 deletions.
41 changes: 27 additions & 14 deletions src/sentry/integrations/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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,
Expand All @@ -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
Expand Down

0 comments on commit e65aff3

Please sign in to comment.