MCPcopy
hub / github.com/go-kit/kit / ExampleCounter

Function ExampleCounter

metrics/influx/example_test.go:12–37  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

10)
11
12func ExampleCounter() {
13 in := New(map[string]string{"a": "b"}, influxdb.BatchPointsConfig{}, log.NewNopLogger())
14 counter := in.NewCounter("influx_counter")
15 counter.Add(10)
16 counter.With("error", "true").Add(1)
17 counter.With("error", "false").Add(2)
18 counter.Add(50)
19
20 client := &bufWriter{}
21 in.WriteTo(client)
22
23 expectedLines := []string{
24 `(influx_counter,a=b count=60) [0-9]{19}`,
25 `(influx_counter,a=b,error=true count=1) [0-9]{19}`,
26 `(influx_counter,a=b,error=false count=2) [0-9]{19}`,
27 }
28
29 if err := extractAndPrintMessage(expectedLines, client.buf.String()); err != nil {
30 fmt.Println(err.Error())
31 }
32
33 // Output:
34 // influx_counter,a=b count=60
35 // influx_counter,a=b,error=true count=1
36 // influx_counter,a=b,error=false count=2
37}
38
39func ExampleGauge() {
40 in := New(map[string]string{"a": "b"}, influxdb.BatchPointsConfig{}, log.NewNopLogger())

Callers

nothing calls this directly

Calls 9

AddMethod · 0.95
WithMethod · 0.95
extractAndPrintMessageFunction · 0.85
NewFunction · 0.70
NewCounterMethod · 0.65
AddMethod · 0.65
WriteToMethod · 0.45
StringMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…