Skip to content

fix(fetcher): Handle missing unit in Datadog query responses - #81

Closed
sentry-junior[bot] wants to merge 1 commit into
mainfrom
fix/datadog-missing-unit
Closed

sentry-junior[bot] wants to merge 1 commit into
mainfrom
fix/datadog-missing-unit

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Oct 23, 2026

Copy link
Copy Markdown
Contributor

Since about 02:00 UTC on Oct 23, the hourly usage-accountant cronjob has been failing in every region with KeyError: 'unit' in warn_multiple_units.

Datadog's v1 query API (/api/v1/query) now leaves series[].unit out completely when a metric has no unit set in Datadog. Before, the field was there with null values. The *.cogs.usage metrics have no unit set. main() already handles this, because every query in our config sets its own unit. But warn_multiple_units read the field without checking it exists, so this warning-only helper was failing the whole run.

This change treats a missing unit as "no units" and also guards against a one-element unit list. Tests are added for both cases.

Refs PRODENG-2990: Investigate usage accountant failures across all regions

via bojan.

--

View Junior Session [Sentry]

Datadog's v1 query API now omits series[].unit for metrics without unit metadata, which made warn_multiple_units raise KeyError and fail every run.

Refs PRODENG-2990

Co-Authored-By: Bojan Oro <bojan.oro@sentry.io>
@sentry-junior
sentry-junior Bot requested a review from a team as a code owner October 23, 2026 14:19
@linear-code

linear-code Bot commented Oct 23, 2026

Copy link
Copy Markdown

PRODENG-2990

@sentry-junior sentry-junior Bot closed this Oct 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants