-module(themis). -compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch]). -export([new/0, print/1, is_metric_name_used/2]). -export_type([store/0, store_error/0]). -type store() :: {store, gleam@dict:dict(internal@metric:metric_name(), internal@metric:metric(internal@metric@gauge:gauge(), internal@prometheus:number_())), gleam@dict:dict(internal@metric:metric_name(), internal@metric:metric(internal@metric@counter:counter(), internal@prometheus:number_())), gleam@dict:dict(internal@metric:metric_name(), internal@metric:metric(internal@metric@histogram:histogram(), internal@metric@histogram:histogram_record()))}. -type store_error() :: metric_name_already_in_use | metric_name_not_found | {metric_error, internal@metric:metric_error()} | {label_error, internal@label:label_error()} | {counter_error, internal@metric@counter:counter_error()} | {histogram_error, internal@metric@histogram:histogram_error()}. -file("/git/Themis/src/themis.gleam", 38). -spec new() -> store(). new() -> {store, maps:new(), maps:new(), maps:new()}. -file("/git/Themis/src/themis.gleam", 59). -spec print_gauges( gleam@dict:dict(internal@metric:metric_name(), internal@metric:metric(internal@metric@gauge:gauge(), internal@prometheus:number_())) ) -> binary(). print_gauges(Gauges) -> _pipe = (gleam@dict:fold( Gauges, [], fun(Current, Name, Gauge) -> [<<(internal@metric@gauge:print(Gauge, Name))/binary, "\n"/utf8>> | Current] end )), _pipe@1 = lists:reverse(_pipe), _pipe@2 = gleam_stdlib:identity(_pipe@1), unicode:characters_to_binary(_pipe@2). -file("/git/Themis/src/themis.gleam", 71). -spec print_counters( gleam@dict:dict(internal@metric:metric_name(), internal@metric:metric(internal@metric@counter:counter(), internal@prometheus:number_())) ) -> binary(). print_counters(Counters) -> _pipe = (gleam@dict:fold( Counters, [], fun(Current, Name, Counter) -> [<<(internal@metric@counter:print(Counter, Name))/binary, "\n"/utf8>> | Current] end )), _pipe@1 = lists:reverse(_pipe), _pipe@2 = gleam_stdlib:identity(_pipe@1), unicode:characters_to_binary(_pipe@2). -file("/git/Themis/src/themis.gleam", 83). -spec print_histograms( gleam@dict:dict(internal@metric:metric_name(), internal@metric:metric(internal@metric@histogram:histogram(), internal@metric@histogram:histogram_record())) ) -> binary(). print_histograms(Histograms) -> _pipe = (gleam@dict:fold( Histograms, [], fun(Current, Counter, Name) -> [<<(internal@metric@histogram:print(Name, Counter))/binary, "\n"/utf8>> | Current] end )), _pipe@1 = lists:reverse(_pipe), _pipe@2 = gleam_stdlib:identity(_pipe@1), unicode:characters_to_binary(_pipe@2). -file("/git/Themis/src/themis.gleam", 53). -spec print(store()) -> binary(). print(Store) -> <<<<(print_gauges(erlang:element(2, Store)))/binary, (print_counters(erlang:element(3, Store)))/binary>>/binary, (print_histograms(erlang:element(4, Store)))/binary>>. -file("/git/Themis/src/themis.gleam", 95). -spec is_metric_name_used(store(), internal@metric:metric_name()) -> boolean(). is_metric_name_used(Store, Name) -> gleam@bool:guard( gleam@dict:has_key(erlang:element(2, Store), Name), true, fun() -> gleam@bool:guard( gleam@dict:has_key(erlang:element(3, Store), Name), true, fun() -> gleam@bool:guard( gleam@dict:has_key(erlang:element(4, Store), Name), true, fun() -> false end ) end ) end ).