Add ETS table memory observability metrics - #3632
Conversation
❌ 1 Tests Failed:
View the top 2 failed test(s) by shortest run time
To view more test analytics, go to the Test Analytics Dashboard |
|
Found 2 test failures on Blacksmith runners: Failures
|
|
you can close this if you don't want to work on it anymore |
5e86668 to
1427896
Compare
Claude Code GuidelinesSee AGENTS.md for project conventions, architecture, and coding guidelines. |
31e33f6 to
c5e1099
Compare
Claude Code ReviewSummaryIteration 3. Good incremental progress: the metric name was revised, test flakiness was fixed, and the utility router now emits the correct Content-Type. The one remaining Important item — What's Working Well
Issues FoundCritical (Must Fix)None. Important (Should Fix)Missing File: Project conventions require @spec top_tables(pos_integer()) :: [
%{
name: atom() | binary(),
type: binary(),
memory: non_neg_integer(),
size: non_neg_integer(),
type_table_count: pos_integer(),
avg_size_per_type: float()
}
]
@spec top_by_type(pos_integer()) :: [
%{type: binary(), memory: non_neg_integer(), table_count: pos_integer(), avg_size: float()}
]
@spec top_memory_stats(pos_integer(), pos_integer()) :: %{
top_tables: list(),
top_by_type: list()
}Suggestions (Nice to Have)Redundant
:telemetry.execute([:ets, :memory], %{total: memory}, %{table_type: type})
The production integration only calls Issue ConformanceNo linked GitHub issue. PR description clearly explains the scope and a changeset is present; a linked issue would be nice for traceability but is not blocking. Previous Review Status
Review iteration: 3 | 2026-04-09 |
c5e1099 to
405cdc7
Compare
… mem usage Similar to how ElectricTelemetry.Processes shows top N types of processes by memory use.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add ets_table_memory periodic measurement that reports top N ETS table types by memory usage, similar to how process_memory reports top process types. Adds the ets_table.memory.total metric with table_type tag and a configurable top_ets_table_count option (default: 10). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Named ETS tables are owned by the test process and auto-deleted when it exits. The on_exit callback runs in a separate process, so tables may already be gone. Use try/rescue instead of :ets.info check. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Update docstring examples to show string types instead of atoms, matching the actual return values after the String.to_atom removal - Hoist :erlang.system_info(:wordsize) to a module attribute since it's a VM constant Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
ETS tables are owned by the creating process, so they are automatically cleaned up when the test process exits. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
405cdc7 to
44f796a
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 44f796aa8f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| ]}, | ||
| default: {:count, 5} | ||
| ], | ||
| top_ets_table_count: [type: :integer, default: 10], |
There was a problem hiding this comment.
Validate top ETS table count as positive
top_ets_table_count is validated as any integer, but ApplicationTelemetry.ets_memory/1 passes it to EtsTables.top_by_type/1, which only has a clause for integers > 0. If a deployment sets this option to 0 or a negative number, periodic telemetry polling will raise a FunctionClauseError on every run, dropping ETS metrics and potentially causing repeated poller restarts/log noise. Constrain this option to a positive integer (or add a non-crashing fallback path).
Useful? React with 👍 / 👎.
Summary
ElectricTelemetry.EtsTablesmodule that collects memory usage statistics from ETS tables, grouping by "type" (extracted from table names using pattern matching on UUID suffixes)ets_table_memoryperiodic measurement inApplicationTelemetryets_table.memory.totalmetric withtable_typetag, following the same pattern asprocess.memory.totaltop_ets_table_countoption (default: 10)Changes
ElectricTelemetry.EtsTables- functions for collecting top N ETS tables by memory (individually and grouped by type)ElectricTelemetry.ApplicationTelemetry- addedets_table_memory/1periodic measurement and metric definitionElectricTelemetry.Opts- addedtop_ets_table_countconfiguration optionTest plan
EtsTablesmodule (13 tests passing)--warnings-as-errorspasses🤖 Generated with Claude Code