MLServe.Telemetry.Metrics (MLServe v0.1.3)

Copy Markdown View Source

Telemetry.Metrics definitions for MLServe, ready for LiveDashboard or any reporter.

This is the practical Phoenix integration: MLServe never depends on Phoenix, but everything a Phoenix application wants to see about inference arrives through :telemetry, and this module turns those events into metric definitions.

Add them to your existing telemetry supervisor:

defmodule MyAppWeb.Telemetry do
  use Supervisor
  import Telemetry.Metrics

  def metrics do
    [
      # ... your Phoenix, Ecto and VM metrics ...
    ] ++ MLServe.Telemetry.Metrics.metrics()
  end
end

Optional dependency

:telemetry_metrics is an optional dependency. When it is not present this module returns an empty list rather than failing to compile, so MLServe stays at one runtime dependency for everyone who does not need metrics. Add it yourself to switch these on:

{:telemetry_metrics, "~> 1.0"}

Tags

Every metric is tagged with :model and, where meaningful, :version — so a canary rollout shows up as two series you can compare directly, which is the whole point of MLServe.canary/3.

Summary

Functions

Returns the metric definitions, or [] when :telemetry_metrics is not available.

Functions

metrics()

@spec metrics() :: list()

Returns the metric definitions, or [] when :telemetry_metrics is not available.

Examples

MLServe.Telemetry.Metrics.metrics()
|> Enum.map(& &1.name)
#=> [[:ml_serve, :prediction, :duration], ...]