Current section

Files

Jump to
themis src themis.erl
Raw

src/themis.erl

-module(themis).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch]).
-define(FILEPATH, "src/themis.gleam").
-export([init/0, print/0]).
-export_type([themis_error/0]).
-if(?OTP_RELEASE >= 27).
-define(MODULEDOC(Str), -moduledoc(Str)).
-define(DOC(Str), -doc(Str)).
-else.
-define(MODULEDOC(Str), -compile([])).
-define(DOC(Str), -compile([])).
-endif.
-type themis_error() :: {gauge_error, themis@gauge:gauge_error()} |
{histogram_error, themis@histogram:histogram_error()} |
{counter_error, themis@counter:counter_error()}.
-file("src/themis.gleam", 14).
?DOC(" Initializes a new empty metrics store.\n").
-spec init() -> gleam@erlang@atom:atom_().
init() ->
themis@internal@store:init().
-file("src/themis.gleam", 29).
?DOC(
" Formats all metrics in the store as a Prometheus-compatible text string.\n"
"\n"
" ## Examples\n"
"\n"
" ```gleam\n"
" let metrics_text = print(store)\n"
" // # HELP my_metric My first gauge\n"
" // # TYPE my_metric gauge\n"
" // my_metric{foo=\"bar\"} 10\n"
" // my_metric{toto=\"tata\",wibble=\"wobble\"} +Inf\n"
" ```\n"
).
-spec print() -> {ok, binary()} | {error, themis_error()}.
print() ->
gleam@result:'try'(
begin
_pipe = themis@gauge:print(),
gleam@result:map_error(_pipe, fun(E) -> {gauge_error, E} end)
end,
fun(Gauges_print) ->
gleam@result:'try'(
begin
_pipe@1 = themis@counter:print(),
gleam@result:map_error(
_pipe@1,
fun(E@1) -> {counter_error, E@1} end
)
end,
fun(Counters_print) ->
gleam@result:'try'(
begin
_pipe@2 = themis@histogram:print(),
gleam@result:map_error(
_pipe@2,
fun(E@2) -> {histogram_error, E@2} end
)
end,
fun(Histograms_print) ->
_pipe@3 = (<<<<<<<<Gauges_print/binary, "\n"/utf8>>/binary,
Counters_print/binary>>/binary,
"\n"/utf8>>/binary,
Histograms_print/binary>>),
{ok, _pipe@3}
end
)
end
)
end
).