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

ref(metrics): Remove extrapolation code #76780

Merged
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: 0 additions & 23 deletions src/sentry/api/endpoints/organization_details.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
DATA_CONSENT_DEFAULT,
DEBUG_FILES_ROLE_DEFAULT,
EVENTS_MEMBER_ADMIN_DEFAULT,
EXTRAPOLATE_METRICS_DEFAULT,
GITHUB_COMMENT_BOT_DEFAULT,
ISSUE_ALERTS_THREAD_DEFAULT,
JOIN_REQUESTS_DEFAULT,
Expand Down Expand Up @@ -217,7 +216,6 @@
bool,
METRICS_ACTIVATE_LAST_FOR_GAUGES_DEFAULT,
),
("extrapolateMetrics", "sentry:extrapolate_metrics", bool, EXTRAPOLATE_METRICS_DEFAULT),
("uptimeAutodetection", "sentry:uptime_autodetection", bool, UPTIME_AUTODETECTION),
)

Expand Down Expand Up @@ -280,7 +278,6 @@ class OrganizationSerializer(BaseOrganizationSerializer):
allowJoinRequests = serializers.BooleanField(required=False)
relayPiiConfig = serializers.CharField(required=False, allow_blank=True, allow_null=True)
apdexThreshold = serializers.IntegerField(min_value=1, required=False)
extrapolateMetrics = serializers.BooleanField(required=False)
uptimeAutodetection = serializers.BooleanField(required=False)

@cached_property
Expand All @@ -295,24 +292,6 @@ def _has_sso_enabled(self):
org_auth_provider = auth_service.get_auth_provider(organization_id=org.id)
return org_auth_provider is not None

def validate_extrapolateMetrics(self, value):
from sentry import features

organization = self.context["organization"]
request = self.context["request"]

# Metrics extrapolation can only be toggled when the metrics-extrapolation flag is enabled.
has_metrics_extrapolation = features.has(
"organizations:metrics-extrapolation", organization, actor=request.user
)

if not has_metrics_extrapolation:
raise serializers.ValidationError(
"Organization does not have the metrics extrapolation feature enabled"
)
else:
return value

def validate_relayPiiConfig(self, value):
organization = self.context["organization"]
return validate_pii_config_update(organization, value)
Expand Down Expand Up @@ -626,7 +605,6 @@ def post_org_pending_deletion(
"genAIConsent",
"metricsActivatePercentiles",
"metricsActivateLastForGauges",
"extrapolateMetrics",
]
)
class OrganizationDetailsPutSerializer(serializers.Serializer):
Expand Down Expand Up @@ -838,7 +816,6 @@ class OrganizationDetailsPutSerializer(serializers.Serializer):
genAIConsent = serializers.BooleanField(required=False)
metricsActivatePercentiles = serializers.BooleanField(required=False)
metricsActivateLastForGauges = serializers.BooleanField(required=False)
extrapolateMetrics = serializers.BooleanField(required=False)


# NOTE: We override the permission class of this endpoint in getsentry with the OrganizationDetailsPermission class
Expand Down
26 changes: 0 additions & 26 deletions src/sentry/api/endpoints/project_details.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ class ProjectMemberSerializer(serializers.Serializer):
"performanceIssueSendToPlatform",
"highlightContext",
"highlightTags",
"extrapolateMetrics",
"uptimeAutodetection",
]
)
Expand Down Expand Up @@ -216,7 +215,6 @@ class ProjectAdminSerializer(ProjectMemberSerializer):
performanceIssueCreationRate = serializers.FloatField(required=False, min_value=0, max_value=1)
performanceIssueCreationThroughPlatform = serializers.BooleanField(required=False)
performanceIssueSendToPlatform = serializers.BooleanField(required=False)
extrapolateMetrics = serializers.BooleanField(required=False)
uptimeAutodetection = serializers.BooleanField(required=False)

# DO NOT ADD MORE TO OPTIONS
Expand Down Expand Up @@ -245,22 +243,6 @@ def validate(self, data):

return data

def validate_extrapolateMetrics(self, value):
organization = self.context["project"].organization
request = self.context["request"]

# Metrics extrapolation can only be toggled when the metrics-extrapolation flag is enabled.
has_metrics_extrapolation = features.has(
"organizations:metrics-extrapolation", organization, actor=request.user
)

