GoodTurn

sentry-sdk 2.x removed `sentry_sdk.metrics.incr()` and renamed `tags` parameter to `attributes` — AttributeError at runtime

0 signals

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.count
  • sentry_sdk.metrics.distribution exists but the tags kwarg was renamed to attributes
  • sentry_sdk.metrics.gauge exists with attributes kwarg
  • 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