Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F113580
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Size
26 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/lib/prometheus/buckets.ex b/lib/prometheus/buckets.ex
index f2def16..418710b 100644
--- a/lib/prometheus/buckets.ex
+++ b/lib/prometheus/buckets.ex
@@ -1,19 +1,27 @@
defmodule Prometheus.Buckets do
+ require Prometheus.Error
+
defmacro default do
:prometheus_buckets.default()
end
defmacro linear(start, step, count) do
quote do
- :prometheus_buckets.linear(unquote(start), unquote(step), unquote(count))
+ require Prometheus.Error
+ Prometheus.Error.with_prometheus_error(
+ :prometheus_buckets.linear(unquote(start), unquote(step), unquote(count))
+ )
end
end
defmacro exponential(start, factor, count) do
quote do
- :prometheus_buckets.exponential(unquote(start), unquote(factor), unquote(count))
+ require Prometheus.Error
+ Prometheus.Error.with_prometheus_error(
+ :prometheus_buckets.exponential(unquote(start), unquote(factor), unquote(count))
+ )
end
end
-
+
end
diff --git a/lib/prometheus/collector.ex b/lib/prometheus/collector.ex
index ae59a7e..a7f3b9e 100644
--- a/lib/prometheus/collector.ex
+++ b/lib/prometheus/collector.ex
@@ -1,21 +1,32 @@
defmodule Prometheus.Collector do
+ require Prometheus.Error
+
defmacro register(collector, registry \\ :default) do
quote do
- :prometheus_registry.register_collector(unquote(collector), unquote(registry))
+ require Prometheus.Error
+ Prometheus.Error.with_prometheus_error(
+ :prometheus_registry.register_collector(unquote(collector), unquote(registry))
+ )
end
end
defmacro deregister(collector, registry \\ :default) do
quote do
- :prometheus_registry.deregister_collector(unquote(collector), unquote(registry))
+ require Prometheus.Error
+ Prometheus.Error.with_prometheus_error(
+ :prometheus_registry.deregister_collector(unquote(collector), unquote(registry))
+ )
end
end
defmacro collecto_mf(collector, callback, registry \\ :default) do
quote do
- :prometheus_collector.collect_mf(unquote(collector), unquote(callback), unquote(registry))
+ require Prometheus.Error
+ Prometheus.Error.with_prometheus_error(
+ :prometheus_collector.collect_mf(unquote(collector), unquote(callback), unquote(registry))
+ )
end
end
-
+
end
diff --git a/lib/prometheus/contrib/http.ex b/lib/prometheus/contrib/http.ex
index 05df086..34368f2 100644
--- a/lib/prometheus/contrib/http.ex
+++ b/lib/prometheus/contrib/http.ex
@@ -1,11 +1,14 @@
defmodule Prometheus.Contrib.HTTP do
defmacro microseconds_duration_buckets do
:prometheus_http.microseconds_duration_buckets
end
defmacro status_class(code) do
- quote do
- :prometheus_http.status_class(unquote(code))
+ quote do
+ require Prometheus.Error
+ Prometheus.Error.with_prometheus_error(
+ :prometheus_http.status_class(unquote(code))
+ )
end
end
end
diff --git a/lib/prometheus/error.ex b/lib/prometheus/error.ex
index 4fa5ea8..2479eb1 100644
--- a/lib/prometheus/error.ex
+++ b/lib/prometheus/error.ex
@@ -1,107 +1,107 @@
defmodule Prometheus.Error do
defmodule InvalidValue do
defexception [:value, :message]
end
defmodule InvalidMetricName do
defexception [:name, :message]
end
defmodule InvalidMetricHelp do
defexception [:help, :message]
end
defmodule InvalidMetricArity do
defexception [:arity]
def message(%{arity: arity}) do
"invalid metric arity: #{arity}"
end
end
defmodule UnknownMetric do
defexception [:registry, :name]
def message(%{registry: registry, name: name}) do
"unknown metric {registry: #{registry}, name: #{name}}"
end
end
defmodule InvalidMetricLabels do
defexception [:labels, :message]
end
defmodule InvalidLabelName do
defexception [:name, :message]
end
defmodule MFAlreadyExists do
defexception [:registry, :name, :message]
end
defmodule HistogramNoBuckets do
defexception [:buckets, :message]
end
defmodule HistogramInvalidBuckets do
defexception [:buckets, :message]
end
defmodule HistogramInvalidBound do
defexception [:bound, :message]
end
defmodule MissingMetricSpecKey do
defexception [:key, :spec, :message]
end
def normalize(erlang_error) do
case erlang_error do
- %{original: original} ->
+ %ErlangError{original: original} ->
case original do
{:invalid_value, value, message} ->
%InvalidValue{value: value, message: message}
{:invalid_metric_name, name, message} ->
%InvalidMetricName{name: name, message: message}
{:invalid_metric_help, help, message} ->
%InvalidMetricHelp{help: help, message: message}
{:invalid_metric_arity, arity} ->
%InvalidMetricArity{arity: arity}
{:unknown_metric, registry, name} ->
%UnknownMetric{registry: registry, name: name}
{:invalid_metric_labels, labels, message} ->
%InvalidMetricLabels{labels: labels, message: message}
{:invalid_metric_label_name, name, message} ->
%InvalidLabelName{name: name, message: message}
{:mf_already_exists, {registry, name}, message} ->
%MFAlreadyExists{registry: registry, name: name, message: message}
{:histogram_no_buckets, buckets} ->
%HistogramNoBuckets{buckets: buckets}
{:histogram_invalid_buckets, buckets} ->
%HistogramInvalidBuckets{buckets: buckets, message: "buckets are invalid"}
{:histogram_invalid_buckets, buckets, message} ->
%HistogramInvalidBuckets{buckets: buckets, message: message}
{:histogram_invalid_bound, bound} ->
%HistogramInvalidBound{bound: bound, message: "bound is invalid"}
{:missing_metric_spec_key, key, spec} ->
%MissingMetricSpecKey{key: key, spec: spec}
_ ->
erlang_error
end
_ ->
erlang_error
end
end
defmacro with_prometheus_error(block) do
quote do
try do
unquote(block)
rescue
- e in ErlangError -> raise Prometheus.Error.normalize(e)
+ e in ErlangError -> reraise Prometheus.Error.normalize(e), System.stacktrace
end
end
end
end
diff --git a/lib/prometheus/format/protobuf.ex b/lib/prometheus/format/protobuf.ex
index f2efc5d..1bb1ad8 100644
--- a/lib/prometheus/format/protobuf.ex
+++ b/lib/prometheus/format/protobuf.ex
@@ -1,11 +1,19 @@
defmodule Prometheus.Format.Protobuf do
+ require Prometheus.Error
+
def content_type do
- :prometheus_protobuf_format.content_type
+ require Prometheus.Error
+ Prometheus.Error.with_prometheus_error(
+ :prometheus_protobuf_format.content_type
+ )
end
def format(registry \\ :default) do
- :prometheus_protobuf_format.format(registry)
+ require Prometheus.Error
+ Prometheus.Error.with_prometheus_error(
+ :prometheus_protobuf_format.format(registry)
+ )
end
-
+
end
diff --git a/lib/prometheus/format/text.ex b/lib/prometheus/format/text.ex
index 9f46c04..3819299 100644
--- a/lib/prometheus/format/text.ex
+++ b/lib/prometheus/format/text.ex
@@ -1,11 +1,19 @@
defmodule Prometheus.Format.Text do
+ require Prometheus.Error
+
def content_type do
- :prometheus_text_format.content_type
+ require Prometheus.Error
+ Prometheus.Error.with_prometheus_error(
+ :prometheus_text_format.content_type
+ )
end
def format(registry \\ :default) do
- :prometheus_text_format.format(registry)
+ require Prometheus.Error
+ Prometheus.Error.with_prometheus_error(
+ :prometheus_text_format.format(registry)
+ )
end
-
+
end
diff --git a/lib/prometheus/metric/counter.ex b/lib/prometheus/metric/counter.ex
index 9c797e3..81f66d4 100644
--- a/lib/prometheus/metric/counter.ex
+++ b/lib/prometheus/metric/counter.ex
@@ -1,51 +1,71 @@
defmodule Prometheus.Metric.Counter do
+
alias Prometheus.Metric
-
+ require Prometheus.Error
+
defmacro new(spec) do
{registry, _, _} = Metric.parse_spec(spec)
quote do
- :prometheus_counter.new(unquote(spec), unquote(registry))
+ require Prometheus.Error
+ Prometheus.Error.with_prometheus_error(
+ :prometheus_counter.new(unquote(spec), unquote(registry))
+ )
end
end
defmacro declare(spec) do
{registry, _, _} = Metric.parse_spec(spec)
quote do
- :prometheus_counter.declare(unquote(spec), unquote(registry))
+ require Prometheus.Error
+ Prometheus.Error.with_prometheus_error(
+ :prometheus_counter.declare(unquote(spec), unquote(registry))
+ )
end
end
defmacro inc(spec, value \\ 1) do
{registry, name, labels} = Metric.parse_spec(spec)
quote do
- :prometheus_counter.inc(unquote(registry), unquote(name), unquote(labels), unquote(value))
+ require Prometheus.Error
+ Prometheus.Error.with_prometheus_error(
+ :prometheus_counter.inc(unquote(registry), unquote(name), unquote(labels), unquote(value))
+ )
end
end
defmacro dinc(spec, value \\ 1) do
{registry, name, labels} = Metric.parse_spec(spec)
quote do
- :prometheus_counter.dinc(unquote(registry), unquote(name), unquote(labels), unquote(value))
+ require Prometheus.Error
+ Prometheus.Error.with_prometheus_error(
+ :prometheus_counter.dinc(unquote(registry), unquote(name), unquote(labels), unquote(value))
+ )
end
end
defmacro reset(spec) do
{registry, name, labels} = Metric.parse_spec(spec)
-
+
quote do
- :prometheus_counter.reset(unquote(registry), unquote(name), unquote(labels))
+ require Prometheus.Error
+ Prometheus.Error.with_prometheus_error(
+ :prometheus_counter.reset(unquote(registry), unquote(name), unquote(labels))
+ )
end
- end
+ end
defmacro value(spec) do
{registry, name, labels} = Metric.parse_spec(spec)
-
+
quote do
- :prometheus_counter.value(unquote(registry), unquote(name), unquote(labels))
+ require Prometheus.Error
+ Prometheus.Error.with_prometheus_error(
+ :prometheus_counter.value(unquote(registry), unquote(name), unquote(labels))
+ )
end
end
end
diff --git a/lib/prometheus/metric/gauge.ex b/lib/prometheus/metric/gauge.ex
index 6470d5e..98ab63f 100644
--- a/lib/prometheus/metric/gauge.ex
+++ b/lib/prometheus/metric/gauge.ex
@@ -1,59 +1,82 @@
defmodule Prometheus.Metric.Gauge do
+
alias Prometheus.Metric
-
+ require Prometheus.Error
+
defmacro new(spec) do
{registry, _, _} = Metric.parse_spec(spec)
quote do
- :prometheus_gauge.new(unquote(spec), unquote(registry))
+ require Prometheus.Error
+ Prometheus.Error.with_prometheus_error(
+ :prometheus_gauge.new(unquote(spec), unquote(registry))
+ )
end
end
defmacro declare(spec) do
{registry, _, _} = Metric.parse_spec(spec)
quote do
- :prometheus_gauge.declare(unquote(spec), unquote(registry))
+ require Prometheus.Error
+ Prometheus.Error.with_prometheus_error(
+ :prometheus_gauge.declare(unquote(spec), unquote(registry))
+ )
end
end
defmacro set(spec, value) do
{registry, name, labels} = Metric.parse_spec(spec)
quote do
- :prometheus_gauge.set(unquote(registry), unquote(name), unquote(labels), unquote(value))
+ require Prometheus.Error
+ Prometheus.Error.with_prometheus_error(
+ :prometheus_gauge.set(unquote(registry), unquote(name), unquote(labels), unquote(value))
+ )
end
end
defmacro set_to_current_time(spec) do
{registry, name, labels} = Metric.parse_spec(spec)
quote do
- :prometheus_gauge.set_to_current_time(unquote(registry), unquote(name), unquote(labels))
+ require Prometheus.Error
+ Prometheus.Error.with_prometheus_error(
+ :prometheus_gauge.set_to_current_time(unquote(registry), unquote(name), unquote(labels))
+ )
end
- end
+ end
defmacro track_inprogress(spec, fun) do
{registry, name, labels} = Metric.parse_spec(spec)
quote do
- :prometheus_gauge.track_inprogress(unquote(registry), unquote(name), unquote(labels), unquote(fun))
+ require Prometheus.Error
+ Prometheus.Error.with_prometheus_error(
+ :prometheus_gauge.track_inprogress(unquote(registry), unquote(name), unquote(labels), unquote(fun))
+ )
end
end
defmacro reset(spec) do
{registry, name, labels} = Metric.parse_spec(spec)
-
+
quote do
- :prometheus_gauge.reset(unquote(registry), unquote(name), unquote(labels))
+ require Prometheus.Error
+ Prometheus.Error.with_prometheus_error(
+ :prometheus_gauge.reset(unquote(registry), unquote(name), unquote(labels))
+ )
end
- end
+ end
defmacro value(spec) do
{registry, name, labels} = Metric.parse_spec(spec)
-
+
quote do
- :prometheus_gauge.value(unquote(registry), unquote(name), unquote(labels))
+ require Prometheus.Error
+ Prometheus.Error.with_prometheus_error(
+ :prometheus_gauge.value(unquote(registry), unquote(name), unquote(labels))
+ )
end
end
end
diff --git a/lib/prometheus/metric/histogram.ex b/lib/prometheus/metric/histogram.ex
index 47f1f32..16d4e00 100644
--- a/lib/prometheus/metric/histogram.ex
+++ b/lib/prometheus/metric/histogram.ex
@@ -1,64 +1,87 @@
defmodule Prometheus.Metric.Histogram do
+
alias Prometheus.Metric
+ require Prometheus.Error
defmacro new(spec) do
{registry, _, _} = Metric.parse_spec(spec)
quote do
- :prometheus_histogram.new(unquote(spec), unquote(registry))
+ require Prometheus.Error
+ Prometheus.Error.with_prometheus_error(
+ :prometheus_histogram.new(unquote(spec), unquote(registry))
+ )
end
end
defmacro declare(spec) do
{registry, _, _} = Metric.parse_spec(spec)
quote do
- :prometheus_histogram.declare(unquote(spec), unquote(registry))
+ require Prometheus.Error
+ Prometheus.Error.with_prometheus_error(
+ :prometheus_histogram.declare(unquote(spec), unquote(registry))
+ )
end
end
defmacro observe(spec, value \\ 1) do
{registry, name, labels} = Metric.parse_spec(spec)
quote do
- :prometheus_histogram.observe(unquote(registry),
- unquote(name), unquote(labels), unquote(value))
+ require Prometheus.Error
+ Prometheus.Error.with_prometheus_error(
+ :prometheus_histogram.observe(unquote(registry),
+ unquote(name), unquote(labels), unquote(value))
+ )
end
end
defmacro dobserve(spec, value \\ 1) do
{registry, name, labels} = Metric.parse_spec(spec)
quote do
- :prometheus_histogram.dobserve(unquote(registry),
- unquote(name), unquote(labels), unquote(value))
+ require Prometheus.Error
+ Prometheus.Error.with_prometheus_error(
+ :prometheus_histogram.dobserve(unquote(registry),
+ unquote(name), unquote(labels), unquote(value))
+ )
end
end
defmacro observe_duration(spec, fun) do
{registry, name, labels} = Metric.parse_spec(spec)
quote do
- :prometheus_histogram.observe_duration(unquote(name),
- unquote(registry), unquote(labels), unquote(fun))
+ require Prometheus.Error
+ Prometheus.Error.with_prometheus_error(
+ :prometheus_histogram.observe_duration(unquote(name),
+ unquote(registry), unquote(labels), unquote(fun))
+ )
end
end
defmacro reset(spec) do
{registry, name, labels} = Metric.parse_spec(spec)
quote do
- :prometheus_histogram.reset(unquote(registry),
- unquote(name), unquote(labels))
+ require Prometheus.Error
+ Prometheus.Error.with_prometheus_error(
+ :prometheus_histogram.reset(unquote(registry),
+ unquote(name), unquote(labels))
+ )
end
end
defmacro value(spec) do
{registry, name, labels} = Metric.parse_spec(spec)
quote do
- :prometheus_histogram.value(unquote(registry),
- unquote(name), unquote(labels))
+ require Prometheus.Error
+ Prometheus.Error.with_prometheus_error(
+ :prometheus_histogram.value(unquote(registry),
+ unquote(name), unquote(labels))
+ )
end
end
end
diff --git a/lib/prometheus/metric/summary.ex b/lib/prometheus/metric/summary.ex
index e89b3d6..e955525 100644
--- a/lib/prometheus/metric/summary.ex
+++ b/lib/prometheus/metric/summary.ex
@@ -1,64 +1,87 @@
defmodule Prometheus.Metric.Summary do
+
alias Prometheus.Metric
+ require Prometheus.Error
defmacro new(spec) do
{registry, _, _} = Metric.parse_spec(spec)
quote do
- :prometheus_summary.new(unquote(spec), unquote(registry))
+ require Prometheus.Error
+ Prometheus.Error.with_prometheus_error(
+ :prometheus_summary.new(unquote(spec), unquote(registry))
+ )
end
end
defmacro declare(spec) do
{registry, _, _} = Metric.parse_spec(spec)
quote do
- :prometheus_summary.declare(unquote(spec), unquote(registry))
+ require Prometheus.Error
+ Prometheus.Error.with_prometheus_error(
+ :prometheus_summary.declare(unquote(spec), unquote(registry))
+ )
end
end
defmacro observe(spec, value \\ 1) do
{registry, name, labels} = Metric.parse_spec(spec)
quote do
- :prometheus_summary.observe(unquote(registry),
- unquote(name), unquote(labels), unquote(value))
+ require Prometheus.Error
+ Prometheus.Error.with_prometheus_error(
+ :prometheus_summary.observe(unquote(registry),
+ unquote(name), unquote(labels), unquote(value))
+ )
end
end
defmacro dobserve(spec, value \\ 1) do
{registry, name, labels} = Metric.parse_spec(spec)
quote do
- :prometheus_summary.dobserve(unquote(registry),
- unquote(name), unquote(labels), unquote(value))
+ require Prometheus.Error
+ Prometheus.Error.with_prometheus_error(
+ :prometheus_summary.dobserve(unquote(registry),
+ unquote(name), unquote(labels), unquote(value))
+ )
end
end
defmacro observe_duration(spec, fun) do
{registry, name, labels} = Metric.parse_spec(spec)
quote do
- :prometheus_summary.observe_duration(unquote(name),
- unquote(registry), unquote(labels), unquote(fun))
+ require Prometheus.Error
+ Prometheus.Error.with_prometheus_error(
+ :prometheus_summary.observe_duration(unquote(name),
+ unquote(registry), unquote(labels), unquote(fun))
+ )
end
end
defmacro reset(spec) do
{registry, name, labels} = Metric.parse_spec(spec)
quote do
- :prometheus_summary.reset(unquote(registry),
- unquote(name), unquote(labels))
+ require Prometheus.Error
+ Prometheus.Error.with_prometheus_error(
+ :prometheus_summary.reset(unquote(registry),
+ unquote(name), unquote(labels))
+ )
end
end
defmacro value(spec) do
{registry, name, labels} = Metric.parse_spec(spec)
quote do
- :prometheus_summary.value(unquote(registry),
- unquote(name), unquote(labels))
+ require Prometheus.Error
+ Prometheus.Error.with_prometheus_error(
+ :prometheus_summary.value(unquote(registry),
+ unquote(name), unquote(labels))
+ )
end
end
end
diff --git a/lib/prometheus/model.ex b/lib/prometheus/model.ex
index 4c09746..9ab2e5a 100644
--- a/lib/prometheus/model.ex
+++ b/lib/prometheus/model.ex
@@ -1,69 +1,104 @@
defmodule Prometheus.Model do
+ require Prometheus.Error
+
defmacro create_mf(name, help, type, collector, collector_data) do
quote do
- :prometheus_model_helpers.create_mf(unquote(name), unquote(help), unquote(type), unquote(collector), unquote(collector_data))
+ require Prometheus.Error
+ Prometheus.Error.with_prometheus_error(
+ :prometheus_model_helpers.create_mf(unquote(name), unquote(help), unquote(type), unquote(collector), unquote(collector_data))
+ )
end
end
defmacro gauge_metrics(mdata) do
quote do
- :prometheus_model_helpers.gauge_metrics(unquote(mdata))
+ require Prometheus.Error
+ Prometheus.Error.with_prometheus_error(
+ :prometheus_model_helpers.gauge_metrics(unquote(mdata))
+ )
end
end
defmacro gauge_metric(value, labels \\ []) do
quote do
- :prometheus_model_helpers.gauge_metric(unquote(labels), unquote(value))
+ require Prometheus.Error
+ Prometheus.Error.with_prometheus_error(
+ :prometheus_model_helpers.gauge_metric(unquote(labels), unquote(value))
+ )
end
end
defmacro counter_metrics(mdata) do
quote do
- :prometheus_model_helpers.counter_metrics(unquote(mdata))
+ require Prometheus.Error
+ Prometheus.Error.with_prometheus_error(
+ :prometheus_model_helpers.counter_metrics(unquote(mdata))
+ )
end
end
defmacro counter_metric(value, labels \\ []) do
quote do
- :prometheus_model_helpers.counter_metric(unquote(labels), unquote(value))
+ require Prometheus.Error
+ Prometheus.Error.with_prometheus_error(
+ :prometheus_model_helpers.counter_metric(unquote(labels), unquote(value))
+ )
end
end
defmacro summary_metrics(mdata) do
quote do
- :prometheus_model_helpers.summary_metrics(unquote(mdata))
+ require Prometheus.Error
+ Prometheus.Error.with_prometheus_error(
+ :prometheus_model_helpers.summary_metrics(unquote(mdata))
+ )
end
end
defmacro summary_metric(count, sum, labels \\ []) do
quote do
- :prometheus_model_helpers.summary_metric(unquote(labels), unquote(count), unquote(sum))
+ require Prometheus.Error
+ Prometheus.Error.with_prometheus_error(
+ :prometheus_model_helpers.summary_metric(unquote(labels), unquote(count), unquote(sum))
+ )
end
end
defmacro histogram_metrics(mdata) do
quote do
- :prometheus_model_helpers.histogram_metrics(unquote(mdata))
+ require Prometheus.Error
+ Prometheus.Error.with_prometheus_error(
+ :prometheus_model_helpers.histogram_metrics(unquote(mdata))
+ )
end
end
defmacro histogram_metric(buckets, count, sum, labels \\ []) do
quote do
- :prometheus_model_helpers.histogram_metric(unquote(labels), unquote(buckets), unquote(count), unquote(sum))
+ require Prometheus.Error
+ Prometheus.Error.with_prometheus_error(
+ :prometheus_model_helpers.histogram_metric(unquote(labels), unquote(buckets), unquote(count), unquote(sum))
+ )
end
end
defmacro label_pairs(labels) do
quote do
- :prometheus_model_helpers.label_pairs(unquote(labels))
+ require Prometheus.Error
+ Prometheus.Error.with_prometheus_error(
+ :prometheus_model_helpers.label_pairs(unquote(labels))
+ )
end
end
defmacro label_pair(name, value) do
quote do
- :prometheus_model_helpers.label_pair({unquote(name), unquote(value)})
+ require Prometheus.Error
+ Prometheus.Error.with_prometheus_error(
+ :prometheus_model_helpers.label_pair({unquote(name), unquote(value)})
+ )
end
end
end
diff --git a/lib/prometheus/registry.ex b/lib/prometheus/registry.ex
index 5ad1d6f..64baad8 100644
--- a/lib/prometheus/registry.ex
+++ b/lib/prometheus/registry.ex
@@ -1,39 +1,59 @@
defmodule Prometheus.Registry do
+ require Prometheus.Error
+
defmacro collect(callback, registry \\ :default) do
quote do
- :prometheus_registry.collect(unquote(registry), unquote(callback))
+ require Prometheus.Error
+ Prometheus.Error.with_prometheus_error(
+ :prometheus_registry.collect(unquote(registry), unquote(callback))
+ )
end
end
defmacro collectors(registry \\ :default) do
quote do
- :prometheus_registry.collectors(unquote(registry))
+ require Prometheus.Error
+ Prometheus.Error.with_prometheus_error(
+ :prometheus_registry.collectors(unquote(registry))
+ )
end
end
defmacro register_collector(collector, registry \\ :default) do
quote do
- :prometheus_registry.register_collector(unquote(registry), unquote(collector))
+ require Prometheus.Error
+ Prometheus.Error.with_prometheus_error(
+ :prometheus_registry.register_collector(unquote(registry), unquote(collector))
+ )
end
end
defmacro deregister_collector(collector, registry \\ :default) do
quote do
- :prometheus_registry.deregister_collector(unquote(registry), unquote(collector))
+ require Prometheus.Error
+ Prometheus.Error.with_prometheus_error(
+ :prometheus_registry.deregister_collector(unquote(registry), unquote(collector))
+ )
end
end
defmacro clear(registry \\ :default) do
quote do
- :prometheus_registry.clear(unquote(registry))
+ require Prometheus.Error
+ Prometheus.Error.with_prometheus_error(
+ :prometheus_registry.clear(unquote(registry))
+ )
end
end
defmacro collector_registred?(collector, registry \\ :default) do
quote do
- :prometheus_registry.collector_registeredp(unquote(registry), unquote(collector))
+ require Prometheus.Error
+ Prometheus.Error.with_prometheus_error(
+ :prometheus_registry.collector_registeredp(unquote(registry), unquote(collector))
+ )
end
end
-
+
end
diff --git a/test/buckets_test.exs b/test/buckets_test.exs
new file mode 100644
index 0000000..8bb5142
--- /dev/null
+++ b/test/buckets_test.exs
@@ -0,0 +1,12 @@
+defmodule PrometheusEx.BucketsTest do
+ use ExUnit.Case
+ alias Prometheus.Error
+ require Prometheus.Buckets
+
+
+ test "linear buckets generator errors" do
+ assert_raise Error.InvalidValue, fn ->
+ Prometheus.Buckets.linear(-15, 5, 0)
+ end
+ end
+end
diff --git a/test/prometheus_test.exs b/test/prometheus_test.exs
index 5111a98..f8875a5 100644
--- a/test/prometheus_test.exs
+++ b/test/prometheus_test.exs
@@ -1,8 +1,7 @@
defmodule PrometheusExTest do
use ExUnit.Case
- doctest PrometheusEx
test "the truth" do
assert 1 + 1 == 2
end
end
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Mon, Nov 25, 11:27 AM (1 d, 14 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
39771
Default Alt Text
(26 KB)
Attached To
Mode
R26 prometheus.ex
Attached
Detach File
Event Timeline
Log In to Comment