Skip to content
Open
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
4 changes: 2 additions & 2 deletions src/sentry/api/endpoints/organization_spans_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
from sentry.search.eap.resolver import SearchResolver
from sentry.search.eap.spans.definitions import SPAN_DEFINITIONS
from sentry.search.eap.types import SearchResolverConfig, SupportedTraceItemType
from sentry.search.eap.utils import can_expose_attribute, translate_internal_to_public_alias
from sentry.search.eap.utils import can_expose_attribute_to_api, translate_internal_to_public_alias
from sentry.search.events.types import SnubaParams
from sentry.snuba.referrer import Referrer
from sentry.tagstore.types import TagValue
Expand Down Expand Up @@ -125,7 +125,7 @@ def get(self, request: Request, organization: Organization) -> Response:
as_tag_key(attribute.name, serialized["type"])
for attribute in rpc_response.attributes
if attribute.name
and can_expose_attribute(
and can_expose_attribute_to_api(
attribute.name,
SupportedTraceItemType.SPANS,
include_internal=include_internal,
Expand Down
26 changes: 26 additions & 0 deletions tests/sentry/api/endpoints/test_organization_spans_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
from uuid import uuid4

from django.urls import reverse
from sentry_conventions.attributes import ATTRIBUTE_NAMES
from sentry_protos.snuba.v1.endpoint_trace_item_attributes_pb2 import (
TraceItemAttributeNamesResponse,
)
from sentry_protos.snuba.v1.trace_item_attribute_pb2 import AttributeKey

from sentry.exceptions import InvalidSearchQuery
from sentry.testutils.cases import APITestCase, BaseSpansTestCase, SpanTestCase
Expand Down Expand Up @@ -163,6 +168,27 @@ def test_boolean_attributes(self) -> None:
assert "tags[is_debug,boolean]" in keys
assert "tags[is_production,boolean]" in keys

@mock.patch("sentry.api.endpoints.organization_spans_fields.snuba_rpc.attribute_names_rpc")
def test_internal_sentry_convention_attributes_are_hidden(self, mock_attribute_names) -> None:
self.create_span(start_ts=before_now(days=0, minutes=10))
mock_attribute_names.return_value = TraceItemAttributeNamesResponse(
attributes=[
TraceItemAttributeNamesResponse.Attribute(
name="public.attribute",
type=AttributeKey.Type.TYPE_STRING,
),
TraceItemAttributeNamesResponse.Attribute(
name=ATTRIBUTE_NAMES.SENTRY_DSC_ENVIRONMENT,
type=AttributeKey.Type.TYPE_STRING,
),
]
)

response = self.do_request()

assert response.status_code == 200, response.data
assert response.data == [{"key": "public.attribute", "name": "public.attribute"}]


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