feat: prometheus metrics endpoint - #37
Merged
Merged
Conversation
adds --metrics-port flag to enable a prometheus HTTP endpoint on a
separate port. when enabled, the server records:
- ember_connections_active / total / rejected (gauge/counters)
- ember_commands_total{cmd} (counter per command)
- ember_commands_duration_seconds{cmd} (histogram, cache-latency buckets)
- ember_commands_errors_total{cmd} (counter)
- ember_keys_total, ember_memory_used_bytes (gauges, polled every 5s)
- ember_keys_expired_total, ember_keys_evicted_total (gauges from shard stats)
zero overhead when --metrics-port is not set — no recorder installed,
timing code is gated behind a bool.
also adds Command::command_name() for zero-allocation metric labels
and enriches KeyspaceStats with cumulative expiry/eviction counters.
kacy
added a commit
that referenced
this pull request
Feb 11, 2026
feat: prometheus metrics endpoint
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
summary
--metrics-port <port>CLI flag to expose a prometheus HTTP endpoint on a separate portShardRequest::Statsand publishes key/memory/expiry/eviction gaugesCommand::command_name()returning&'static strfor zero-allocation metric labelsKeyspaceStatswith cumulativekeys_expiredandkeys_evictedcounters--metrics-portis not set — no recorder installed, all timing gated behind a booltested
cargo test --workspace— all 216 tests passcargo clippy --workspace -- -D warnings— clean--metrics-port 9100, confirmedcurl localhost:9100/metricsreturns prometheus output with all expected metric familiesdesign considerations
metrics,metrics-exporter-prometheus) are only inember-server.ember-corestays dependency-free — the stats poller pulls data through the existing shard broadcast mechanismcommand_name()method avoids allocation by returning static strings, suitable for use as prometheus labels