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

perf(trace-explorer): Service Entry spans always have group 0 #72817

Merged
merged 3 commits into from
Jun 17, 2024
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
11 changes: 9 additions & 2 deletions src/sentry/api/endpoints/organization_traces.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
SpansIndexedQueryBuilder,
TimeseriesSpanIndexedQueryBuilder,
)
from sentry.search.events.constants import TIMEOUT_SPAN_ERROR_MESSAGE
from sentry.search.events.constants import TIMEOUT_SPAN_ERROR_MESSAGE, UNCLASSIFIED_SPAN_GROUP
from sentry.search.events.types import ParamsType, QueryBuilderConfig, SnubaParams, WhereType
from sentry.sentry_metrics.querying.samples_list import SpanKey, get_sample_list_executor_cls
from sentry.services.hybrid_cloud.organization import RpcOrganization
Expand Down Expand Up @@ -854,11 +854,18 @@ def get_traces_breakdown_projects_query(
) -> QueryBuilder:
trace_ids_str = ",".join(trace_ids)
trace_ids_condition = f"trace:[{trace_ids_str}]"
query = " ".join(
[
"is_transaction:1", # service entry spans
f"group:{UNCLASSIFIED_SPAN_GROUP}", # service entry spans do not have a group
trace_ids_condition,
],
)
return SpansIndexedQueryBuilder(
Dataset.SpansIndexed,
params,
snuba_params=snuba_params,
query=f"is_transaction:1 {trace_ids_condition}",
query=query,
selected_columns=[
"trace",
"project",
Expand Down
3 changes: 3 additions & 0 deletions src/sentry/search/events/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@
SPAN_DESCRIPTION = "span.description"
SPAN_STATUS = "span.status"

# Not all spans get a group assigned to it. Unassigned ones has a default of 0.
UNCLASSIFIED_SPAN_GROUP = "00"


class ThresholdDict(TypedDict):
poor: float
Expand Down
3 changes: 2 additions & 1 deletion src/sentry/sentry_metrics/querying/samples_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
QueryBuilder,
SpansIndexedQueryBuilder,
)
from sentry.search.events.constants import UNCLASSIFIED_SPAN_GROUP
from sentry.search.events.types import ParamsType, QueryBuilderConfig, SelectType, SnubaParams
from sentry.snuba.dataset import Dataset
from sentry.snuba.metrics.naming_layer.mri import (
Expand Down Expand Up @@ -277,7 +278,7 @@ def get_matching_spans_from_traces(

return [
SpanKey(
group="00", # all segments have a group of `00` currently
group=UNCLASSIFIED_SPAN_GROUP,
timestamp=row["timestamp"],
span_id=row["span_id"],
)
Expand Down
Loading