Skip to content

ref(metrics): Replace merni with metrics#348

Merged
jan-auer merged 3 commits intomainfrom
worktree-metrics-dogstatsd
Mar 3, 2026
Merged

ref(metrics): Replace merni with metrics#348
jan-auer merged 3 commits intomainfrom
worktree-metrics-dogstatsd

Conversation

@jan-auer
Copy link
Copy Markdown
Member

@jan-auer jan-auer commented Mar 2, 2026

Migrate from the merni crate (which sends metrics directly to the Datadog
API using an API key) to the metrics ecosystem with a DogStatsD exporter.
Our deployment has a sidecar with a DataDog agent that is able to handle
these submissions.

New objectstore-metrics crate

Thin wrapper that provides:

  • counter!, gauge!, distribution! macros preserving the existing
    call-site syntax with @s/@b unit annotations for value conversion
  • MetricsConfig struct with configurable host, prefix, buffer size, and tags
  • init() to wire up the DogStatsD exporter (no-op when host is None)
  • with_capturing_test_client() for asserting on metrics in tests

Configuration changes

Before After Notes
metrics.datadog_key metrics.host StatsD address replaces API key
metrics.prefix Defaults to "objectstore."
metrics.buffer_size Optional payload size override
Explicit flush on shutdown Periodic background flush

All ~30 metric call sites across 11 files are mechanically updated from
merni::counter!objectstore_metrics::counter! etc. with no changes
to metric names, tags, or semantics. Improvements to the macro will come
in a follow-up.

Requires https://github.com/getsentry/ops/pull/19421
Ref FS-278

Migrate from the merni crate (which sends metrics directly to the Datadog
API) to the metrics ecosystem with a DogStatsD exporter. Our deployment
now uses a DogStatsD sidecar, so we emit StatsD to a local socket instead
of requiring Datadog API credentials.

Introduces `objectstore-metrics`, a thin crate that provides:
- `counter!`, `gauge!`, `distribution!` macros preserving the existing
  call-site syntax with `@s`/`@b` unit annotations for value conversion
- `MetricsConfig` with configurable host, prefix, buffer size, and tags
- `init()` to wire up the DogStatsD exporter (no-op when host is None)
- `with_capturing_test_client()` for asserting on metrics in tests

Configuration changes:
- `metrics.datadog_key` (API key) → `metrics.host` (StatsD address)
- New: `metrics.prefix` (defaults to "objectstore.")
- New: `metrics.buffer_size` (optional payload size override)
- Explicit flush-on-shutdown removed (exporter flushes periodically)

This aligns with how Relay emits metrics, using the same crate versions
(metrics 0.24, metrics-exporter-dogstatsd 0.9) and builder configuration.
@jan-auer jan-auer changed the title ref(metrics): Replace merni with metrics + metrics-exporter-dogstatsd ref(metrics): Replace merni with metrics Mar 2, 2026
@linear
Copy link
Copy Markdown

linear bot commented Mar 3, 2026

@jan-auer jan-auer marked this pull request as ready for review March 3, 2026 12:17
@jan-auer jan-auer requested a review from a team as a code owner March 3, 2026 12:17
@jan-auer jan-auer enabled auto-merge (squash) March 3, 2026 15:48
@jan-auer jan-auer merged commit 6f700c7 into main Mar 3, 2026
20 checks passed
@jan-auer jan-auer deleted the worktree-metrics-dogstatsd branch March 3, 2026 15:56
jan-auer added a commit that referenced this pull request Mar 4, 2026
* main:
  release: 0.1.2
  build(gocd): Enable deployments for all customers (#351)
  ref(metrics): Replace merni with metrics (#348)
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.

2 participants