Skip to content

chore(seer rpc): Simplify RPC call params #91044

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

Merged
merged 2 commits into from
May 6, 2025
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
23 changes: 10 additions & 13 deletions src/sentry/api/endpoints/seer_rpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,14 +225,11 @@ def get_attribute_names(*, org_id: int, project_ids: list[int], stats_period: st
fields_resp = snuba_rpc.attribute_names_rpc(req)

parsed_fields = [
{
"key": as_attribute_key(
attr.name,
"string" if attr_type == AttributeKey.Type.TYPE_STRING else "number",
SupportedTraceItemType.SPANS,
)["key"],
"type": attr_type,
}
as_attribute_key(
attr.name,
"string" if attr_type == AttributeKey.Type.TYPE_STRING else "number",
SupportedTraceItemType.SPANS,
)["key"]
for attr in fields_resp.attributes
if attr.name and can_expose_attribute(attr.name, SupportedTraceItemType.SPANS)
]
Expand All @@ -243,7 +240,7 @@ def get_attribute_names(*, org_id: int, project_ids: list[int], stats_period: st

def get_attribute_values(
*,
fields: list[dict[str, Any]],
fields: list[str],
org_id: int,
project_ids: list[int],
stats_period: str,
Expand Down Expand Up @@ -272,8 +269,8 @@ def get_attribute_values(
)

for field in fields:
if field["type"] == AttributeKey.Type.TYPE_STRING:
resolved_column, _ = resolver.resolve_attribute(field["key"])
resolved_field, _ = resolver.resolve_attribute(field)
if resolved_field.proto_definition.type == AttributeKey.Type.TYPE_STRING:

req = TraceItemAttributeValuesRequest(
meta=RequestMeta(
Expand All @@ -285,12 +282,12 @@ def get_attribute_values(
end_timestamp=end_time_proto,
trace_item_type=TraceItemType.TRACE_ITEM_TYPE_SPAN,
),
key=resolved_column.proto_definition,
key=resolved_field.proto_definition,
limit=limit,
)

values_response = snuba_rpc.attribute_values_rpc(req)
values[field["key"]] = [value for value in values_response.values]
values[field] = [value for value in values_response.values]

return {"values": values}

Expand Down
22 changes: 4 additions & 18 deletions tests/snuba/api/endpoints/test_seer_attributes.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
from uuid import uuid4

from sentry_protos.snuba.v1.trace_item_attribute_pb2 import AttributeKey

from sentry.api.endpoints.seer_rpc import get_attribute_names, get_attribute_values
from sentry.testutils.cases import BaseSpansTestCase
from sentry.testutils.helpers.datetime import before_now
Expand Down Expand Up @@ -36,22 +34,10 @@ def test_get_attribute_names(self):
)
assert result == {
"fields": [
{
"key": "span.description",
"type": AttributeKey.Type.TYPE_STRING,
},
{
"key": "transaction",
"type": AttributeKey.Type.TYPE_STRING,
},
{
"key": "project",
"type": AttributeKey.Type.TYPE_STRING,
},
{
"key": "span.duration",
"type": AttributeKey.Type.TYPE_DOUBLE,
},
"span.description",
"transaction",
"project",
"span.duration",
]
}

Expand Down
Loading