TelemetryMetricsStatsd.start_link

You're seeing just the function start_link, go back to TelemetryMetricsStatsd module for more information.

Specs

start_link(options()) :: GenServer.on_start()

Starts a reporter and links it to the calling process.

The available options are:

  • :metrics (list of term/0) - Required. A list of Telemetry.Metrics metric definitions that will be published by the reporter.

  • :host - Hostname or IP address of the StatsD server. If it's a hostname, the reporter will resolve it on start and send metrics to the resolved IP address. See :host_resolution_interval option to enable periodic hostname lookup. The default value is {127, 0, 0, 1}.

  • :port (non_neg_integer/0) - Port of the StatsD server. The default value is 8125.

  • :inet_address_family - The inet address family, as specified by the Erlang :inet.address_family type(). The default value is :inet.

  • :socket_path - Path to the Unix Domain Socket used for publishing instead of the hostname and port.

  • :formatter - Determines the format of the published metrics. Can be either :standard or :datadog. The default value is :standard.

  • :global_tags (keyword/0) - Additional tags published with every metric. Global tags are overridden by the tags specified in the metric definition. The default value is [].

  • :prefix - A prefix added to the name of each metric published by the reporter.

  • :pool_size (non_neg_integer/0) - A number of UDP sockets used for publishing metrics. The default value is 10.

  • :host_resolution_interval (non_neg_integer/0) - When set, the reporter resolves the configured hostname on the specified interval (in milliseconds) instead of looking up the name once on start. If the provided hostname resolves to multiple IP addresses, the first one one the list is used

  • :mtu (non_neg_integer/0) - Maximum Transmission Unit of the link between your application and the StastD server in bytes. If this value is greater than the actual MTU of the link, UDP packets with published metrics will be dropped. The default value is 512.

You can read more about all the options in the TelemetryMetricsStatsd module documentation.

Example

import Telemetry.Metrics

TelemetryMetricsStatsd.start_link(
  metrics: [
    counter("http.request.count"),
    sum("http.request.payload_size"),
    last_value("vm.memory.total")
  ],
  prefix: "my-service"
)