From 2cbf8813fd6dedddef633735b0563aff2a5e8f67 Mon Sep 17 00:00:00 2001 From: Shruthi Date: Mon, 19 Aug 2024 11:50:58 -0400 Subject: [PATCH] feat: disable span description clustering (#76383) We're making a lot of redis calls here https://sentry.my.sentry.io/organizations/sentry/performance/trace/2f1fea0659264706bc0f2b4d6807908f/?dataset=transactions&field=title&field=project&field=timestamp&field=transaction.duration&name=All+Errors&node=span-9f7db12a2da2ae00&node=txn-09cd48a7d61d4b8db3cfeb07e4c202a9&query=server_name%3Agetsentry-worker-postprocess-transactions%2A&queryDataset=transaction-like&sort=-transaction.duration&source=discover&statsPeriod=24h×tamp=1724066865&yAxis=count%28%29 might be hitting resource limits on redis instance --- src/sentry/features/temporary.py | 1 + .../transaction_clusterer/datasource/redis.py | 4 ++++ tests/sentry/ingest/test_span_desc_clusterer.py | 13 ++++++++----- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/sentry/features/temporary.py b/src/sentry/features/temporary.py index 9940a06dba5bd9..6e19d0fb62a9b6 100644 --- a/src/sentry/features/temporary.py +++ b/src/sentry/features/temporary.py @@ -546,6 +546,7 @@ def register_temporary_features(manager: FeatureManager): manager.add("projects:relay-otel-endpoint", ProjectFeature, FeatureHandlerStrategy.OPTIONS, api_expose=False) # EAP: extremely experimental flag that makes DDM page use EAP tables manager.add("projects:use-eap-spans-for-metrics-explorer", ProjectFeature, FeatureHandlerStrategy.FLAGPOLE, api_expose=False) + manager.add("projects:record-span-descriptions", ProjectFeature, FeatureHandlerStrategy.FLAGPOLE, api_expose=True) # Project plugin features manager.add("projects:plugins", ProjectPluginFeature, FeatureHandlerStrategy.INTERNAL, default=True, api_expose=True) diff --git a/src/sentry/ingest/transaction_clusterer/datasource/redis.py b/src/sentry/ingest/transaction_clusterer/datasource/redis.py index c3440a534e186c..4304a61c200f6e 100644 --- a/src/sentry/ingest/transaction_clusterer/datasource/redis.py +++ b/src/sentry/ingest/transaction_clusterer/datasource/redis.py @@ -1,4 +1,5 @@ """ Write transactions into redis sets """ + import logging from collections.abc import Iterator, Mapping from typing import Any @@ -184,6 +185,9 @@ def record_span_descriptions( if not features.has("projects:span-metrics-extraction", project): return + if not features.has("projects:record-span-descriptions", project): + return + spans = event_data.get("spans", []) for span in spans: description = _get_span_description_to_store(span) diff --git a/tests/sentry/ingest/test_span_desc_clusterer.py b/tests/sentry/ingest/test_span_desc_clusterer.py index f96db0daf17e16..2a2eec645e18fb 100644 --- a/tests/sentry/ingest/test_span_desc_clusterer.py +++ b/tests/sentry/ingest/test_span_desc_clusterer.py @@ -83,6 +83,7 @@ def test_record_span_desc_url(mocked_record, default_organization): with Feature( { "projects:span-metrics-extraction": True, + "projects:record-span-descriptions": True, } ): project = Project(id=111, name="project", organization_id=default_organization.id) @@ -241,9 +242,10 @@ def _add_mock_data(proj, number): # Add a transaction to project2 so it runs again _record_sample(ClustererNamespace.SPANS, project2, "foo") - with mock.patch( - "sentry.ingest.transaction_clusterer.tasks.PROJECTS_PER_TASK", 1 - ), freeze_time("2000-01-01 01:00:01"): + with ( + mock.patch("sentry.ingest.transaction_clusterer.tasks.PROJECTS_PER_TASK", 1), + freeze_time("2000-01-01 01:00:01"), + ): spawn_clusterers_span_descs() # One project per batch now: @@ -299,8 +301,9 @@ def test_get_deleted_project(): @django_db_all def test_record_span_descriptions_no_databag(default_organization): """Verify a `None` databag doesn't break the span description clusterer.""" - with Feature("projects:span-metrics-extraction"), override_options( - {"span_descs.bump-lifetime-sample-rate": 1.0} + with ( + Feature("projects:span-metrics-extraction"), + override_options({"span_descs.bump-lifetime-sample-rate": 1.0}), ): payload = { "spans": [