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

fix(discover) Move http_method and http_referer to common fields #1293

Merged
merged 5 commits into from Sep 8, 2020
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions snuba/datasets/discover.py
Expand Up @@ -291,6 +291,8 @@ def __init__(self) -> None:
("geo_country_code", Nullable(String())),
("geo_region", Nullable(String())),
("geo_city", Nullable(String())),
("http_method", Nullable(String())),
("http_referer", Nullable(String())),
# Other tags and context
("tags", Nested([("key", String()), ("value", String())])),
("contexts", Nested([("key", String()), ("value", String())])),
Expand All @@ -313,8 +315,6 @@ def __init__(self) -> None:
("received", Nullable(DateTime())),
("sdk_integrations", Nullable(Array(String()))),
("version", Nullable(String())),
("http_method", Nullable(String())),
("http_referer", Nullable(String())),
# exception interface
(
"exception_stacks",
Expand Down
14 changes: 14 additions & 0 deletions tests/fixtures.py
Expand Up @@ -18,6 +18,19 @@
"name": "sentry-java",
"version": "1.6.1-d1e3a",
},
"request": {
"url": "http://127.0.0.1:/query",
"headers": [
["Accept-Encoding", "identity"],
["Content-Length", "398"],
["Host", "127.0.0.1:"],
["Referer", "tagstore.something"],
["Trace", "8fa73032d-1"],
],
"data": "",
"method": "POST",
"env": {"SERVER_PORT": "1010", "SERVER_NAME": "snuba"},
},
"contexts": {"device": {"online": True, "charging": True, "model_id": "Galaxy"}},
"sentry.interfaces.Exception": {
"exc_omitted": None,
Expand Down Expand Up @@ -102,6 +115,7 @@
["server_name", "localhost.localdomain"],
["level", "error"],
["custom_tag", "custom_value"],
["url", "http://127.0.0.1:/query"],
],
"time_spent": None,
"type": "error",
Expand Down
63 changes: 63 additions & 0 deletions tests/test_discover_api.py
Expand Up @@ -67,6 +67,7 @@ def generate_transaction(self):
"environment": u"prød",
"sentry:release": "1",
"sentry:dist": "dist1",
"url": "http://127.0.0.1:/query",
# User
"foo": "baz",
"foo.bar": "qux",
Expand Down Expand Up @@ -98,6 +99,19 @@ def generate_transaction(self):
"version": "0.13.4",
"integrations": ["django"],
},
"request": {
"url": "http://127.0.0.1:/query",
"headers": [
["Accept-Encoding", "identity"],
["Content-Length", "398"],
["Host", "127.0.0.1:"],
["Referer", "tagstore.something"],
["Trace", "8fa73032d-1"],
],
"data": "",
"method": "POST",
"env": {"SERVER_PORT": "1010", "SERVER_NAME": "snuba"},
},
"spans": [
{
"op": "db",
Expand Down Expand Up @@ -539,6 +553,55 @@ def test_os_fields_condition(self):
data = json.loads(response.data)
assert data["data"] == [{"count": 0}]

def test_http_fields(self):
response = self.app.post(
"/query",
data=json.dumps(
{
"dataset": "discover",
"project": self.project_id,
"aggregations": [["count()", "", "count"]],
"conditions": [["duration", ">=", 0]],
"groupby": ["http_method", "http_referer", "tags[url]"],
"limit": 1000,
}
),
)
assert response.status_code == 200
data = json.loads(response.data)
assert data["data"] == [
{
"http_method": "POST",
"http_referer": "tagstore.something",
"tags[url]": "http://127.0.0.1:/query",
"count": 1,
}
]

response = self.app.post(
"/query",
data=json.dumps(
{
"dataset": "discover",
"project": self.project_id,
"aggregations": [["count()", "", "count"]],
"conditions": [["group_id", ">=", 0]],
"groupby": ["http_method", "http_referer", "tags[url]"],
"limit": 1000,
}
),
)
assert response.status_code == 200
data = json.loads(response.data)
assert data["data"] == [
{
"http_method": "POST",
"http_referer": "tagstore.something",
"tags[url]": "http://127.0.0.1:/query",
"count": 1,
}
]

def test_device_fields_condition(self):
response = self.app.post(
"/query",
Expand Down