getsentry / sentry

Developer-first error tracking and performance monitoring
https://sentry.io
Other
38.32k stars 4.11k forks source link

Metrics with unit names exceeding length limit (15 chars) don't appear in Sentry #71323

Open philipphofmann opened 2 months ago

philipphofmann commented 2 months ago

Environment

SaaS (https://sentry.io/)

Steps to Reproduce

This problem initially appeared on the Cocoa SDK (https://github.com/getsentry/sentry-cocoa/issues/3999), but while investigating, I realized it also happens for the Python SDK, so my assumption is that it's not SDK-related.

Capture the following metrics with the Python SDK or the Cocoa SDK:

# Does NOT end up in Sentry
sentry_sdk.metrics.incr(
    key="inc_with_custom_unit_underscores",
    value=1,
    unit="custom_unit_underscores",
)

# Ends up in Sentry
sentry_sdk.metrics.incr(
    key="inc_with_custom_unit_without_underscores",
    value=1,
    unit="myCustomUnit",
)

# Does NOT end up in Sentry
sentry_sdk.metrics.set(
    key="set_with_custom_unit_underscores",
    value="3",
    unit="custom_unit_underscores",
)

# Ends up in Sentry
sentry_sdk.metrics.set(
    key="set_with_custom_unit_without_underscores",
    value="3",
    unit="myCustomUnit",
)

It's worth noting that the _ is allowed for units; see develop docs.

Expected Result

All metrics show up in Sentry.

Actual Result

Only metrics without using the _ custom unit appear in Sentry.

Product Area

Other

Link

No response

DSN

No response

Version

No response

getsantry[bot] commented 2 months ago

Routing to @getsentry/product-owners-ddm for triage ⏲️

kahest commented 2 months ago

The root cause of this is that unit names are restricted to a maximum length of 15 chars, see docs: https://develop.sentry.dev/sdk/metrics/#maximum-lengths

Currently, measurements exceeding this limit are dropped. We plan to change this to automatically truncate unit names instead.

philipphofmann commented 2 months ago

We plan to change this to automatically truncate unit names instead.

Truncate them where, @kahest?

kahest commented 2 months ago

We plan to change this to automatically truncate unit names instead.

Truncate them where, @kahest?

I think in Relay, as per @Dav1dde's suggestion in our internal discussion