### Initialize TelemetryMetricsPrometheus under a Supervisor Source: https://hexdocs.pm/telemetry_metrics_prometheus This snippet shows how to start TelemetryMetricsPrometheus as a child process within an Elixir application's supervision tree. It includes a list of metrics to monitor. ```elixir def start(_type, _args) do # List all child processes to be supervised children = [ {TelemetryMetricsPrometheus, [metrics: metrics()]} ... ] opts = [strategy: :one_for_one, name: ExampleApp.Supervisor] Supervisor.start_link(children, opts) end defp metrics, do: [ counter("http.request.count"), sum("http.request.payload_size", unit: :byte), last_value("vm.memory.total", unit: :byte) ] ``` -------------------------------- ### Start TelemetryMetricsPrometheus Reporter Source: https://hexdocs.pm/telemetry_metrics_prometheus This function starts the TelemetryMetricsPrometheus reporter and links it to the calling process. It accepts various options to configure metrics, port, protocol, and handlers. ```elixir start_link(options()) :: GenServer.on_start() ``` -------------------------------- ### Define a Prometheus Metrics Distribution Source: https://hexdocs.pm/telemetry_metrics_prometheus Example of defining a distribution metric for Prometheus, specifically for tracking the duration of prometheus metrics scrapes. It configures buckets, event name, measurement, tags, and units. ```elixir Metrics.distribution("prometheus_metrics.scrape.duration.milliseconds", reporter_options: [buckets: [0.05, 0.1, 0.2, 0.5, 1]], description: "A histogram of the request duration for prometheus metrics scrape.", event_name: [:prometheus_metrics, :plug, :stop], measurement: :duration, tags: [:name], tag_values: fn %{conn: conn} -> %{name: conn.private[:prometheus_metrics_name]} end, unit: {:native, :millisecond} ) ``` -------------------------------- ### Get Reporter's Child Specification Source: https://hexdocs.pm/telemetry_metrics_prometheus Provides a child specification for the TelemetryMetricsPrometheus reporter, suitable for use with Elixir's Supervisor module. This allows the reporter to be supervised within an application. ```elixir child_spec(options()) :: Supervisor.child_spec() ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.