mirror of
https://github.com/prometheus/prometheus.git
synced 2025-09-21 05:41:01 +02:00
web: Trim excessive line length in federate.go
Signed-off-by: beorn7 <beorn@grafana.com>
This commit is contained in:
parent
d5cc5e2738
commit
aac5cc3d99
@ -190,7 +190,9 @@ Loop:
|
|||||||
isHistogram := s.H != nil
|
isHistogram := s.H != nil
|
||||||
formatType := format.FormatType()
|
formatType := format.FormatType()
|
||||||
if isHistogram &&
|
if isHistogram &&
|
||||||
formatType != expfmt.TypeProtoDelim && formatType != expfmt.TypeProtoText && formatType != expfmt.TypeProtoCompact {
|
formatType != expfmt.TypeProtoDelim &&
|
||||||
|
formatType != expfmt.TypeProtoText &&
|
||||||
|
formatType != expfmt.TypeProtoCompact {
|
||||||
// Can't serve the native histogram.
|
// Can't serve the native histogram.
|
||||||
// TODO(codesome): Serve them when other protocols get the native histogram support.
|
// TODO(codesome): Serve them when other protocols get the native histogram support.
|
||||||
continue
|
continue
|
||||||
@ -208,20 +210,30 @@ Loop:
|
|||||||
}
|
}
|
||||||
if l.Name == labels.MetricName {
|
if l.Name == labels.MetricName {
|
||||||
nameSeen = true
|
nameSeen = true
|
||||||
if l.Value == lastMetricName && // We already have the name in the current MetricDescriptor, and we ignore nameless metrics.
|
// We already have the name in the current MetricDescriptor,
|
||||||
lastWasHistogram == isHistogram && // The sample type matches (float vs histogram).
|
// and we ignore nameless metrics.
|
||||||
// If it was a histogram, the histogram type (counter vs gauge) also matches.
|
if l.Value == lastMetricName &&
|
||||||
(!isHistogram || lastHistogramWasGauge == (s.H.CounterResetHint == histogram.GaugeType)) {
|
// The sample type matches (float vs histogram).
|
||||||
|
lastWasHistogram == isHistogram &&
|
||||||
|
// If it was a histogram, the histogram type
|
||||||
|
// (counter vs gauge) also matches.
|
||||||
|
(!isHistogram ||
|
||||||
|
lastHistogramWasGauge == (s.H.CounterResetHint == histogram.GaugeType)) {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Since we now check for the sample type and type of histogram above, we will end up
|
// Since we now check for the sample type and
|
||||||
// creating multiple metric families for the same metric name. This would technically be
|
// type of histogram above, we will end up
|
||||||
// an invalid exposition. But since the consumer of this is Prometheus, and Prometheus can
|
// creating multiple metric families for the
|
||||||
// parse it fine, we allow it and bend the rules to make federation possible in those cases.
|
// same metric name. This would technically be
|
||||||
|
// an invalid exposition. But since the consumer
|
||||||
|
// of this is Prometheus, and Prometheus can
|
||||||
|
// parse it fine, we allow it and bend the rules
|
||||||
|
// to make federation possible in those cases.
|
||||||
|
|
||||||
// Need to start a new MetricDescriptor. Ship off the old one (if any) before
|
// Need to start a new MetricDescriptor. Ship
|
||||||
// creating the new one.
|
// off the old one (if any) before creating the
|
||||||
|
// new one.
|
||||||
if protMetricFam != nil {
|
if protMetricFam != nil {
|
||||||
if err := enc.Encode(protMetricFam); err != nil {
|
if err := enc.Encode(protMetricFam); err != nil {
|
||||||
return err
|
return err
|
||||||
|
Loading…
x
Reference in New Issue
Block a user