本文整理汇总了Golang中github.com/prometheus/client_model/go.MetricFamily.Name方法的典型用法代码示例。如果您正苦于以下问题:Golang MetricFamily.Name方法的具体用法?Golang MetricFamily.Name怎么用?Golang MetricFamily.Name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/prometheus/client_model/go.MetricFamily
的用法示例。
在下文中一共展示了MetricFamily.Name方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: PrintAsText
// PrintAsText outputs all metrics in text format.
func (r *Registry) PrintAsText(w io.Writer) error {
var metricFamily prometheusgo.MetricFamily
var ret error
labels := r.getLabels()
for _, metric := range r.tracked {
metric.Inspect(func(v interface{}) {
if ret != nil {
return
}
if prom, ok := v.(PrometheusExportable); ok {
metricFamily.Reset()
metricFamily.Name = proto.String(exportedName(metric.GetName()))
metricFamily.Help = proto.String(metric.GetHelp())
prom.FillPrometheusMetric(&metricFamily)
if len(labels) != 0 {
// Set labels from registry. We only set one metric in the slice, but loop anyway.
for _, m := range metricFamily.Metric {
m.Label = labels
}
}
if l := prom.GetLabels(); len(l) != 0 {
// Append per-metric labels.
for _, m := range metricFamily.Metric {
m.Label = append(m.Label, l...)
}
}
if _, err := expfmt.MetricFamilyToText(w, &metricFamily); err != nil {
ret = err
}
}
})
}
return ret
}
示例2: PrintAsText
// PrintAsText outputs all metrics in text format.
func (r *Registry) PrintAsText(w io.Writer) error {
var metricFamily prometheusgo.MetricFamily
var ret error
r.Each(func(name string, v interface{}) {
if ret != nil {
return
}
if metric, ok := v.(PrometheusExportable); ok {
metricFamily.Reset()
metricFamily.Name = proto.String(exportedName(name))
metric.FillPrometheusMetric(&metricFamily)
if _, err := expfmt.MetricFamilyToText(w, &metricFamily); err != nil {
ret = err
}
}
})
return ret
}