const quantileLabel … type Summary … var errQuantileLabelNotAllowed … const DefMaxAge … const DefAgeBuckets … const DefBufCap … type SummaryOpts … type SummaryVecOpts … // NewSummary creates a new Summary based on the provided SummaryOpts. func NewSummary(opts SummaryOpts) Summary { … } func newSummary(desc *Desc, opts SummaryOpts, labelValues ...string) Summary { … } type summary … func (s *summary) Desc() *Desc { … } func (s *summary) Observe(v float64) { … } func (s *summary) Write(out *dto.Metric) error { … } func (s *summary) newStream() *quantile.Stream { … } // asyncFlush needs bufMtx locked. func (s *summary) asyncFlush(now time.Time) { … } // rotateStreams needs mtx AND bufMtx locked. func (s *summary) maybeRotateStreams() { … } // flushColdBuf needs mtx locked. func (s *summary) flushColdBuf() { … } // swapBufs needs mtx AND bufMtx locked, coldBuf must be empty. func (s *summary) swapBufs(now time.Time) { … } type summaryCounts … type noObjectivesSummary … func (s *noObjectivesSummary) Desc() *Desc { … } func (s *noObjectivesSummary) Observe(v float64) { … } func (s *noObjectivesSummary) Write(out *dto.Metric) error { … } type quantSort … func (s quantSort) Len() int { … } func (s quantSort) Swap(i, j int) { … } func (s quantSort) Less(i, j int) bool { … } type SummaryVec … // NewSummaryVec creates a new SummaryVec based on the provided SummaryOpts and // partitioned by the given label names. // // Due to the way a Summary is represented in the Prometheus text format and how // it is handled by the Prometheus server internally, “quantile” is an illegal // label name. NewSummaryVec will panic if this label name is used. func NewSummaryVec(opts SummaryOpts, labelNames []string) *SummaryVec { … } // NewSummaryVec creates a new SummaryVec based on the provided SummaryVecOpts. func (v2) NewSummaryVec(opts SummaryVecOpts) *SummaryVec { … } // GetMetricWithLabelValues returns the Summary for the given slice of label // values (same order as the variable labels in Desc). If that combination of // label values is accessed for the first time, a new Summary is created. // // It is possible to call this method without using the returned Summary to only // create the new Summary but leave it at its starting value, a Summary without // any observations. // // Keeping the Summary for later use is possible (and should be considered if // performance is critical), but keep in mind that Reset, DeleteLabelValues and // Delete can be used to delete the Summary from the SummaryVec. In that case, // the Summary will still exist, but it will not be exported anymore, even if a // Summary with the same label values is created later. See also the CounterVec // example. // // An error is returned if the number of label values is not the same as the // number of variable labels in Desc (minus any curried labels). // // Note that for more than one label value, this method is prone to mistakes // caused by an incorrect order of arguments. Consider GetMetricWith(Labels) as // an alternative to avoid that type of mistake. For higher label numbers, the // latter has a much more readable (albeit more verbose) syntax, but it comes // with a performance overhead (for creating and processing the Labels map). // See also the GaugeVec example. func (v *SummaryVec) GetMetricWithLabelValues(lvs ...string) (Observer, error) { … } // GetMetricWith returns the Summary for the given Labels map (the label names // must match those of the variable labels in Desc). If that label map is // accessed for the first time, a new Summary is created. Implications of // creating a Summary without using it and keeping the Summary for later use are // the same as for GetMetricWithLabelValues. // // An error is returned if the number and names of the Labels are inconsistent // with those of the variable labels in Desc (minus any curried labels). // // This method is used for the same purpose as // GetMetricWithLabelValues(...string). See there for pros and cons of the two // methods. func (v *SummaryVec) GetMetricWith(labels Labels) (Observer, error) { … } // WithLabelValues works as GetMetricWithLabelValues, but panics where // GetMetricWithLabelValues would have returned an error. Not returning an // error allows shortcuts like // // myVec.WithLabelValues("404", "GET").Observe(42.21) func (v *SummaryVec) WithLabelValues(lvs ...string) Observer { … } // With works as GetMetricWith, but panics where GetMetricWithLabels would have // returned an error. Not returning an error allows shortcuts like // // myVec.With(prometheus.Labels{"code": "404", "method": "GET"}).Observe(42.21) func (v *SummaryVec) With(labels Labels) Observer { … } // CurryWith returns a vector curried with the provided labels, i.e. the // returned vector has those labels pre-set for all labeled operations performed // on it. The cardinality of the curried vector is reduced accordingly. The // order of the remaining labels stays the same (just with the curried labels // taken out of the sequence – which is relevant for the // (GetMetric)WithLabelValues methods). It is possible to curry a curried // vector, but only with labels not yet used for currying before. // // The metrics contained in the SummaryVec are shared between the curried and // uncurried vectors. They are just accessed differently. Curried and uncurried // vectors behave identically in terms of collection. Only one must be // registered with a given registry (usually the uncurried version). The Reset // method deletes all metrics, even if called on a curried vector. func (v *SummaryVec) CurryWith(labels Labels) (ObserverVec, error) { … } // MustCurryWith works as CurryWith but panics where CurryWith would have // returned an error. func (v *SummaryVec) MustCurryWith(labels Labels) ObserverVec { … } type constSummary … func (s *constSummary) Desc() *Desc { … } func (s *constSummary) Write(out *dto.Metric) error { … } // NewConstSummary returns a metric representing a Prometheus summary with fixed // values for the count, sum, and quantiles. As those parameters cannot be // changed, the returned value does not implement the Summary interface (but // only the Metric interface). Users of this package will not have much use for // it in regular operations. However, when implementing custom Collectors, it is // useful as a throw-away metric that is generated on the fly to send it to // Prometheus in the Collect method. // // quantiles maps ranks to quantile values. For example, a median latency of // 0.23s and a 99th percentile latency of 0.56s would be expressed as: // // map[float64]float64{0.5: 0.23, 0.99: 0.56} // // NewConstSummary returns an error if the length of labelValues is not // consistent with the variable labels in Desc or if Desc is invalid. func NewConstSummary( desc *Desc, count uint64, sum float64, quantiles map[float64]float64, labelValues ...string, ) (Metric, error) { … } // MustNewConstSummary is a version of NewConstSummary that panics where // NewConstMetric would have returned an error. func MustNewConstSummary( desc *Desc, count uint64, sum float64, quantiles map[float64]float64, labelValues ...string, ) Metric { … }