if not has_metrics_extrapolation:
raise serializers.ValidationError(
"Organization does not have the metrics extrapolation feature enabled"
)
else:
return value

def validate_allowedDomains(self, value):
value = list(filter(bool, value))
if len(value) == 0:
Expand Down Expand Up @@ -757,10 +739,6 @@ def put(self, request: Request, project) -> Response:
"dynamicSamplingBiases"
]

if "extrapolateMetrics" in result:
if project.update_option("sentry:extrapolate_metrics", result["extrapolateMetrics"]):
changed_proj_settings["sentry:extrapolate_metrics"] = result["extrapolateMetrics"]

if result.get("uptimeAutodetection") is not None:
if project.update_option("sentry:uptime_autodetection", result["uptimeAutodetection"]):
changed_proj_settings["sentry:uptime_autodetection"] = result["uptimeAutodetection"]
Expand Down Expand Up @@ -905,10 +883,6 @@ def put(self, request: Request, project) -> Response:
data = serialize(project, request.user, DetailedProjectSerializer())
return Response(data)

if "sentry:extrapolate_metrics" in options:
project.update_option(
"sentry:extrapolate_metrics", bool(options["sentry:extrapolate_metrics"])
)
if "sentry:uptime_autodetection" in options:
project.update_option(
"sentry:uptime_autodetection", bool(options["sentry:uptime_autodetection"])
Expand Down
8 changes: 0 additions & 8 deletions src/sentry/api/serializers/models/organization.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
DATA_CONSENT_DEFAULT,
DEBUG_FILES_ROLE_DEFAULT,
EVENTS_MEMBER_ADMIN_DEFAULT,
EXTRAPOLATE_METRICS_DEFAULT,
GITHUB_COMMENT_BOT_DEFAULT,
ISSUE_ALERTS_THREAD_DEFAULT,
JOIN_REQUESTS_DEFAULT,
Expand Down Expand Up @@ -471,7 +470,6 @@ class DetailedOrganizationSerializerResponse(_DetailedOrganizationSerializerResp
metricAlertsThreadFlag: bool
metricsActivatePercentiles: bool
metricsActivateLastForGauges: bool
extrapolateMetrics: bool
requiresSso: bool


Expand Down Expand Up @@ -614,11 +612,6 @@ def serialize( # type: ignore[explicit-override, override]
}
)

if features.has("organizations:metrics-extrapolation", obj):
context["extrapolateMetrics"] = bool(
obj.get_option("sentry:extrapolate_metrics", EXTRAPOLATE_METRICS_DEFAULT)
)

if features.has("organizations:uptime-settings", obj):
context["uptimeAutodetection"] = bool(
obj.get_option("sentry:uptime_autodetection", UPTIME_AUTODETECTION)
Expand Down Expand Up @@ -666,7 +659,6 @@ def serialize( # type: ignore[explicit-override, override]
"genAIConsent",
"metricsActivatePercentiles",
"metricsActivateLastForGauges",
"extrapolateMetrics",
"quota",
]
)
Expand Down
10 changes: 0 additions & 10 deletions src/sentry/api/serializers/models/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -901,7 +901,6 @@ class DetailedProjectResponse(ProjectWithTeamResponseDict):
dynamicSamplingBiases: list[dict[str, str | bool]]
eventProcessing: dict[str, bool]
symbolSources: str
extrapolateMetrics: bool
uptimeAutodetection: bool


Expand Down Expand Up @@ -1022,15 +1021,6 @@ def serialize(
}
)

if features.has("organizations:metrics-extrapolation", obj.organization):
data.update(
{
"extrapolateMetrics": bool(
attrs["options"].get("sentry:extrapolate_metrics", False)
)
}
)

