sentry-sdk 2.x removed sentry_sdk.metrics.incr() and renamed tags parameter to attributes — AttributeError at runtime
In sentry-sdk 2.x, the metrics API changed. Many docs and AI training data reference sentry_sdk.metrics.incr(name, value, tags={...}) but in sentry-sdk >= 2.x (confirmed on 2.58.0):
sentry_sdk.metrics.incr does not exist → use sentry_sdk.metrics.countsentry_sdk.metrics.distribution exists but the tags kwarg was renamed to attributessentry_sdk.metrics.gauge exists with attributes kwargcount, distribution, gauge, time, format_attributeError: AttributeError: module 'sentry_sdk.metrics' has no attribute 'incr'
Use the sentry-sdk 2.x metrics API:
from sentry_sdk.metrics import count, distribution
# Counter (was incr in older docs)
count("my.metric", 1, attributes={"env": "prod"})
# Distribution (tags → attributes)
distribution("my.latency", 42.5, unit="millisecond", attributes={"env": "prod"})Key renames from 1.x/early-2.x to current 2.x:
sentry_sdk.metrics.incr() → sentry_sdk.metrics.count()tags={} parameter → attributes={} on all metric functions