datadog_client/metric

Types

A Datadog series entry. Build with gauge/count/rate and refine via the with_* / add_* helpers.

pub opaque type Metric

Datadog metric kind.

pub type MetricType {
  Gauge
  Count
  Rate
}

Constructors

  • Gauge
  • Count
  • Rate

A single sample: a Unix timestamp in seconds and its value.

pub type Point {
  Point(timestamp: Int, value: Float)
}

Constructors

  • Point(timestamp: Int, value: Float)

Values

pub fn add_point(
  metric: Metric,
  at timestamp: Int,
  of value: Float,
) -> Metric

Append a single point at the given timestamp.

pub fn add_tag(metric: Metric, with tag: String) -> Metric

Append a single tag.

pub fn count(name: String, value: Float) -> Metric

Count metric at the current time.

pub fn gauge(name: String, value: Float) -> Metric

Gauge metric at the current time.

pub fn rate(name: String, value: Float) -> Metric

Rate metric at the current time. Set the interval with with_interval.

pub fn to_json(metric: Metric) -> json.Json

JSON object for a single metric, matching Datadog’s v1 series schema.

pub fn with_host(metric: Metric, to host: String) -> Metric

Set the reporting host.

pub fn with_interval(metric: Metric, of seconds: Int) -> Metric

Set the flush interval in seconds (required for Rate).

pub fn with_points(
  metric: Metric,
  with points: List(Point),
) -> Metric

Replace all points.

pub fn with_tags(
  metric: Metric,
  with tags: List(String),
) -> Metric

Replace the metric’s tags.

pub fn with_type(metric: Metric, to kind: MetricType) -> Metric

Set the metric type (gauge/count/rate).

Search Document