From e3f2c8d45916da7e3e51a288b909d00a29ebe131 Mon Sep 17 00:00:00 2001 From: Aaron Seo Date: Mon, 16 Oct 2023 12:35:26 -0700 Subject: [PATCH] Move export prometheus_text_format:escape_label_value outside of TEST def --- src/formats/prometheus_text_format.erl | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/formats/prometheus_text_format.erl b/src/formats/prometheus_text_format.erl index d8fec36d..216b3bbe 100644 --- a/src/formats/prometheus_text_format.erl +++ b/src/formats/prometheus_text_format.erl @@ -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 ]). @@ -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 %%==================================================================== @@ -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) -> <>;