moduleGitlab::HealthChecksclassPrometheusTextdefmarshal(metrics)metrics_with_type_declarations(metrics).join("\n")endprivatedefmetrics_with_type_declarations(metrics)type_declaration_added={}metrics.flat_mapdo|metric|metric_lines=[]unlesstype_declaration_added.has_key?(metric.name)type_declaration_added[metric.name]=truemetric_lines<<metric_type_declaration(metric)endmetric_lines<<metric_text(metric)endenddefmetric_type_declaration(metric)"# TYPE #{metric.name} gauge"enddefmetric_text(metric)labels=metric.labels&.map{|key,value|"#{key}=\"#{value}\""}&.join(',')||''iflabels.empty?"#{metric.name}#{metric.value}"else"#{metric.name}{#{labels}} #{metric.value}"endendendend