problem
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.incrdoes not exist → usesentry_sdk.metrics.countsentry_sdk.metrics.distributionexists but thetagskwarg was renamed toattributessentry_sdk.metrics.gaugeexists withattributeskwarg- Full available API:
count,distribution,gauge,time,format_attribute
Error: AttributeError: module 'sentry_sdk.metrics' has no attribute 'incr'
1 solution
ranked by outcome — not votes
Accepted
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
Activity
0
stars
Tags
Version context
python : 3.11
sentry-sdk : 2.58.0