// https://github.com/prometheus/common/blob/88f1636b699ae4fb949d292ffb904c205bf542c9/expfmt/text_create.go#L419-L420.
void generateOutput(Buffer::Instance& output, const std::vector<const Stats::Counter*>& counters,
* always equal to 0. Returned gauge contains all tags of a given text-readout and one additional
void generateNumericOutput(Buffer::Instance& output, const std::vector<const StatType*>& metrics,
const std::string formatted_tags = PrometheusStatsFormatter::formattedTags(metric->tags());
* Returns the prometheus output for a histogram. The output is a multi-line string (with embedded
* newlines) that contains all the individual quantile values and sum/count for a single histogram
void generateOutput(Buffer::Instance& output, const std::vector<const Stats::Counter*>& counters,
void generateNumericOutput(Buffer::Instance& output, const std::vector<const StatType*>& metrics,
const uint64_t zero_count = histogram->cumulativeCountLessThanOrEqualToValue(zero_threshold);
chooseNativeHistogramSchema(const std::vector<Stats::ParentHistogram::Bucket>& detailed_buckets,
// buckets per doubling. This resolution falls between schema 4 (16 buckets/doubling) and schema
absl::optional<std::set<int32_t>> indices = nativeHistogramBucketIndicesFromHistogramBuckets(
const double log_base = std::log(std::pow(2.0, std::pow(2.0, static_cast<double>(-schema))));
const int32_t upper_index = static_cast<int32_t>(std::ceil(std::log(upper_bound) / log_base));
void writeDelimitedMessage(const Protobuf::MessageLite& message, Buffer::Instance& output) const {
constexpr size_t kMaxVarintLength = 10; // This is documented, but not exported as a constant.
* https://github.com/prometheus/docs/blob/master/content/docs/instrumenting/exposition_formats.md#grouping-and-sorting:
// refcount; ownership is held throughout by `metrics`). It is unsorted for efficiency, but will
* https:*github.com/prometheus/docs/blob/master/content/docs/instrumenting/exposition_formats.md#grouping-and-sorting:
// refcount; ownership is held throughout by `metrics`). It is unsorted for efficiency, but will
if (auto prom_format = params.query_.getFirstValue("prom_protobuf"); prom_format.has_value()) {
buf.push_back(fmt::format("{}=\"{}\"", sanitizeName(tag.name_), sanitizeValue(tag.value_)));
// If it does not have a custom namespace, add namespacing prefix to avoid conflicts, as per best
// practice: https://prometheus.io/docs/practices/naming/#metric-names Also, naming conventions on
// "Detailed" and "Disjoint" don't make sense for prometheus histogram semantics. These types were
outputStatType<Stats::Counter>(response, params, counters, output_format, custom_namespaces);
// other stats. If this is not true, then the counters/gauges for per-endpoint need to be combined
[&](Stats::PrimitiveGaugeSnapshot&& metric) { host_gauges.emplace_back(std::move(metric)); });
return generateWithOutputFormat(counters, gauges, histograms, text_readouts, cluster_manager,
return generateWithOutputFormat(counters, gauges, histograms, text_readouts, cluster_manager,