if features.has("organizations:uptime-settings", obj.organization):
data.update(
{
Expand Down
1 change: 0 additions & 1 deletion src/sentry/apidocs/examples/project_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,6 @@
"dataScrubberDefaults": False,
"safeFields": [],
"storeCrashReports": 5,
"extrapolateMetrics": True,
"sensitiveFields": ["sudo"],
"subjectTemplate": "$shortID - $title",
"securityToken": "e84c8c0fb1c121e988558785885f9cde",
Expand Down
1 change: 0 additions & 1 deletion src/sentry/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,6 @@ class InsightModules(Enum):
METRICS_ACTIVATE_PERCENTILES_DEFAULT = True
METRICS_ACTIVATE_LAST_FOR_GAUGES_DEFAULT = False
DATA_CONSENT_DEFAULT = False
EXTRAPOLATE_METRICS_DEFAULT = False
UPTIME_AUTODETECTION = True

# `sentry:events_member_admin` - controls whether the 'member' role gets the event:admin scope
Expand Down
2 changes: 0 additions & 2 deletions src/sentry/features/temporary.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,6 @@ def register_temporary_features(manager: FeatureManager):
manager.add("organizations:default-metric-alerts-new-projects", OrganizationFeature, FeatureHandlerStrategy.FLAGPOLE, api_expose=True)
manager.add("organizations:devtoolbar", OrganizationFeature, FeatureHandlerStrategy.FLAGPOLE, default=False, api_expose=True)
manager.add("organizations:email-performance-regression-image", OrganizationFeature, FeatureHandlerStrategy.OPTIONS, api_expose=False)
# Enables metrics extrapolation feature
manager.add("organizations:metrics-extrapolation", OrganizationFeature, FeatureHandlerStrategy.FLAGPOLE, api_expose=True)
# Enables automatically deriving of code mappings
manager.add("organizations:derive-code-mappings", OrganizationFeature, FeatureHandlerStrategy.INTERNAL, default=True)
# Enables synthesis of device.class in ingest
Expand Down
1 change: 0 additions & 1 deletion src/sentry/models/options/project_option.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@
"sentry:dynamic_sampling_biases",
"sentry:breakdowns",
"sentry:transaction_name_cluster_rules",
"sentry:extrapolate_metrics",
"sentry:uptime_autodetection",
"quotas:spike-protection-disabled",
"feedback:branding",
Expand Down
30 changes: 0 additions & 30 deletions src/sentry/options/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -1477,36 +1477,6 @@
flags=FLAG_AUTOMATOR_MODIFIABLE,
)

# Enables extrapolation on the `transactions` namespace.
register(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Either remove these in a separate PR, or ensure that https://github.com/getsentry/sentry-options-automator/pull/2199 is merged and applied before this PR.

"sentry-metrics.extrapolation.enable_transactions",
default=False,
flags=FLAG_AUTOMATOR_MODIFIABLE,
)

# Enables extrapolation on the `spans` namespace.
register(
"sentry-metrics.extrapolation.enable_spans",
default=False,
flags=FLAG_AUTOMATOR_MODIFIABLE,
)

# Maximum duplication factor for ingest-time extrapolation of distribution
# values in Relay. Obsolete once `.propagate-rates` is the default.
register(
"sentry-metrics.extrapolation.duplication-limit",
default=0,
flags=FLAG_AUTOMATOR_MODIFIABLE,
)

# Send sample rates for metrics from Relay via the indexer into snuba rather
# than extrapolating at ingest time.
register(
"sentry-metrics.extrapolation.propagate-rates",
default=False,
flags=FLAG_AUTOMATOR_MODIFIABLE,
)

# Performance issue option for *all* performance issues detection
register("performance.issues.all.problem-detection", default=1.0, flags=FLAG_AUTOMATOR_MODIFIABLE)

Expand Down
43 changes: 0 additions & 43 deletions src/sentry/relay/config/metric_extraction.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,17 +72,11 @@ class HighCardinalityWidgetException(Exception):
pass


class MetricExtrapolationConfig(TypedDict):
include: NotRequired[list[str]]
exclude: NotRequired[list[str]]


class MetricExtractionConfig(TypedDict):
"""Configuration for generic extraction of metrics from all data categories."""

version: int
metrics: list[MetricSpec]
extrapolate: NotRequired[MetricExtrapolationConfig]


def get_max_widget_specs(organization: Organization) -> int:
Expand Down Expand Up @@ -114,8 +108,6 @@ def get_metric_extraction_config(project: Project) -> MetricExtractionConfig | N
) or ([], [])
with sentry_sdk.start_span(op="merge_metric_specs"):
metric_specs = _merge_metric_specs(alert_specs, widget_specs)
with sentry_sdk.start_span(op="get_extrapolation_config"):
extrapolation_config = get_extrapolation_config(project)

if not metric_specs:
return None
Expand All @@ -125,44 +117,9 @@ def get_metric_extraction_config(project: Project) -> MetricExtractionConfig | N
"metrics": metric_specs,
}

if extrapolation_config:
rv["extrapolate"] = extrapolation_config

return rv


