MCPcopy Index your code
hub / github.com/coder/coder / String

Method String

scripts/metricsdocgen/scanner/scanner.go:707–728  ·  view source on GitHub ↗

String returns the metric in Prometheus text exposition format. Label values are empty strings and metric values are 0 since only metadata (name, type, help, label names) is used for documentation generation.

()

Source from the content-addressed store, hash-verified

705// Label values are empty strings and metric values are 0 since only
706// metadata (name, type, help, label names) is used for documentation generation.
707func (m Metric) String() string {
708 var buf strings.Builder
709
710 // Write HELP line.
711 _, _ = fmt.Fprintf(&buf, "# HELP %s %s\n", m.Name, m.Help)
712
713 // Write TYPE line.
714 _, _ = fmt.Fprintf(&buf, "# TYPE %s %s\n", m.Name, m.Type)
715
716 // Write a sample metric line with empty label values and zero metric value.
717 if len(m.Labels) > 0 {
718 labelPairs := make([]string, len(m.Labels))
719 for i, l := range m.Labels {
720 labelPairs[i] = fmt.Sprintf("%s=\"\"", l)
721 }
722 _, _ = fmt.Fprintf(&buf, "%s{%s} 0\n", m.Name, strings.Join(labelPairs, ","))
723 } else {
724 _, _ = fmt.Fprintf(&buf, "%s 0\n", m.Name)
725 }
726
727 return buf.String()
728}
729
730// writeMetrics writes all metrics in Prometheus text exposition format.
731func writeMetrics(metrics []Metric, w io.Writer) {

Callers 4

verifyCollectedMetricsFunction · 0.95
jsonSegmentToGoNameFunction · 0.45
updatePrometheusDocFunction · 0.45
writeMetricsFunction · 0.45

Calls

no outgoing calls

Tested by 1

verifyCollectedMetricsFunction · 0.76