MCPcopy
hub / github.com/prometheus/client_golang / TestWriteToTextfile

Function TestWriteToTextfile

prometheus/registry_test.go:993–1098  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

991}
992
993func TestWriteToTextfile(t *testing.T) {
994 expectedOut := `# HELP test_counter test counter
995# TYPE test_counter counter
996test_counter{name="qux"} 1
997# HELP test_gauge test gauge
998# TYPE test_gauge gauge
999test_gauge{name="baz"} 1.1
1000# HELP test_hist test histogram
1001# TYPE test_hist histogram
1002test_hist_bucket{name="bar",le="0.005"} 0
1003test_hist_bucket{name="bar",le="0.01"} 0
1004test_hist_bucket{name="bar",le="0.025"} 0
1005test_hist_bucket{name="bar",le="0.05"} 0
1006test_hist_bucket{name="bar",le="0.1"} 0
1007test_hist_bucket{name="bar",le="0.25"} 0
1008test_hist_bucket{name="bar",le="0.5"} 0
1009test_hist_bucket{name="bar",le="1"} 1
1010test_hist_bucket{name="bar",le="2.5"} 1
1011test_hist_bucket{name="bar",le="5"} 2
1012test_hist_bucket{name="bar",le="10"} 2
1013test_hist_bucket{name="bar",le="+Inf"} 2
1014test_hist_sum{name="bar"} 3.64
1015test_hist_count{name="bar"} 2
1016# HELP test_summary test summary
1017# TYPE test_summary summary
1018test_summary{name="foo",quantile="0.5"} 10
1019test_summary{name="foo",quantile="0.9"} 20
1020test_summary{name="foo",quantile="0.99"} 20
1021test_summary_sum{name="foo"} 30
1022test_summary_count{name="foo"} 2
1023`
1024
1025 registry := prometheus.NewRegistry()
1026
1027 summary := prometheus.NewSummaryVec(
1028 prometheus.SummaryOpts{
1029 Name: "test_summary",
1030 Help: "test summary",
1031 Objectives: map[float64]float64{
1032 0.5: 0.05,
1033 0.9: 0.01,
1034 0.99: 0.001,
1035 },
1036 },
1037 []string{"name"},
1038 )
1039
1040 histogram := prometheus.NewHistogramVec(
1041 prometheus.HistogramOpts{
1042 Name: "test_hist",
1043 Help: "test histogram",
1044 },
1045 []string{"name"},
1046 )
1047
1048 gauge := prometheus.NewGaugeVec(
1049 prometheus.GaugeOpts{
1050 Name: "test_gauge",

Callers

nothing calls this directly

Calls 14

MustRegisterMethod · 0.95
WithMethod · 0.95
WithMethod · 0.95
WithMethod · 0.95
WithMethod · 0.95
NewRegistryFunction · 0.92
NewSummaryVecFunction · 0.92
NewHistogramVecFunction · 0.92
NewGaugeVecFunction · 0.92
NewCounterVecFunction · 0.92
WriteToTextfileFunction · 0.92
ObserveMethod · 0.65

Tested by

no test coverage detected