ref(resolvers): inline the trace item stats resolver - #8452
Open
MeredithAnya wants to merge 1 commit into
Open
Conversation
This was referenced Sep 9, 2026
MeredithAnya
added this pull request to stack #8456
September 9, 2026 23:52
pbhandari
approved these changes
Sep 10, 2026
pbhandari
reviewed
Sep 10, 2026
Comment on lines
+328
to
+354
| if requested_type.attribute_distributions.max_buckets > MAX_BUCKETS: | ||
| raise BadSnubaRPCRequestException(f"Max allowed buckets is {MAX_BUCKETS}.") | ||
|
|
||
| if len(requested_type.attribute_distributions.attributes) > MAX_REQUEST_ATTRIBUTES: | ||
| raise BadSnubaRPCRequestException( | ||
| f"Max allowed attributes is {MAX_REQUEST_ATTRIBUTES}." | ||
| ) | ||
|
|
||
| query = _build_attr_distribution_query( | ||
| in_msg, requested_type.attribute_distributions | ||
| ) | ||
| treeify_or_and_conditions(query) | ||
|
|
||
| snuba_request = _build_snuba_request(in_msg, query, routing_decision) | ||
| query_res = run_query( | ||
| dataset=PluggableDataset(name="eap", all_entities=[]), | ||
| request=snuba_request, | ||
| timer=self._timer, | ||
| ) | ||
| routing_decision.routing_context.query_result = query_res | ||
|
|
||
| attributes = _transform_attr_distribution_results( | ||
| query_res.result.get("data", []), in_msg.meta | ||
| ) | ||
| result.attribute_distributions.CopyFrom( | ||
| AttributeDistributions(attributes=attributes) | ||
| ) |
Contributor
There was a problem hiding this comment.
[non-blocking] I see we have a HeatmapBuilder already, how hard would it be to create/reuse a AttributeDistributionBuilder and keep the pattern between the two branches the same (i.e. foo = xxxBuilder(...).build(); result.blah.copyFrom(foo)?
I'd prefer if we could do that, but if it's not feasible I'm happy with just a TODO comment in here.
ResolverTraceItemStatsEAPItems was the only implementation of ResolverTraceItemStats, registered under TRACE_ITEM_TYPE_UNSPECIFIED, so get_from_trace_item_type could only ever return it. Move the resolver module body into endpoint_trace_item_stats.py and turn resolve() into _query_trace_item_stats, following the EndpointGetTrace conversion in 76d1fed. The seer.rpc tier downgrade still runs before the query is built. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
MeredithAnya
force-pushed
the
meredith/convert-resolver-stats
branch
from
September 10, 2026 19:50
9baa107 to
ae638ef
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stack
ref(resolvers): remove unused resolver declarationsref(resolvers): inline the trace item stats resolverref(resolvers): inline the time series resolverref(resolvers): inline the trace item table resolverref(resolvers): remove the TraceItemDataResolver abstractionWhy
TraceItemDataResolverexists to dispatch an endpoint to a different query implementation perTraceItemType— one for spans, one for logs, one for uptime checks. Those are all gone (76d1fed8f,cfaaad94d,0077ce42f).ResolverTraceItemStatsEAPItemswas the only implementation ofResolverTraceItemStats, registered underTRACE_ITEM_TYPE_UNSPECIFIED, soget_from_trace_item_typecould only ever return it.What
Moves the resolver module body into
endpoint_trace_item_stats.pyand turnsresolve()into_query_trace_item_stats, following theEndpointGetTraceconversion in76d1fed8f. Pure move — no logic changes.resolve()tookrouting_decisionas a parameter; the method now readsself.routing_decision, whichRPCEndpointsets before_executeruns. Theseer.rpctier downgrade still happens before the query is built.Tests
Import/patch-target updates only, no logic changes.
pytest tests/web/rpc/v1/test_endpoint_trace_item_stats.pyandtest_storage_routing.pypass;mypy snuba/web/rpc/clean.🤖 Generated with Claude Code