Skip to content
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
16 changes: 15 additions & 1 deletion src/sentry/api/endpoints/organization_spans_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,16 @@
from sentry.tagstore.types import TagKey, TagValue
from sentry.utils import snuba

# This causes problems if a user sends an attribute with any of these values
# but the meta table currently can't handle that anyways
# More users will see the 3 of these since they're on everything so lets try to make
# the common usecase more reasonable
TAG_NAME_MAPPING = {
"segment_name": "transaction",
"name": "span.description",
"service": "project",
}


class OrganizationSpansFieldsEndpointBase(OrganizationEventsV2EndpointBase):
publish_status = {
Expand Down Expand Up @@ -108,7 +118,11 @@ def get(self, request: Request, organization) -> Response:

paginator = ChainPaginator(
[
[TagKey(tag.name) for tag in rpc_response.tags if tag.name],
[
TagKey(TAG_NAME_MAPPING.get(tag.name, tag.name))
for tag in rpc_response.tags
if tag.name
],
],
max_limit=max_span_tags,
)
Expand Down
35 changes: 32 additions & 3 deletions tests/sentry/api/endpoints/test_organization_spans_fields.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from uuid import uuid4

import pytest
from django.urls import reverse

from sentry.testutils.cases import APITestCase, BaseSpansTestCase
Expand Down Expand Up @@ -35,8 +34,6 @@ def test_no_project(self):
assert response.status_code == 200, response.data
assert response.data == []

# shellmayr: https://github.com/getsentry/sentry/actions/runs/10918616180/job/30304486687
@pytest.mark.xfail(reason="test is failing in CI")
def test_tags_list(self):
for tag in ["foo", "bar", "baz"]:
self.store_segment(
Expand Down Expand Up @@ -89,6 +86,38 @@ def do_request(self, query=None, features=None, **kwargs):
**kwargs,
)

def test_tags_list(self):
Copy link
Contributor

Choose a reason for hiding this comment

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

are there two test_tags_list ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah one is inheriting from OrganizationSpansTagsEndpointTest while the other is that class

for tag in ["foo", "bar", "baz"]:
self.store_segment(
self.project.id,
uuid4().hex,
uuid4().hex,
span_id=uuid4().hex[:15],
organization_id=self.organization.id,
parent_span_id=None,
timestamp=before_now(days=0, minutes=10).replace(microsecond=0),
transaction="foo",
duration=100,
exclusive_time=100,
tags={tag: tag},
is_eap=self.is_eap,
)

for features in [
None, # use the default features
["organizations:performance-trace-explorer"],
]:
response = self.do_request(features=features)
assert response.status_code == 200, response.data
assert response.data == [
{"key": "bar", "name": "Bar"},
{"key": "baz", "name": "Baz"},
{"key": "foo", "name": "Foo"},
{"key": "span.description", "name": "Span.Description"},
{"key": "transaction", "name": "Transaction"},
{"key": "project", "name": "Project"},
]


class OrganizationSpansTagKeyValuesEndpointTest(BaseSpansTestCase, APITestCase):
view = "sentry-api-0-organization-spans-fields-values"
Expand Down
Loading