Skip to content

Commit

Permalink
Move export prometheus_text_format:escape_label_value outside of TEST…
Browse files Browse the repository at this point in the history
… def
  • Loading branch information
aaron-seo committed Oct 16, 2023
1 parent b78e17e commit e3f2c8d
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions src/formats/prometheus_text_format.erl
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,12 @@
-export([content_type/0,
format/0,
format/1,
render_labels/1]).
render_labels/1,
escape_label_value/1
]).

-ifdef(TEST).
-export([escape_metric_help/1,
escape_label_value/1,
emit_mf_prologue/2,
emit_mf_metrics/2
]).
Expand Down Expand Up @@ -76,6 +77,15 @@ format(Registry) ->
ok = file:close(Fd),
Str.

-spec escape_label_value(binary() | iolist() | undefined) -> binary().
%% @doc
%% Escapes the backslash (\), double-quote ("), and line feed (\n) characters
%% @end
escape_label_value(LValue) when is_list(LValue); is_binary(LValue) ->
escape_string(fun escape_label_char/1, LValue);
escape_label_value(Value) ->
erlang:error({wtf, Value}).

%%====================================================================
%% Private Parts
%%====================================================================
Expand Down Expand Up @@ -227,13 +237,6 @@ bound_to_label_value(Bound) when is_float(Bound) ->
bound_to_label_value(infinity) ->
"+Inf".

-spec escape_label_value(binary() | iolist() | undefined) -> binary().
%% @private
escape_label_value(LValue) when is_list(LValue); is_binary(LValue) ->
escape_string(fun escape_label_char/1, LValue);
escape_label_value(Value) ->
erlang:error({wtf, Value}).

%% @private
escape_label_char($\\ = X) ->
<<X, X>>;
Expand Down

0 comments on commit e3f2c8d

Please sign in to comment.