Skip to content

Commit 0653357

Browse files
authored
Drop metrics (#3518)
1 parent 28d8b82 commit 0653357

File tree

12 files changed

+8
-2131
lines changed

12 files changed

+8
-2131
lines changed

MIGRATION_GUIDE.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ Looking to upgrade from Sentry SDK 2.x to 3.x? Here's a comprehensive list of wh
2121
### Removed
2222

2323
- Dropped support for Python 3.6.
24+
- `sentry_sdk.metrics` and associated metrics APIs have been removed as Sentry no longer accepts metrics data in this form. See https://sentry.zendesk.com/hc/en-us/articles/26369339769883-Upcoming-API-Changes-to-Metrics
25+
- The experimental options `enable_metrics`, `before_emit_metric` and `metric_code_locations` have been removed.
2426
- When setting span status, the HTTP status code is no longer automatically added as a tag.
2527
- Class `Hub` has been removed.
2628
- Class `_ScopeManager` has been removed.

scripts/aws_lambda_functions/sentryPythonDeleteTestFunctions/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ The Lambda function has been deployed here:
99
- Region: `us-east-1`
1010
- Function ARN: `arn:aws:lambda:us-east-1:943013980633:function:sentryPythonDeleteTestFunctions`
1111

12-
This function also emits Sentry Metrics and Sentry Crons checkins to the `sentry-python` project in the `Sentry SDKs` organisation on Sentry.io:
13-
https://sentry-sdks.sentry.io/projects/sentry-python/?project=5461230
12+
This function also emits Sentry Crons checkins to the `sentry-python` project in the `Sentry SDKs` organisation on Sentry.io:
13+
https://sentry-sdks.sentry.io/projects/sentry-python/?project=5461230

scripts/aws_lambda_functions/sentryPythonDeleteTestFunctions/lambda_function.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,6 @@ def delete_lambda_functions(prefix="test_"):
4444
def lambda_handler(event, context):
4545
functions_deleted = delete_lambda_functions()
4646

47-
sentry_sdk.metrics.gauge(
48-
key="num_aws_functions_deleted",
49-
value=functions_deleted,
50-
)
51-
5247
return {
5348
"statusCode": 200,
5449
"body": f"{functions_deleted} AWS Lambda functions deleted successfully.",

sentry_sdk/_types.py

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
from typing import Mapping
1818
from typing import NotRequired
1919
from typing import Optional
20-
from typing import Tuple
2120
from typing import Type
2221
from typing import Union
2322
from typing_extensions import Literal, TypedDict
@@ -118,7 +117,6 @@ class SDKInfo(TypedDict):
118117
"transaction_info": Mapping[str, Any], # TODO: We can expand on this type
119118
"type": Literal["check_in", "transaction"],
120119
"user": dict[str, object],
121-
"_metrics_summary": dict[str, object],
122120
},
123121
total=False,
124122
)
@@ -156,7 +154,6 @@ class SDKInfo(TypedDict):
156154
"internal",
157155
"profile",
158156
"profile_chunk",
159-
"metric_bucket",
160157
"monitor",
161158
"span",
162159
]
@@ -165,26 +162,6 @@ class SDKInfo(TypedDict):
165162
ContinuousProfilerMode = Literal["thread", "gevent", "unknown"]
166163
ProfilerMode = Union[ContinuousProfilerMode, Literal["sleep"]]
167164

