Closed mkuratczyk closed 6 months ago
It's better to pre-render global labels once to a single binary, outside the callback function - otherwise relatively large set of global labels can crash performance even if the app pre-renders labels itself.
Pre-rendered metrics are only compatible with text collector (protobuf is probably not being used by anyone, but the source code still exists here). So just to keep that working, maybe something like
Metrics = [case ML of
<<>> -> M#'Metric'{label = GlobalPrerendered};
<<_>> -> M#'Metric'{label = <<GlobalPrerendered/binary, ",", ML/binary>>;
_ -> M#'Metric'{label = Labels ++ ML}
end
prometheus_text_format:render_labels/1
is what can be used for pre-rendering, but it's currently not exported.
superseded by https://github.com/deadtrickster/prometheus.erl/pull/149
Without this change, a collector that pre-renders labels (like RabbitMQ) will return
<<>>
in case there are no labels at all. That will create an an improper list when an empty binary is appended to a list of global labels. Rather than dealing with improper list later, let's just avoid them.