metrics: further clarification to docs
Peter Bourgon
7 years ago
20 | 20 | // many code paths somewhat dynamically. The concept of With is fully supported |
21 | 21 | // in some backends like Prometheus, and not supported in other backends like |
22 | 22 | // Graphite. So, With may be a no-op, depending on the concrete implementation |
23 | // you choose. | |
23 | // you choose. Please check the implementation to know for sure. For | |
24 | // implementations that don't provide With, it's necessary to fully parameterize | |
25 | // each metric in the metric name, e.g. | |
26 | // | |
27 | // // Statsd | |
28 | // c := statsd.NewCounter("request_duration_MyMethod_200") | |
29 | // c.Add(1) | |
30 | // | |
31 | // // Prometheus | |
32 | // c := prometheus.NewCounter(stdprometheus.CounterOpts{ | |
33 | // Name: "request_duration", | |
34 | // ... | |
35 | // }, []string{"method", "status_code"}) | |
36 | // c.With("method", "MyMethod", "status_code", strconv.Itoa(code)).Add(1) | |
24 | 37 | // |
25 | 38 | // Usage |
26 | 39 | // |