Skip to content

Commit 7997368

Browse files
authored
chore: Remove old metrics code (#4899)
### Description Remove old metrics code to make way for #4898 Metrics was always an experimental feature and Sentry stopped accepting metrics a year ago. #### Issues <!-- * resolves: #1234 * resolves: LIN-1234 --> #### Reminders - Please add tests to validate your changes, and lint your code using `tox -e linters`. - Add GH Issue ID _&_ Linear ID (if applicable) - PR title should use [conventional commit](https://develop.sentry.dev/engineering-practices/commit-messages/#type) style (`feat:`, `fix:`, `ref:`, `meta:`) - For external contributors: [CONTRIBUTING.md](https://github.com/getsentry/sentry-python/blob/master/CONTRIBUTING.md), [Sentry SDK development docs](https://develop.sentry.dev/sdk/), [Discord community](https://discord.gg/Ww9hbqr)
1 parent 55e903e commit 7997368

File tree

10 files changed

+2
-2156
lines changed

10 files changed

+2
-2156
lines changed

sentry_sdk/_types.py

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,6 @@ class SDKInfo(TypedDict):
210210
"type": Literal["check_in", "transaction"],
211211
"user": dict[str, object],
212212
"_dropped_spans": int,
213-
"_metrics_summary": dict[str, object],
214213
},
215214
total=False,
216215
)
@@ -266,7 +265,6 @@ class SDKInfo(TypedDict):
266265
"internal",
267266
"profile",
268267
"profile_chunk",
269-
"metric_bucket",
270268
"monitor",
271269
"span",
272270
"log_item",
@@ -276,26 +274,6 @@ class SDKInfo(TypedDict):
276274
ContinuousProfilerMode = Literal["thread", "gevent", "unknown"]
277275
ProfilerMode = Union[ContinuousProfilerMode, Literal["sleep"]]
278276

279-
# Type of the metric.
280-
MetricType = Literal["d", "s", "g", "c"]
281-
282-
# Value of the metric.
283-
MetricValue = Union[int, float, str]
284-
285-
# Internal representation of tags as a tuple of tuples (this is done in order to allow for the same key to exist
286-
# multiple times).
287-
MetricTagsInternal = Tuple[Tuple[str, str], ...]
288-
289-
# External representation of tags as a dictionary.
290-
MetricTagValue = Union[str, int, float, None]
291-
MetricTags = Mapping[str, MetricTagValue]
292-
293-
# Value inside the generator for the metric value.
294-
FlushedMetricValue = Union[int, float]
295-
296-
BucketKey = Tuple[MetricType, str, MeasurementUnit, MetricTagsInternal]
297-
MetricMetaKey = Tuple[MetricType, str, MeasurementUnit]
298-
299277
MonitorConfigScheduleType = Literal["crontab", "interval"]
300278
MonitorConfigScheduleUnit = Literal[
301279
"year",

sentry_sdk/client.py

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@
6161

6262
from sentry_sdk._types import Event, Hint, SDKInfo, Log
6363
from sentry_sdk.integrations import Integration
64-
from sentry_sdk.metrics import MetricsAggregator
6564
from sentry_sdk.scope import Scope
6665
from sentry_sdk.session import Session
6766
from sentry_sdk.spotlight import SpotlightClient
@@ -182,7 +181,6 @@ def __init__(self, options=None):
182181

183182
self.transport = None # type: Optional[Transport]
184183
self.monitor = None # type: Optional[Monitor]
185-
self.metrics_aggregator = None # type: Optional[MetricsAggregator]
186184
self.log_batcher = None # type: Optional[LogBatcher]
187185

188186
def __getstate__(self, *args, **kwargs):
@@ -361,26 +359,6 @@ def _capture_envelope(envelope):
361359

362360
self.session_flusher = SessionFlusher(capture_func=_capture_envelope)
363361

364-
self.metrics_aggregator = None # type: Optional[MetricsAggregator]
365-
experiments = self.options.get("_experiments", {})
366-
if experiments.get("enable_metrics", True):
367-
# Context vars are not working correctly on Python <=3.6
368-
# with gevent.
369-
metrics_supported = not is_gevent() or PY37
370-
if metrics_supported:
371-
from sentry_sdk.metrics import MetricsAggregator
372-
373-
self.metrics_aggregator = MetricsAggregator(
374-
capture_func=_capture_envelope,
375-
enable_code_locations=bool(
376-
experiments.get("metric_code_locations", True)
377-
),
378-
)
379-
else:
380-
logger.info(
381-
"Metrics not supported on Python 3.6 and lower with gevent."
382-
)
383-
384362
self.log_batcher = None
385363

386364
if has_logs_enabled(self.options):
@@ -467,7 +445,6 @@ def _capture_envelope(envelope):
467445

468446
if (
469447
self.monitor
470-
or self.metrics_aggregator
471448
or self.log_batcher
472449
or has_profiling_enabled(self.options)
473450
or isinstance(self.transport, BaseHttpTransport)
@@ -1019,8 +996,6 @@ def close(
1019996
if self.transport is not None:
1020997
self.flush(timeout=timeout, callback=callback)
1021998
self.session_flusher.kill()
1022-
if self.metrics_aggregator is not None:
1023-
self.metrics_aggregator.kill()
1024999
if self.log_batcher is not None:
10251000
self.log_batcher.kill()
10261001
if self.monitor:
@@ -1045,8 +1020,6 @@ def flush(
10451020
if timeout is None:
10461021
timeout = self.options["shutdown_timeout"]
10471022
self.session_flusher.flush()
1048-
if self.metrics_aggregator is not None:
1049-
self.metrics_aggregator.flush()
10501023
if self.log_batcher is not None:
10511024
self.log_batcher.flush()
10521025
self.transport.flush(timeout=timeout, callback=callback)

sentry_sdk/consts.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,6 @@ class CompressionAlgo(Enum):
5555
ProfilerMode,
5656
TracesSampler,
5757
TransactionProcessor,
58-
MetricTags,
59-
MetricValue,
6058
)
6159

6260
# Experiments are feature flags to enable and disable certain unstable SDK
@@ -77,11 +75,6 @@ class CompressionAlgo(Enum):
7775
"transport_compression_algo": Optional[CompressionAlgo],
7876
"transport_num_pools": Optional[int],
7977
"transport_http2": Optional[bool],
80-
"enable_metrics": Optional[bool],
81-
"before_emit_metric": Optional[
82-
Callable[[str, MetricValue, MeasurementUnit, MetricTags], bool]
83-
],
84-
"metric_code_locations": Optional[bool],
8578
"enable_logs": Optional[bool],
8679
"before_send_log": Optional[Callable[[Log, Hint], Optional[Log]]],
8780
},

sentry_sdk/envelope.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -291,8 +291,6 @@ def data_category(self):
291291
return "profile"
292292
elif ty == "profile_chunk":
293293
return "profile_chunk"
294-
elif ty == "statsd":
295-
return "metric_bucket"
296294
elif ty == "check_in":
297295
return "monitor"
298296
else:
@@ -354,7 +352,7 @@ def deserialize_from(
354352
# if no length was specified we need to read up to the end of line
355353
# and remove it (if it is present, i.e. not the very last char in an eof terminated envelope)
356354
payload = f.readline().rstrip(b"\n")
357-
if headers.get("type") in ("event", "transaction", "metric_buckets"):
355+
if headers.get("type") in ("event", "transaction"):
358356
rv = cls(headers=headers, payload=PayloadRef(json=parse_json(payload)))
359357
else:
360358
rv = cls(headers=headers, payload=payload)

0 commit comments

Comments
 (0)