168-
# Type of the metric.
169-
MetricType = Literal["d", "s", "g", "c"]
170-
171-
# Value of the metric.
172-
MetricValue = Union[int, float, str]
173-
174-
# Internal representation of tags as a tuple of tuples (this is done in order to allow for the same key to exist
175-
# multiple times).
176-
MetricTagsInternal = Tuple[Tuple[str, str], ...]
177-
178-
# External representation of tags as a dictionary.
179-
MetricTagValue = Union[str, int, float, None]
180-
MetricTags = Mapping[str, MetricTagValue]
181-
182-
# Value inside the generator for the metric value.
183-
FlushedMetricValue = Union[int, float]
184-
185-
BucketKey = Tuple[MetricType, str, MeasurementUnit, MetricTagsInternal]
186-
MetricMetaKey = Tuple[MetricType, str, MeasurementUnit]
187-
188165
MonitorConfigScheduleType = Literal["crontab", "interval"]
189166
MonitorConfigScheduleUnit = Literal[
190167
"year",

sentry_sdk/client.py

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@
5555

5656
from sentry_sdk._types import Event, Hint, SDKInfo
5757
from sentry_sdk.integrations import Integration
58-
from sentry_sdk.metrics import MetricsAggregator
5958
from sentry_sdk.scope import Scope
6059
from sentry_sdk.session import Session
6160
from sentry_sdk.transport import Transport
@@ -146,7 +145,6 @@ def __init__(self, options=None):
146145

147146
self.transport = None # type: Optional[Transport]
148147
self.monitor = None # type: Optional[Monitor]
149-
self.metrics_aggregator = None # type: Optional[MetricsAggregator]
150148

151149
def __getstate__(self, *args, **kwargs):
152150
# type: (*Any, **Any) -> Any
@@ -308,18 +306,6 @@ def _capture_envelope(envelope):
308306

309307
self.session_flusher = SessionFlusher(capture_func=_capture_envelope)
310308

311-
self.metrics_aggregator = None # type: Optional[MetricsAggregator]
312-
experiments = self.options.get("_experiments", {})
313-
if experiments.get("enable_metrics", True):
314-
from sentry_sdk.metrics import MetricsAggregator
315-
316-
self.metrics_aggregator = MetricsAggregator(
317-
capture_func=_capture_envelope,
318-
enable_code_locations=bool(
319-
experiments.get("metric_code_locations", True)
320-
),
321-
)
322-
323309
max_request_body_size = ("always", "never", "small", "medium")
324310
if self.options["max_request_body_size"] not in max_request_body_size:
325311
raise ValueError(
@@ -377,7 +363,6 @@ def _capture_envelope(envelope):
377363

378364
if (
379365
self.monitor
380-
or self.metrics_aggregator
381366
or has_profiling_enabled(self.options)
382367
or isinstance(self.transport, HttpTransport)
383368
):
@@ -810,8 +795,6 @@ def close(
810795
if self.transport is not None:
811796
self.flush(timeout=timeout, callback=callback)
812797
self.session_flusher.kill()
813-
if self.metrics_aggregator is not None:
814-
self.metrics_aggregator.kill()
815798
if self.monitor:
816799
self.monitor.kill()
817800
self.transport.kill()
@@ -834,8 +817,6 @@ def flush(
834817
if timeout is None:
835818
timeout = self.options["shutdown_timeout"]
836819
self.session_flusher.flush()
837-
if self.metrics_aggregator is not None:
838-
self.metrics_aggregator.flush()
839820
self.transport.flush(timeout=timeout, callback=callback)
840821

841822
def __enter__(self):

sentry_sdk/consts.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,9 @@ class EndpointType(Enum):
3838
Event,
3939
EventProcessor,
4040
Hint,
41-
MeasurementUnit,
4241
ProfilerMode,
4342
TracesSampler,
4443
TransactionProcessor,
45-
MetricTags,
46-
MetricValue,
4744
)
4845

4946
# Experiments are feature flags to enable and disable certain unstable SDK
@@ -61,11 +58,6 @@ class EndpointType(Enum):
6158
"otel_powered_performance": Optional[bool],
6259
"transport_zlib_compression_level": Optional[int],
6360
"transport_num_pools": Optional[int],
64-
"enable_metrics": Optional[bool],
65-
"before_emit_metric": Optional[
66-
Callable[[str, MetricValue, MeasurementUnit, MetricTags], bool]
67-
],
68-
"metric_code_locations": Optional[bool],
6961
},
7062
total=False,
7163
)

sentry_sdk/envelope.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -274,8 +274,6 @@ def data_category(self):
274274
return "profile"
275275
elif ty == "profile_chunk":
276276
return "profile_chunk"
277-
elif ty == "statsd":
278-
return "metric_bucket"
279277
elif ty == "check_in":
280278
return "monitor"
281279
else:
@@ -335,7 +333,7 @@ def deserialize_from(
335333
# if no length was specified we need to read up to the end of line
336334
# and remove it (if it is present, i.e. not the very last char in an eof terminated envelope)
337335
payload = f.readline().rstrip(b"\n")
338-
if headers.get("type") in ("event", "transaction", "metric_buckets"):
336+
if headers.get("type") in ("event", "transaction"):
339337
rv = cls(headers=headers, payload=PayloadRef(json=parse_json(payload)))
340338
else:
341339
rv = cls(headers=headers, payload=payload)

0 commit comments

Comments
 (0)