Skip to content
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
22 changes: 0 additions & 22 deletions sentry_sdk/_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,6 @@ class SDKInfo(TypedDict):
"type": Literal["check_in", "transaction"],
"user": dict[str, object],
"_dropped_spans": int,
"_metrics_summary": dict[str, object],
},
total=False,
)
Expand Down Expand Up @@ -266,7 +265,6 @@ class SDKInfo(TypedDict):
"internal",
"profile",
"profile_chunk",
"metric_bucket",
"monitor",
"span",
"log_item",
Expand All @@ -276,26 +274,6 @@ class SDKInfo(TypedDict):
ContinuousProfilerMode = Literal["thread", "gevent", "unknown"]
ProfilerMode = Union[ContinuousProfilerMode, Literal["sleep"]]

# Type of the metric.
MetricType = Literal["d", "s", "g", "c"]

# Value of the metric.
MetricValue = Union[int, float, str]

# Internal representation of tags as a tuple of tuples (this is done in order to allow for the same key to exist
# multiple times).
MetricTagsInternal = Tuple[Tuple[str, str], ...]

# External representation of tags as a dictionary.
MetricTagValue = Union[str, int, float, None]
MetricTags = Mapping[str, MetricTagValue]

# Value inside the generator for the metric value.
FlushedMetricValue = Union[int, float]

BucketKey = Tuple[MetricType, str, MeasurementUnit, MetricTagsInternal]
MetricMetaKey = Tuple[MetricType, str, MeasurementUnit]

MonitorConfigScheduleType = Literal["crontab", "interval"]
MonitorConfigScheduleUnit = Literal[
"year",
Expand Down
27 changes: 0 additions & 27 deletions sentry_sdk/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@

from sentry_sdk._types import Event, Hint, SDKInfo, Log
from sentry_sdk.integrations import Integration
from sentry_sdk.metrics import MetricsAggregator
from sentry_sdk.scope import Scope
from sentry_sdk.session import Session
from sentry_sdk.spotlight import SpotlightClient
Expand Down Expand Up @@ -182,7 +181,6 @@ def __init__(self, options=None):

self.transport = None # type: Optional[Transport]
self.monitor = None # type: Optional[Monitor]
self.metrics_aggregator = None # type: Optional[MetricsAggregator]
self.log_batcher = None # type: Optional[LogBatcher]

def __getstate__(self, *args, **kwargs):
Expand Down Expand Up @@ -361,26 +359,6 @@ def _capture_envelope(envelope):

self.session_flusher = SessionFlusher(capture_func=_capture_envelope)

self.metrics_aggregator = None # type: Optional[MetricsAggregator]
experiments = self.options.get("_experiments", {})
if experiments.get("enable_metrics", True):
# Context vars are not working correctly on Python <=3.6
# with gevent.
metrics_supported = not is_gevent() or PY37
if metrics_supported:
from sentry_sdk.metrics import MetricsAggregator

self.metrics_aggregator = MetricsAggregator(
capture_func=_capture_envelope,
enable_code_locations=bool(
experiments.get("metric_code_locations", True)
),
)
else:
logger.info(
"Metrics not supported on Python 3.6 and lower with gevent."
)

self.log_batcher = None

if has_logs_enabled(self.options):
Expand Down Expand Up @@ -467,7 +445,6 @@ def _capture_envelope(envelope):

if (
self.monitor
or self.metrics_aggregator
or self.log_batcher
or has_profiling_enabled(self.options)
or isinstance(self.transport, BaseHttpTransport)
Expand Down Expand Up @@ -1019,8 +996,6 @@ def close(
if self.transport is not None:
self.flush(timeout=timeout, callback=callback)
self.session_flusher.kill()
if self.metrics_aggregator is not None:
self.metrics_aggregator.kill()
if self.log_batcher is not None:
self.log_batcher.kill()
if self.monitor:
Expand All @@ -1045,8 +1020,6 @@ def flush(
if timeout is None:
timeout = self.options["shutdown_timeout"]
self.session_flusher.flush()
if self.metrics_aggregator is not None:
self.metrics_aggregator.flush()
if self.log_batcher is not None:
self.log_batcher.flush()
self.transport.flush(timeout=timeout, callback=callback)
Expand Down
7 changes: 0 additions & 7 deletions sentry_sdk/consts.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@ class CompressionAlgo(Enum):
ProfilerMode,
TracesSampler,
TransactionProcessor,
MetricTags,
MetricValue,
)

# Experiments are feature flags to enable and disable certain unstable SDK
Expand All @@ -77,11 +75,6 @@ class CompressionAlgo(Enum):
"transport_compression_algo": Optional[CompressionAlgo],
"transport_num_pools": Optional[int],
"transport_http2": Optional[bool],
"enable_metrics": Optional[bool],
"before_emit_metric": Optional[
Callable[[str, MetricValue, MeasurementUnit, MetricTags], bool]
],
"metric_code_locations": Optional[bool],
"enable_logs": Optional[bool],
"before_send_log": Optional[Callable[[Log, Hint], Optional[Log]]],
},
Expand Down
4 changes: 1 addition & 3 deletions sentry_sdk/envelope.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,8 +291,6 @@ def data_category(self):
return "profile"
elif ty == "profile_chunk":
return "profile_chunk"
elif ty == "statsd":
return "metric_bucket"
elif ty == "check_in":
return "monitor"
else:
Expand Down Expand Up @@ -354,7 +352,7 @@ def deserialize_from(
# if no length was specified we need to read up to the end of line
# and remove it (if it is present, i.e. not the very last char in an eof terminated envelope)
payload = f.readline().rstrip(b"\n")
if headers.get("type") in ("event", "transaction", "metric_buckets"):
if headers.get("type") in ("event", "transaction"):
Copy link

Choose a reason for hiding this comment

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

Bug: Metric Buckets Payload Deserialization Failure

The deserialize_from method stopped parsing metric_buckets payloads as JSON. This means existing envelopes with metric_buckets will now be deserialized as raw bytes, which could cause runtime errors when a parsed object is expected.

Fix in Cursor Fix in Web

rv = cls(headers=headers, payload=PayloadRef(json=parse_json(payload)))
else:
rv = cls(headers=headers, payload=payload)
Expand Down
Loading