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

misc(metrics): First pass at un-sampled single metric paths. #13434

Merged
merged 2 commits into from
May 29, 2019
Merged
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
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,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@markstory: I changed this tag from host to integration because host is a protected tag that we apply at the machine-level.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good. I'll update the related dashboads/monitors when this ships.

'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
2 changes: 1 addition & 1 deletion src/sentry/runner/commands/cleanup.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ def is_filtered(model):

if timed:
duration = int(time.time() - start_time)
metrics.timing('cleanup.duration', duration, instance=router)
metrics.timing('cleanup.duration', duration, instance=router, sample_rate=1.0)
click.echo("Clean up took %s second(s)." % duration)


Expand Down
21 changes: 18 additions & 3 deletions src/sentry/web/frontend/auth_login.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,12 @@ def handle_basic_auth(self, request, organization=None, *args, **kwargs):
login_form.errors['__all__'] = [
u'You have made too many login attempts. Please try again later.'
]
metrics.incr('login.attempt', instance='rate_limited', skip_internal=True)
metrics.incr(
'login.attempt',
instance='rate_limited',
skip_internal=True,
sample_rate=1.0
)
elif login_form.is_valid():
user = login_form.get_user()

Expand All @@ -160,14 +165,24 @@ def handle_basic_auth(self, request, organization=None, *args, **kwargs):
user,
organization_id=organization.id if organization else None,
)
metrics.incr('login.attempt', instance='success', skip_internal=True)
metrics.incr(
'login.attempt',
instance='success',
skip_internal=True,
sample_rate=1.0
)

if not user.is_active:
return self.redirect(reverse('sentry-reactivate-account'))

return self.redirect(auth.get_login_redirect(request))
else:
metrics.incr('login.attempt', instance='failure', skip_internal=True)
metrics.incr(
'login.attempt',
instance='failure',
skip_internal=True,
sample_rate=1.0
)

context = {
'op': op or 'login',
Expand Down