def get_extrapolation_config(project: Project) -> MetricExtrapolationConfig | None:
if not features.has("organizations:metrics-extrapolation", project.organization):
return None

enabled = project.get_option("sentry:extrapolate_metrics", None)
if enabled is None:
enabled = project.organization.get_option("sentry:extrapolate_metrics", False)
if not enabled:
return None

# Extrapolation applies to extracted metrics. This enables extrapolation for
# the entire `custom` namespace, but this does not extrapolate old custom
# metrics sent from the SDK directly.
config: MetricExtrapolationConfig = {
"include": ["?:custom/*"],
"exclude": [],
}

if options.get("sentry-metrics.extrapolation.enable_transactions"):
config["include"] += ["?:transactions/*"]
config["exclude"] += [
"c:transactions/usage@none", # stats
"c:transactions/count_per_root_project@none", # dynamic sampling
]

if options.get("sentry-metrics.extrapolation.enable_spans"):
config["include"] += ["?:spans/*"]
config["exclude"] += ["c:spans/usage@none"] # stats

return config


def get_on_demand_metric_specs(
timeout: TimeChecker, project: Project
) -> tuple[list[HashedMetricSpec], list[HashedMetricSpec]]:
Expand Down
2 changes: 0 additions & 2 deletions src/sentry/relay/globalconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@
"relay.metric-stats.rollout-rate",
"relay.span-extraction.sample-rate",
"relay.compute-metrics-summaries.sample-rate",
"sentry-metrics.extrapolation.duplication-limit",
"relay.span-normalization.allowed_hosts",
"sentry-metrics.extrapolation.propagate-rates",
]


Expand Down
20 changes: 0 additions & 20 deletions tests/sentry/api/endpoints/test_organization_details.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,6 @@ def test_upload_avatar(self):
"sentry.integrations.github.GitHubApiClient.get_repositories",
return_value=[{"name": "cool-repo", "full_name": "testgit/cool-repo"}],
)
@with_feature("organizations:metrics-extrapolation")
@with_feature("organizations:codecov-integration")
def test_various_options(self, mock_get_repositories):
initial = self.organization.get_audit_log_data()
Expand Down Expand Up @@ -454,7 +453,6 @@ def test_various_options(self, mock_get_repositories):
"metricAlertsThreadFlag": False,
"metricsActivatePercentiles": False,
"metricsActivateLastForGauges": True,
"extrapolateMetrics": True,
"uptimeAutodetection": False,
}

Expand Down Expand Up @@ -493,7 +491,6 @@ def test_various_options(self, mock_get_repositories):
assert options.get("sentry:events_member_admin") is False
assert options.get("sentry:metrics_activate_percentiles") is False
assert options.get("sentry:metrics_activate_last_for_gauges") is True
assert options.get("sentry:extrapolate_metrics") is True
assert options.get("sentry:uptime_autodetection") is False

# log created
Expand Down Expand Up @@ -539,7 +536,6 @@ def test_various_options(self, mock_get_repositories):
"to {}".format(data["metricsActivateLastForGauges"])
in log.data["metricsActivateLastForGauges"]
)
assert "to {}".format(data["extrapolateMetrics"]) in log.data["extrapolateMetrics"]
assert "to {}".format(data["uptimeAutodetection"]) in log.data["uptimeAutodetection"]

@responses.activate
Expand Down Expand Up @@ -943,22 +939,6 @@ def test_org_mapping_already_taken(self):
self.create_organization(slug="taken")
self.get_error_response(self.organization.slug, slug="taken", status_code=400)

@with_feature("organizations:metrics-extrapolation")
def test_extrapolate_metrics_with_permission(self):
# test when the value is set to False
resp = self.get_success_response(self.organization.slug, **{"extrapolateMetrics": False})
assert self.organization.get_option("sentry:extrapolate_metrics") is False
assert b"extrapolateMetrics" in resp.content

# test when the value is set to True
resp = self.get_success_response(self.organization.slug, **{"extrapolateMetrics": True})
assert self.organization.get_option("sentry:extrapolate_metrics") is True
assert b"extrapolateMetrics" in resp.content

def test_extrapolate_metrics_without_permission(self):
resp = self.get_response(self.organization.slug, **{"extrapolateMetrics": False})
assert resp.status_code == 400


class OrganizationDeleteTest(OrganizationDetailsTestBase):
method = "delete"
Expand Down
Loading
Loading