Skip to content

feat: add PartitonedTables#1819

Merged
edgurgel merged 2 commits intomainfrom
feat/peep-partitioned-tables
Apr 19, 2026
Merged

feat: add PartitonedTables#1819
edgurgel merged 2 commits intomainfrom
feat/peep-partitioned-tables

Conversation

@edgurgel
Copy link
Copy Markdown
Member

What kind of change does this PR introduce?

Peep.Storage implementation using N ETS tables with optional tag-based routing.

Each metric write is routed to a specific table based on a :routing_tag option. If the routing tag is present in the metric's tags, :erlang.phash2/2 is used to select the table. Otherwise, the first table is used.

This reduces lock contention by routing different tag values (e.g. different tenants) to different ETS tables, without partitioning metrics within a table.

If a metric does not have a routing_tag to route we just put the on the first table. This way we never have a metric/tag combination in more than 1 table simplifying most operations.

Peep.Storage implementation using N ETS tables with optional tag-based routing.

Each metric write is routed to a specific table based on a `:routing_tag` option.
If the routing tag is present in the metric's tags, `:erlang.phash2/2` is used to
select the table. Otherwise, the first table is used.

This reduces lock contention by routing different tag values (e.g. different tenants)
to different ETS tables, without partitioning metrics within a table.
@coveralls
Copy link
Copy Markdown

Coverage Status

Coverage is 91.81%feat/peep-partitioned-tables into main. No base build found for main.

@edgurgel edgurgel requested a review from v0idpwn April 17, 2026 07:19
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new Peep storage backend that reduces ETS write contention by routing metrics into multiple ETS tables based on an optional tag value, and wires it into PromEx.

Changes:

  • Introduce Realtime.Monitoring.Peep.PartitionedTables (N ETS tables, optional :routing_tag-based routing).
  • Switch PromEx’s Peep storage to PartitionedTables with routing_tag: :tenant.
  • Add unit tests for routing/pruning behavior and relax timing in MetricsPusher tests to reduce flakiness.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
lib/realtime/monitoring/peep/partitioned_tables.ex New Peep storage implementation backed by multiple ETS tables with optional tag-based routing.
lib/realtime/monitoring/prom_ex.ex Uses PartitionedTables as the PromEx Peep storage and configures tenant-based routing.
test/realtime/monitoring/peep/partitioned_tables_test.exs Adds coverage for cross-table aggregation, routing fallback, and targeted pruning.
test/realtime/metrics_pusher_test.exs Increases assert_receive timeouts to reduce test flakiness.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread lib/realtime/monitoring/peep/partitioned_tables.ex
Comment thread test/realtime/monitoring/peep/partitioned_tables_test.exs
Comment thread test/realtime/monitoring/peep/partitioned_tables_test.exs
Comment thread test/realtime/monitoring/peep/partitioned_tables_test.exs
@edgurgel edgurgel merged commit ca07643 into main Apr 19, 2026
12 checks passed
@edgurgel edgurgel deleted the feat/peep-partitioned-tables branch April 19, 2026 22:49
@realtime-release-bot
Copy link
Copy Markdown

🎉 This PR is included in version 2.86.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants