()
| 381 | } |
| 382 | |
| 383 | func ExampleNewConstSummary() { |
| 384 | desc := prometheus.NewDesc( |
| 385 | "http_request_duration_seconds", |
| 386 | "A summary of the HTTP request durations.", |
| 387 | []string{"code", "method"}, |
| 388 | prometheus.Labels{"owner": "example"}, |
| 389 | ) |
| 390 | |
| 391 | // Create a constant summary from values we got from a 3rd party telemetry system. |
| 392 | s := prometheus.MustNewConstSummary( |
| 393 | desc, |
| 394 | 4711, 403.34, |
| 395 | map[float64]float64{0.5: 42.3, 0.9: 323.3}, |
| 396 | "200", "get", |
| 397 | ) |
| 398 | |
| 399 | // Just for demonstration, let's check the state of the summary by |
| 400 | // (ab)using its Write method (which is usually only used by Prometheus |
| 401 | // internally). |
| 402 | metric := &dto.Metric{} |
| 403 | s.Write(metric) |
| 404 | fmt.Println(toNormalizedJSON(metric)) |
| 405 | |
| 406 | // Output: |
| 407 | // {"label":[{"name":"code","value":"200"},{"name":"method","value":"get"},{"name":"owner","value":"example"}],"summary":{"sampleCount":"4711","sampleSum":403.34,"quantile":[{"quantile":0.5,"value":42.3},{"quantile":0.9,"value":323.3}]}} |
| 408 | } |
| 409 | |
| 410 | func ExampleNewConstSummaryWithCreatedTimestamp() { |
| 411 | desc := prometheus.NewDesc( |
nothing calls this directly
no test coverage detected