themis/counter

Functions

pub fn create_record(
  store store: Store,
  counter_name name_string: String,
  labels labels_dict: Dict(String, String),
) -> Result(Store, StoreError)

Initializes a new counter metric record with the given labels.

Arguments

  • store: The metrics store containing the counter
  • counter_name: The name of the counter to record a value for
  • labels: A dictionary of labels

Examples

let labels = dict.from_list([#("instance", "localhost:9090")])
let assert Ok(store) = insert_record(
  store,
  "http_request_failures",
  labels,
)
pub fn increment_record(
  store store: Store,
  counter_name name_string: String,
  labels labels_dict: Dict(String, String),
) -> Result(Store, StoreError)

Increments a counter record with the given labels by 1.

Arguments

  • store: The metrics store containing the counter
  • counter_name: The name of the counter to record a value for
  • labels: A dictionary of labels

Examples

let labels = dict.from_list([#("instance", "localhost:9090")])
let assert Ok(store) = increment_record(
  store,
  "http_request_failures",
  labels,
)
pub fn increment_record_by(
  store store: Store,
  counter_name name_string: String,
  labels labels_dict: Dict(String, String),
  by by: Number,
) -> Result(Store, StoreError)

Increments a counter record with the given labels by a specified value.

Arguments

  • store: The metrics store containing the counter
  • counter_name: The name of the counter to record a value for
  • labels: A dictionary of labels

Examples

let labels = dict.from_list([#("instance", "localhost:9090")])
let assert Ok(store) = increment_record(
  store,
  "http_request_failures",
  labels,
  number.int(12),
)
pub fn register(
  store store: Store,
  name name_string: String,
  description description: String,
) -> Result(Store, StoreError)

Registers a new counter metric to the store.

Arguments

  • store: The metrics store to add the counter to
  • name: The name of the counter metric (must be a valid Prometheus metric name)
  • description: A human-readable description of what the counter measures

Examples

let assert Ok(store) = register(
  store,
  "http_request_failures",
  "Count of HTTP request failures",
)
pub fn unregister(
  store store: Store,
  counter_name name_string: String,
) -> Result(Store, StoreError)

Removes a counter metric and all its recorded values from the store.

Arguments

  • store: The metrics store containing the counter
  • counter_name: The name of the counter to delete

Examples

let assert Ok(store) = unregister(store, "http_request_failures")
Search Document