Skip to content

Drop metrics #3518

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

Merged
merged 2 commits into from
Sep 11, 2024
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
2 changes: 2 additions & 0 deletions MIGRATION_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ Looking to upgrade from Sentry SDK 2.x to 3.x? Here's a comprehensive list of wh
### Removed

- Dropped support for Python 3.6.
- `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
- The experimental options `enable_metrics`, `before_emit_metric` and `metric_code_locations` have been removed.
- When setting span status, the HTTP status code is no longer automatically added as a tag.
- Class `Hub` has been removed.
- Class `_ScopeManager` has been removed.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ The Lambda function has been deployed here:
- Region: `us-east-1`
- Function ARN: `arn:aws:lambda:us-east-1:943013980633:function:sentryPythonDeleteTestFunctions`

This function also emits Sentry Metrics and Sentry Crons checkins to the `sentry-python` project in the `Sentry SDKs` organisation on Sentry.io:
https://sentry-sdks.sentry.io/projects/sentry-python/?project=5461230
This function also emits Sentry Crons checkins to the `sentry-python` project in the `Sentry SDKs` organisation on Sentry.io:
https://sentry-sdks.sentry.io/projects/sentry-python/?project=5461230
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,6 @@ def delete_lambda_functions(prefix="test_"):
def lambda_handler(event, context):
functions_deleted = delete_lambda_functions()

sentry_sdk.metrics.gauge(
key="num_aws_functions_deleted",
value=functions_deleted,
)

return {
"statusCode": 200,
"body": f"{functions_deleted} AWS Lambda functions deleted successfully.",
Expand Down
23 changes: 0 additions & 23 deletions sentry_sdk/_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
from typing import Mapping
from typing import NotRequired
from typing import Optional
from typing import Tuple
from typing import Type
from typing import Union
from typing_extensions import Literal, TypedDict
Expand Down Expand Up @@ -118,7 +117,6 @@ class SDKInfo(TypedDict):
"transaction_info": Mapping[str, Any], # TODO: We can expand on this type
"type": Literal["check_in", "transaction"],
"user": dict[str, object],
"_metrics_summary": dict[str, object],
},
total=False,
)
Expand Down Expand Up @@ -156,7 +154,6 @@ class SDKInfo(TypedDict):
"internal",
"profile",
"profile_chunk",
"metric_bucket",
"monitor",
"span",
]
Expand All @@ -165,26 +162,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
19 changes: 0 additions & 19 deletions sentry_sdk/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@

from sentry_sdk._types import Event, Hint, SDKInfo
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.transport import Transport
Expand Down Expand Up @@ -146,7 +145,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]

def __getstate__(self, *args, **kwargs):
# type: (*Any, **Any) -> Any
Expand Down Expand Up @@ -308,18 +306,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):
from sentry_sdk.metrics import MetricsAggregator

self.metrics_aggregator = MetricsAggregator(
capture_func=_capture_envelope,
enable_code_locations=bool(
experiments.get("metric_code_locations", True)
),
)

max_request_body_size = ("always", "never", "small", "medium")
if self.options["max_request_body_size"] not in max_request_body_size:
raise ValueError(
Expand Down Expand Up @@ -377,7 +363,6 @@ def _capture_envelope(envelope):

if (
self.monitor
or self.metrics_aggregator
or has_profiling_enabled(self.options)
or isinstance(self.transport, HttpTransport)
):
Expand Down Expand Up @@ -810,8 +795,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.monitor:
self.monitor.kill()
self.transport.kill()
Expand All @@ -834,8 +817,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()
self.transport.flush(timeout=timeout, callback=callback)

def __enter__(self):
Expand Down
8 changes: 0 additions & 8 deletions sentry_sdk/consts.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,9 @@ class EndpointType(Enum):
Event,
EventProcessor,
Hint,
MeasurementUnit,
ProfilerMode,
TracesSampler,
TransactionProcessor,
MetricTags,
MetricValue,
)

# Experiments are feature flags to enable and disable certain unstable SDK
Expand All @@ -61,11 +58,6 @@ class EndpointType(Enum):
"otel_powered_performance": Optional[bool],
"transport_zlib_compression_level": Optional[int],
"transport_num_pools": Optional[int],
"enable_metrics": Optional[bool],
"before_emit_metric": Optional[
Callable[[str, MetricValue, MeasurementUnit, MetricTags], bool]
],
"metric_code_locations": Optional[bool],
},
total=False,
)
Expand Down
4 changes: 1 addition & 3 deletions sentry_sdk/envelope.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,8 +274,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 @@ -335,7 +333,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"):
rv = cls(headers=headers, payload=PayloadRef(json=parse_json(payload)))
else:
rv = cls(headers=headers, payload=payload)
Expand Down
Loading
Loading