diff --git a/src/sentry/utils/snuba.py b/src/sentry/utils/snuba.py index 8149fb35f22e9f..ce99cd27e89123 100644 --- a/src/sentry/utils/snuba.py +++ b/src/sentry/utils/snuba.py @@ -11,6 +11,7 @@ import six import time import urllib3 +import sentry_sdk from concurrent.futures import ThreadPoolExecutor from django.conf import settings @@ -724,13 +725,16 @@ def snuba_query(params): query_params, forward, reverse = params try: with timer("snuba_query"): - return ( - _snuba_pool.urlopen( - "POST", "/query", body=json.dumps(query_params), headers=headers - ), - forward, - reverse, - ) + body = json.dumps(query_params) + with sentry_sdk.start_span( + op="snuba", description=u"query {}".format(body) + ) as span: + span.set_tag("referrer", headers.get("referer", "")) + return ( + _snuba_pool.urlopen("POST", "/query", body=body, headers=headers), + forward, + reverse, + ) except urllib3.exceptions.HTTPError as err: raise SnubaError(err)