ExTorch.Metrics
(extorch v0.2.0)
Copy Markdown
ETS-backed metrics collection for ExTorch model serving.
Automatically attaches to telemetry events emitted by ExTorch.JIT.Server
and maintains per-model inference statistics.
Setup
Call ExTorch.Metrics.setup/0 in your application start to begin collecting:
def start(_type, _args) do
ExTorch.Metrics.setup()
# ...
endQuerying Metrics
ExTorch.Metrics.get("model.pt")
# => %{inference_count: 150, error_count: 2, total_duration_ms: 4523.1,
# min_duration_ms: 12.3, max_duration_ms: 89.2, last_inference_at: ~U[...]}
ExTorch.Metrics.all()
# => [{"model.pt", %{...}}, {"other.pt", %{...}}]
Summary
Functions
Get metrics for all tracked models.
Get metrics for a specific model path.
Reset metrics for a specific model path.
Reset all metrics.
Initialize the metrics ETS table and attach telemetry handlers.
Detach telemetry handlers. Metrics table remains intact.
Functions
Get metrics for all tracked models.
Returns a list of {path, metrics} tuples.
Get metrics for a specific model path.
Returns a map of metrics or nil if no data exists.
@spec reset(String.t()) :: :ok
Reset metrics for a specific model path.
@spec reset_all() :: :ok
Reset all metrics.
@spec setup() :: :ok
Initialize the metrics ETS table and attach telemetry handlers.
Safe to call multiple times -- will not reset existing data.
@spec teardown() :: :ok | {:error, :not_found}
Detach telemetry handlers. Metrics table remains intact.