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

Function main

scripts/metricsdocgen/main.go:31–62  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

29)
30
31func main() {
32 flag.StringVar(&staticMetricsFile, "static-metrics", "scripts/metricsdocgen/metrics", "Path to static metrics file (manually maintained)")
33 flag.StringVar(&generatedMetricsFile, "generated-metrics", "scripts/metricsdocgen/generated_metrics", "Path to generated metrics file (from scanner)")
34 flag.StringVar(&prometheusDocFile, "prometheus-doc-file", "docs/admin/integrations/prometheus.md", "Path to Prometheus doc file")
35 flag.BoolVar(&dryRun, "dry-run", false, "Dry run")
36 flag.Parse()
37
38 metrics, err := readAndMergeMetrics()
39 if err != nil {
40 log.Fatal("can't read metrics: ", err)
41 }
42
43 doc, err := readPrometheusDoc()
44 if err != nil {
45 log.Fatal("can't read Prometheus doc: ", err)
46 }
47
48 doc, err = updatePrometheusDoc(doc, metrics)
49 if err != nil {
50 log.Fatal("can't update Prometheus doc: ", err)
51 }
52
53 if dryRun {
54 log.Println(string(doc))
55 return
56 }
57
58 err = writePrometheusDoc(doc)
59 if err != nil {
60 log.Fatal("can't write updated Prometheus doc: ", err)
61 }
62}
63
64// readMetricsFromFile reads metrics from a single Prometheus text format file.
65func readMetricsFromFile(path string) ([]*dto.MetricFamily, error) {

Callers

nothing calls this directly

Calls 6

readAndMergeMetricsFunction · 0.85
readPrometheusDocFunction · 0.85
updatePrometheusDocFunction · 0.85
writePrometheusDocFunction · 0.85
FatalMethod · 0.80
ParseMethod · 0.65

Tested by

no test coverage detected