Page MenuHomePhorge

No OneTemporary

Authored By
Unknown
Size
27 KB
Referenced Files
None
Subscribers
None
diff --git a/lib/prometheus/metric/counter.ex b/lib/prometheus/metric/counter.ex
index 89a3d11..ed439d4 100644
--- a/lib/prometheus/metric/counter.ex
+++ b/lib/prometheus/metric/counter.ex
@@ -1,130 +1,140 @@
defmodule Prometheus.Metric.Counter do
@moduledoc """
Counter is a Metric that represents a single numerical value that only ever
goes up. That implies that it cannot be used to count items whose number can
also go down, e.g. the number of currently running processes. Those
"counters" are represented by `Prometheus.Metric.Gauge`.
A Counter is typically used to count requests served, tasks completed, errors
occurred, etc.
Example use cases for Counters:
- Number of requests processed;
- Number of items that were inserted into a queue;
- Total amount of data that a system has processed.
Use the [`rate()`](https://prometheus.io/docs/querying/functions/#rate())/
[`irate()`](https://prometheus.io/docs/querying/functions/#irate())
functions in Prometheus to calculate the rate of increase of a Counter.
By convention, the names of Counters are suffixed by `_total`.
To create a counter use either `new/1` or `declare/`, the difference is that
`new/` will raise `Prometheus.Error.MFAlreadyExists` exception if counter with
the same `registry`, `name` and `labels` combination already exists.
Both accept `spec` `Keyword` with the same set of keys:
- `:registry` - optional, default is `:default`;
- `:name` - required, can be an atom or a string;
- `:help` - required, must be a string;
- `:labels` - optional, default is `[]`.
Example:
```
defmodule MyServiceInstrumenter do
use Prometheus.Metric
## to be called at app/supervisor startup.
## to tolerate restarts use declare.
def setup() do
Counter.declare([name: :my_service_total_requests,
help: "Total requests.",
labels: [:caller]])
end
def inc(caller) do
Counter.inc([name: :my_service_total_requests,
labels: [caller]])
end
end
```
"""
use Prometheus.Erlang, :prometheus_counter
@doc """
Creates a counter using `spec`.
Raises `Prometheus.Error.MissingMetricSpecKey` if required `spec` key is missing.<br>
Raises `Prometheus.Error.InvalidMetricName` if metric name is invalid.<br>
Raises `Prometheus.Error.InvalidMetricHelp` if help is invalid.<br>
Raises `Prometheus.Error.InvalidMetricLabels` if labels isn't a list.<br>
Raises `Prometheus.Error.InvalidMetricName` if label name is invalid.<br>
Raises `Prometheus.Error.MFAlreadyExists` if a counter with the same `spec` already exists.
"""
defmacro new(spec) do
Erlang.call([spec])
end
@doc """
Creates a counter using `spec`.
If a counter with the same `spec` exists returns `false`.
Raises `Prometheus.Error.MissingMetricSpecKey` if required `spec` key is missing.<br>
Raises `Prometheus.Error.InvalidMetricName` if metric name is invalid.<br>
Raises `Prometheus.Error.InvalidMetricHelp` if help is invalid.<br>
Raises `Prometheus.Error.InvalidMetricLabels` if labels isn't a list.<br>
Raises `Prometheus.Error.InvalidMetricName` if label name is invalid.
"""
defmacro declare(spec) do
Erlang.call([spec])
end
@doc """
Increments the counter identified by `spec` by `value`.
Raises `Prometheus.Error.InvalidValue` exception if `value` isn't a positive integer.<br>
Raises `Prometheus.Error.UnknownMetric` exception if a counter for `spec` can't be found.<br>
Raises `Prometheus.Error.InvalidMetricArity` exception if labels count mismatch.
"""
defmacro inc(spec, value \\ 1) do
Erlang.metric_call(:inc, spec, [value])
end
@doc """
Increments the counter identified by `spec` by `value`.
If `value` happened to be a float number even one time(!) you shouldn't use `inc/2` after dinc.
Raises `Prometheus.Error.InvalidValue` exception if `value` isn't a positive number.<br>
Raises `Prometheus.Error.UnknownMetric` exception if a counter for `spec` can't be found.<br>
Raises `Prometheus.Error.InvalidMetricArity` exception if labels count mismatch.
"""
defmacro dinc(spec, value \\ 1) do
Erlang.metric_call({:prometheus_counter, :dinc}, spec, [value])
end
+ @doc """
+ Removes counter series identified by spec.
+
+ Raises `Prometheus.Error.UnknownMetric` exception if a gauge for `spec` can't be found.<br>
+ Raises `Prometheus.Error.InvalidMetricArity` exception if labels count mismatch.
+ """
+ defmacro remove(spec) do
+ Erlang.metric_call(spec)
+ end
+
@doc """
Resets the value of the counter identified by `spec`.
Raises `Prometheus.Error.UnknownMetric` exception if a counter for `spec` can't be found.<br>
Raises `Prometheus.Error.InvalidMetricArity` exception if labels count mismatch.
"""
defmacro reset(spec) do
Erlang.metric_call(spec)
end
@doc """
Returns the value of the counter identified by `spec`. If there is no counter for
given labels combination, returns `:undefined`.
Raises `Prometheus.Error.UnknownMetric` exception if a counter for `spec` can't be found.<br>
Raises `Prometheus.Error.InvalidMetricArity` exception if labels count mismatch.
"""
defmacro value(spec) do
Erlang.metric_call({:prometheus_counter, :value}, spec)
end
end
diff --git a/lib/prometheus/metric/gauge.ex b/lib/prometheus/metric/gauge.ex
index 158d2b2..d1d30fb 100644
--- a/lib/prometheus/metric/gauge.ex
+++ b/lib/prometheus/metric/gauge.ex
@@ -1,131 +1,197 @@
defmodule Prometheus.Metric.Gauge do
@moduledoc """
Gauge metric, to report instantaneous values.
Gauge is a metric that represents a single numerical value that can
arbitrarily go up and down.
A Gauge is typically used for measured values like temperatures or current
memory usage, but also "counts" that can go up and down, like the number of
running processes.
Example use cases for Gauges:
- Inprogress requests;
- Number of items in a queue;
- Free memory;
- Total memory;
- Temperature.
Example:
```
defmodule MyPoolInstrumenter do
use Prometheus.Metric
## to be called at app/supervisor startup.
## to tolerate restarts use declare.
def setup() do
Gauge.declare([name: :my_pool_size,
help: "Pool size."])
Gauge.declare([name: :my_pool_checked_out,
help: "Number of sockets checked out from the pool"])
end
def set_size(size) do
Gauge.set([name: :my_pool_size], size)
end
def track_checked_out_sockets(checkout_fun) do
Gauge.track_inprogress([name: :my_pool_checked_out], checkout_fun)
end
end
```
"""
use Prometheus.Erlang, :prometheus_gauge
@doc """
Creates a gauge using `spec`.
Raises `Prometheus.Error.MissingMetricSpecKey` if required `spec` key is missing.<br>
Raises `Prometheus.Error.InvalidMetricName` if metric name is invalid.<br>
Raises `Prometheus.Error.InvalidMetricHelp` if help is invalid.<br>
Raises `Prometheus.Error.InvalidMetricLabels` if labels isn't a list.<br>
Raises `Prometheus.Error.InvalidMetricName` if label name is invalid.<br>
Raises `Prometheus.Error.MFAlreadyExists` if a gauge with the same `spec` exists.
"""
defmacro new(spec) do
Erlang.call([spec])
end
@doc """
Creates a gauge using `spec`.
If a gauge with the same `spec` exists returns `false`.
Raises `Prometheus.Error.MissingMetricSpecKey` if required `spec` key is missing.<br>
Raises `Prometheus.Error.InvalidMetricName` if metric name is invalid.<br>
Raises `Prometheus.Error.InvalidMetricHelp` if help is invalid.<br>
Raises `Prometheus.Error.InvalidMetricLabels` if labels isn't a list.<br>
Raises `Prometheus.Error.InvalidMetricName` if label name is invalid.
"""
defmacro declare(spec) do
Erlang.call([spec])
end
@doc """
Sets the gauge identified by `spec` to `value`.
Raises `Prometheus.Error.InvalidValue` exception if `value` isn't a number.<br>
Raises `Prometheus.Error.UnknownMetric` exception if a gauge for `spec` can't be found.<br>
Raises `Prometheus.Error.InvalidMetricArity` exception if labels count mismatch.
"""
defmacro set(spec, value) do
Erlang.metric_call(spec, [value])
end
+ @doc """
+ Increments the gauge identified by `spec` by `value`.
+
+ Raises `Prometheus.Error.InvalidValue` exception if `value` isn't an integer.<br>
+ Raises `Prometheus.Error.UnknownMetric` exception if a counter for `spec` can't be found.<br>
+ Raises `Prometheus.Error.InvalidMetricArity` exception if labels count mismatch.
+ """
+ defmacro inc(spec, value \\ 1) do
+ Erlang.metric_call(spec, [value])
+ end
+
+ @doc """
+ Decrements the gauge identified by `spec` by `value`.
+
+ Raises `Prometheus.Error.InvalidValue` exception if `value` isn't an integer.<br>
+ Raises `Prometheus.Error.UnknownMetric` exception if a counter for `spec` can't be found.<br>
+ Raises `Prometheus.Error.InvalidMetricArity` exception if labels count mismatch.
+ """
+ defmacro dec(spec, value \\ 1) do
+ Erlang.metric_call(spec, [value])
+ end
+
+ @doc """
+ Increments the gauge identified by `spec` by `value`.
+ If `value` happened to be a float number even one time(!) you shouldn't use `inc/2` or `dec/2` after dinc.
+
+ Raises `Prometheus.Error.InvalidValue` exception if `value` isn't a number.<br>
+ Raises `Prometheus.Error.UnknownMetric` exception if a counter for `spec` can't be found.<br>
+ Raises `Prometheus.Error.InvalidMetricArity` exception if labels count mismatch.
+ """
+ defmacro dinc(spec, value \\ 1) do
+ Erlang.metric_call(spec, [value])
+ end
+
+ @doc """
+ Decrements the gauge identified by `spec` by `value`.
+ If `value` happened to be a float number even one time(!) you shouldn't use `inc/2` or `dec/2` after ddec.
+
+ Raises `Prometheus.Error.InvalidValue` exception if `value` isn't a number.<br>
+ Raises `Prometheus.Error.UnknownMetric` exception if a counter for `spec` can't be found.<br>
+ Raises `Prometheus.Error.InvalidMetricArity` exception if labels count mismatch.
+ """
+ defmacro ddec(spec, value \\ 1) do
+ Erlang.metric_call(spec, [value])
+ end
+
@doc """
Sets the gauge identified by `spec` to the current unixtime.
Raises `Prometheus.Error.UnknownMetric` exception if a gauge for `spec` can't be found.<br>
Raises `Prometheus.Error.InvalidMetricArity` exception if labels count mismatch.
"""
defmacro set_to_current_time(spec) do
Erlang.metric_call(spec)
end
@doc """
- Track inprogress functions.
+ Tracks inprogress functions.
Raises `Prometheus.Error.UnknownMetric` exception if a gauge for `spec` can't be found.<br>
Raises `Prometheus.Error.InvalidMetricArity` exception if labels count mismatch.
"""
defmacro track_inprogress(spec, fun) do
Erlang.metric_call(spec, [fun])
end
+ @doc """
+ Tracks function execution duration.
+
+ Raises `Prometheus.Error.UnknownMetric` exception if a gauge for `spec` can't be found.<br>
+ Raises `Prometheus.Error.InvalidMetricArity` exception if labels count mismatch.
+ """
+ defmacro set_duration(spec, fun) do
+ Erlang.metric_call(spec, [fun])
+ end
+
+ @doc """
+ Removes gauge series identified by spec.
+
+ Raises `Prometheus.Error.UnknownMetric` exception if a gauge for `spec` can't be found.<br>
+ Raises `Prometheus.Error.InvalidMetricArity` exception if labels count mismatch.
+ """
+ defmacro remove(spec) do
+ Erlang.metric_call(spec)
+ end
+
@doc """
Resets the value of the gauge identified by `spec`.
Raises `Prometheus.Error.UnknownMetric` exception if a gauge for `spec` can't be found.<br>
Raises `Prometheus.Error.InvalidMetricArity` exception if labels count mismatch.
"""
defmacro reset(spec) do
Erlang.metric_call(spec)
end
@doc """
Returns the value of the gauge identified by `spec`.
Raises `Prometheus.Error.UnknownMetric` exception if a gauge for `spec` can't be found.<br>
Raises `Prometheus.Error.InvalidMetricArity` exception if labels count mismatch.
"""
defmacro value(spec) do
Erlang.metric_call(spec)
end
end
diff --git a/lib/prometheus/metric/histogram.ex b/lib/prometheus/metric/histogram.ex
index 1b59bc0..706fdb1 100644
--- a/lib/prometheus/metric/histogram.ex
+++ b/lib/prometheus/metric/histogram.ex
@@ -1,140 +1,150 @@
defmodule Prometheus.Metric.Histogram do
@moduledoc """
A Histogram tracks the size and number of events in buckets.
You can use Histograms for aggregatable calculation of quantiles.
Example use cases for Histograms:
- Response latency;
- Request size.
Histogram expects `buckets` key in a metric spec. Buckets can be:
- a list of numbers in increasing order;
- on of the generate specs (essentially shortcuts for `Prometheus.Buckets` macros)
- :default;
- {:linear, start, step, count};
- {:exponential, start, step, count}.
Example:
```
defmodule ExampleInstrumenter do
use Prometheus.Metric
## to be called at app/supervisor startup.
## to tolerate restarts use declare.
def setup do
Histogram.new([name: :http_request_duration_milliseconds,
labels: [:method],
buckets: [100, 300, 500, 750, 1000],
help: "Http Request execution time"])
end
def instrument(%{time: time, method: method}) do
Histogram.observe([name: :http_request_duration_milliseconds, labels: [method]], time)
end
end
```
"""
use Prometheus.Erlang, :prometheus_histogram
@doc """
Creates a histogram using `spec`.
Histogram cannot have a label named "le".
Raises `Prometheus.Error.MissingMetricSpecKey` if required `spec` key is missing.<br>
Raises `Prometheus.Error.InvalidMetricName` if metric name is invalid.<br>
Raises `Prometheus.Error.InvalidMetricHelp` if help is invalid.<br>
Raises `Prometheus.Error.InvalidMetricLabels` if labels isn't a list.<br>
Raises `Prometheus.Error.InvalidMetricName` if label name is invalid.
Raises `Prometheus.Error.MFAlreadyExists` if a histogram with the same `spec` exists.
Histogram Specific exceptions:
Raises `Prometheus.Error.HistogramNoBuckets` if buckets are missing, not a list, empty list or not known buckets spec.<br>
Raises `Prometheus.Error.HistogramInvalidBuckets` if buckets aren't in increasing order.<br>
Raises `Prometheus.Error.HistogramInvalidBound` if bucket bound isn't a number.
"""
defmacro new(spec) do
Erlang.call([spec])
end
@doc """
Creates a histogram using `spec`.
Histogram cannot have a label named "le".
If a histogram with the same `spec` exists returns `false`.
Raises `Prometheus.Error.MissingMetricSpecKey` if required `spec` key is missing.<br>
Raises `Prometheus.Error.InvalidMetricName` if metric name is invalid.<br>
Raises `Prometheus.Error.InvalidMetricHelp` if help is invalid.<br>
Raises `Prometheus.Error.InvalidMetricLabels` if labels isn't a list.<br>
Raises `Prometheus.Error.InvalidMetricName` if label name is invalid.
Histogram Specific exceptions:
Raises `Prometheus.Error.HistogramNoBuckets` if buckets are missing, not a list, empty list or not known buckets spec.<br>
Raises `Prometheus.Error.HistogramInvalidBuckets` if buckets aren't in increasing order.<br>
Raises `Prometheus.Error.HistogramInvalidBound` if bucket bound isn't a number.
"""
defmacro declare(spec) do
Erlang.call([spec])
end
@doc """
Observes the given amount.
Raises `Prometheus.Error.InvalidValue` exception if `amount` isn't a positive integer.<br>
Raises `Prometheus.Error.UnknownMetric` exception if a histogram for `spec` can't be found.<br>
Raises `Prometheus.Error.InvalidMetricArity` exception if labels count mismatch.
"""
defmacro observe(spec, amount \\ 1) do
Erlang.metric_call(spec, [amount])
end
@doc """
Observes the given amount.
If `amount` happened to be a float number even one time(!) you shouldn't use `observe/2` after dobserve.
Raises `Prometheus.Error.InvalidValue` exception if `amount` isn't a positive integer.<br>
Raises `Prometheus.Error.UnknownMetric` exception if a histogram for `spec` can't be found.<br>
Raises `Prometheus.Error.InvalidMetricArity` exception if labels count mismatch.
"""
defmacro dobserve(spec, amount \\ 1) do
Erlang.metric_call(spec, [amount])
end
@doc """
Observes the amount of microseconds spent executing `fun`.
Raises `Prometheus.Error.UnknownMetric` exception if a histogram for `spec` can't be found.<br>
Raises `Prometheus.Error.InvalidMetricArity` exception if labels count mismatch.
"""
defmacro observe_duration(spec, fun) do
Erlang.metric_call(spec, [fun])
end
+ @doc """
+ Removes histogram series identified by spec.
+
+ Raises `Prometheus.Error.UnknownMetric` exception if a gauge for `spec` can't be found.<br>
+ Raises `Prometheus.Error.InvalidMetricArity` exception if labels count mismatch.
+ """
+ defmacro remove(spec) do
+ Erlang.metric_call(spec)
+ end
+
@doc """
Resets the value of the histogram identified by `spec`.
Raises `Prometheus.Error.UnknownMetric` exception if a histogram for `spec` can't be found.<br>
Raises `Prometheus.Error.InvalidMetricArity` exception if labels count mismatch.
"""
defmacro reset(spec) do
Erlang.metric_call(spec)
end
@doc """
Returns the value of the histogram identified by `spec`. If there is no histogram for
given labels combination, returns `:undefined`.
Raises `Prometheus.Error.UnknownMetric` exception if a histogram for `spec` can't be found.<br>
Raises `Prometheus.Error.InvalidMetricArity` exception if labels count mismatch.
"""
defmacro value(spec) do
Erlang.metric_call(spec)
end
end
diff --git a/lib/prometheus/metric/summary.ex b/lib/prometheus/metric/summary.ex
index 643713f..b9c7698 100644
--- a/lib/prometheus/metric/summary.ex
+++ b/lib/prometheus/metric/summary.ex
@@ -1,125 +1,135 @@
defmodule Prometheus.Metric.Summary do
@moduledoc """
Summary metric, to track the size of events.
Example use cases for Summaries:
- Response latency;
- Request size;
- Response size.
Example:
```
defmodule MyProxyInstrumenter do
use Prometheus.Metric
## to be called at app/supervisor startup.
## to tolerate restarts use declare.
def setup() do
Summary.declare([name: :request_size_bytes,
help: "Request size in bytes."])
Summary.declare([name: :response_size_bytes,
help: "Response size in bytes."])
end
def observe_request(size) do
Summary.observe([name: :request_size_bytes], size)
end
def observe_response(size) do
Summary.observe([name: :response_size_bytes], size)
end
end
```
"""
use Prometheus.Erlang, :prometheus_summary
@doc """
Creates a summary using `spec`.
Summary cannot have a label named "quantile".
Raises `Prometheus.Error.MissingMetricSpecKey` if required `spec` key is missing.<br>
Raises `Prometheus.Error.InvalidMetricName` if metric name is invalid.<br>
Raises `Prometheus.Error.InvalidMetricHelp` if help is invalid.<br>
Raises `Prometheus.Error.InvalidMetricLabels` if labels isn't a list.<br>
Raises `Prometheus.Error.InvalidMetricName` if label name is invalid.<br>
Raises `Prometheus.Error.MFAlreadyExists` if a summary with the same `spec` already exists.
"""
defmacro new(spec) do
Erlang.call([spec])
end
@doc """
Creates a summary using `spec`.
Summary cannot have a label named "quantile".
If a summary with the same `spec` exists returns `false`.
Raises `Prometheus.Error.MissingMetricSpecKey` if required `spec` key is missing.<br>
Raises `Prometheus.Error.InvalidMetricName` if metric name is invalid.<br>
Raises `Prometheus.Error.InvalidMetricHelp` if help is invalid.<br>
Raises `Prometheus.Error.InvalidMetricLabels` if labels isn't a list.<br>
Raises `Prometheus.Error.InvalidMetricName` if label name is invalid.
"""
defmacro declare(spec) do
Erlang.call([spec])
end
@doc """
Observes the given amount.
Raises `Prometheus.Error.InvalidValue` exception if `amount` isn't a positive integer.<br>
Raises `Prometheus.Error.UnknownMetric` exception if a summary for `spec` can't be found.<br>
Raises `Prometheus.Error.InvalidMetricArity` exception if labels count mismatch.
"""
defmacro observe(spec, amount \\ 1) do
Erlang.metric_call(spec, [amount])
end
@doc """
Observes the given amount.
If `amount` happened to be a float number even one time(!) you shouldn't use `observe/2` after dobserve.
Raises `Prometheus.Error.InvalidValue` exception if `amount` isn't a positive integer.<br>
Raises `Prometheus.Error.UnknownMetric` exception if a summary for `spec` can't be found.<br>
Raises `Prometheus.Error.InvalidMetricArity` exception if labels count mismatch.
"""
defmacro dobserve(spec, amount \\ 1) do
Erlang.metric_call(spec, [amount])
end
@doc """
Observes the amount of microseconds spent executing `fun`.
Raises `Prometheus.Error.UnknownMetric` exception if a summary for `spec` can't be found.<br>
Raises `Prometheus.Error.InvalidMetricArity` exception if labels count mismatch.
"""
defmacro observe_duration(spec, fun) do
Erlang.metric_call(spec, [fun])
end
+ @doc """
+ Removes summary series identified by spec.
+
+ Raises `Prometheus.Error.UnknownMetric` exception if a gauge for `spec` can't be found.<br>
+ Raises `Prometheus.Error.InvalidMetricArity` exception if labels count mismatch.
+ """
+ defmacro remove(spec) do
+ Erlang.metric_call(spec)
+ end
+
@doc """
Resets the value of the summary identified by `spec`.
Raises `Prometheus.Error.UnknownMetric` exception if a summary for `spec` can't be found.<br>
Raises `Prometheus.Error.InvalidMetricArity` exception if labels count mismatch.
"""
defmacro reset(spec) do
Erlang.metric_call(spec)
end
@doc """
Returns the value of the summary identified by `spec`. If there is no summary for
given labels combination, returns `:undefined`.
Raises `Prometheus.Error.UnknownMetric` exception if a summary for `spec` can't be found.<br>
Raises `Prometheus.Error.InvalidMetricArity` exception if labels count mismatch.
"""
defmacro value(spec) do
Erlang.metric_call(spec)
end
end
diff --git a/lib/prometheus/model.ex b/lib/prometheus/model.ex
index 1c3320b..460ffc7 100644
--- a/lib/prometheus/model.ex
+++ b/lib/prometheus/model.ex
@@ -1,94 +1,118 @@
defmodule Prometheus.Model do
@moduledoc """
Helpers for working with Prometheus data model. For advanced users.
Probably will be used with `Prometheus.Collector`.
"""
use Prometheus.Erlang, :prometheus_model_helpers
@doc """
Create Metric Family of `type`, `name` and `help`.
`collector.collect_metrics/2` callback will be called and expected to
return individual metrics list.
"""
defmacro create_mf(name, help, type, collector, collector_data) do
Erlang.call([name, help, type, collector, collector_data])
end
@doc """
Creates gauge metrics from `mdata` {label, value} tuple list.
iex(11)> Prometheus.Model.gauge_metrics([{[host: "example.com"], 100}])
[{:Metric, [{:LabelPair, "host", "example.com"}], {:Gauge, 100}, :undefined,
:undefined, :undefined, :undefined, :undefined}]
"""
defmacro gauge_metrics(mdata) do
Erlang.call([mdata])
end
@doc """
Creates gauge metric with `value` and `labels`
iex(13)> Prometheus.Model.gauge_metric(100, [host: "example.com"])
{:Metric, [{:LabelPair, "host", "example.com"}], {:Gauge, 100}, :undefined,
:undefined, :undefined, :undefined, :undefined}
"""
defmacro gauge_metric(value, labels \\ []) do
Erlang.call([labels, value])
end
+ @doc """
+ Creates untyped metrics from `mdata` {label, value} tuple list.
+
+ iex(11)> Prometheus.Model.untyped_metrics([{[host: "example.com"], 100}])
+ [{:Metric, [{:LabelPair, "host", "example.com"}], :undefined,
+ :undefined, :undefined, {:Untyped, 100}, :undefined, :undefined}]
+
+ """
+ defmacro untyped_metrics(mdata) do
+ Erlang.call([mdata])
+ end
+
+ @doc """
+ Creates untyped metric with `value` and `labels`
+
+ iex(13)> Prometheus.Model.untyped_metric(100, [host: "example.com"])
+ {:Metric, [{:LabelPair, "host", "example.com"}], :undefined,
+ :undefined, :undefined, {:Untyped, 100}, :undefined, :undefined}
+
+ """
+ defmacro untyped_metric(value, labels \\ []) do
+ Erlang.call([labels, value])
+ end
+
@doc """
Creates counter metrics from `mdata` {labels, value} tuple list.
iex(14)> Prometheus.Model.counter_metrics([{[host: "example.com"], 100}])
[{:Metric, [{:LabelPair, "host", "example.com"}], :undefined, {:Counter, 100},
:undefined, :undefined, :undefined, :undefined}]
"""
defmacro counter_metrics(mdata) do
Erlang.call([mdata])
end
@doc """
Creates counter metric with `value` and `labels`.
iex(15)> Prometheus.Model.counter_metric(100, [host: "example.com"])
{:Metric, [{:LabelPair, "host", "example.com"}], :undefined, {:Counter, 100},
:undefined, :undefined, :undefined, :undefined}
"""
defmacro counter_metric(value, labels \\ []) do
Erlang.call([labels, value])
end
@doc """
Creates summary metrics from `mdata` {labels, count, sum} tuple list.
"""
defmacro summary_metrics(mdata) do
Erlang.call([mdata])
end
@doc """
Creates summary metric with `count`, `sum` and `labels`.
"""
defmacro summary_metric(count, sum, labels \\ []) do
Erlang.call([labels, count, sum])
end
@doc """
Creates histogram metrics from `mdata` {labels, buckets, count, sum} tuple list.
"""
defmacro histogram_metrics(mdata) do
Erlang.call([mdata])
end
@doc """
Creates histogram metric with `buckets`, `count`, `sum`, and `labels`.
"""
defmacro histogram_metric(buckets, count, sum, labels \\ []) do
Erlang.call([labels, buckets, count, sum])
end
end
diff --git a/mix.exs b/mix.exs
index 2478a31..e446681 100644
--- a/mix.exs
+++ b/mix.exs
@@ -1,48 +1,48 @@
defmodule PrometheusEx.Mixfile do
use Mix.Project
@version "1.0.0-alpha4"
def project do
[app: :prometheus_ex,
version: @version,
elixir: "~> 1.3",
build_embedded: Mix.env == :prod,
start_permanent: Mix.env == :prod,
description: description,
package: package,
name: "Prometheus.ex",
deps: deps(),
docs: [main: Prometheus,
source_ref: "v#{@version}",
source_url: "https://github.com/deadtrickster/prometheus.ex"]]
end
def application do
[applications: [:logger,
:prometheus]]
end
defp description do
"""
Elixir-friendly Prometheus monitoring system client.
"""
end
defp package do
[maintainers: ["Ilya Khaprov"],
licenses: ["MIT"],
links: %{"GitHub" => "https://github.com/deadtrickster/prometheus.ex",
"Prometheus.erl" => "https://hex.pm/packages/prometheus",
"Ecto Instrumenter" => "https://hex.pm/packages/prometheus_ecto",
"Phoenix Instrumenter" => "https://hex.pm/packages/prometheus_phoenix",
"Plugs Instrumenter/Exporter" => "https://hex.pm/packages/prometheus_plugs",
"Process info Collector" => "https://hex.pm/packages/prometheus_process_collector"}]
end
defp deps do
- [{:prometheus, "~> 3.0.0-alpha4"},
+ [{:prometheus, "~> 3.0.0-alpha5"},
{:ex_doc, "~> 0.11", only: :dev},
{:earmark, ">= 0.0.0", only: :dev}]
end
end

File Metadata

Mime Type
text/x-diff
Expires
Thu, Oct 29, 9:18 AM (19 h, 20 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1797847
Default Alt Text
(27 KB)

Event Timeline