()
| 321 | } |
| 322 | |
| 323 | func ExampleSummary() { |
| 324 | temps := prometheus.NewSummary(prometheus.SummaryOpts{ |
| 325 | Name: "pond_temperature_celsius", |
| 326 | Help: "The temperature of the frog pond.", |
| 327 | Objectives: map[float64]float64{0.5: 0.05, 0.9: 0.01, 0.99: 0.001}, |
| 328 | }) |
| 329 | |
| 330 | // Simulate some observations. |
| 331 | for i := 0; i < 1000; i++ { |
| 332 | temps.Observe(30 + math.Floor(120*math.Sin(float64(i)*0.1))/10) |
| 333 | } |
| 334 | |
| 335 | // Just for demonstration, let's check the state of the summary by |
| 336 | // (ab)using its Write method (which is usually only used by Prometheus |
| 337 | // internally). |
| 338 | metric := &dto.Metric{} |
| 339 | temps.Write(metric) |
| 340 | |
| 341 | fmt.Println(toNormalizedJSON(sanitizeMetric(metric))) |
| 342 | |
| 343 | // Output: |
| 344 | // {"summary":{"sampleCount":"1000","sampleSum":29969.50000000001,"quantile":[{"quantile":0.5,"value":31.1},{"quantile":0.9,"value":41.3},{"quantile":0.99,"value":41.9}],"createdTimestamp":"1970-01-01T00:00:10Z"}} |
| 345 | } |
| 346 | |
| 347 | func ExampleSummaryVec() { |
| 348 | temps := prometheus.NewSummaryVec( |
nothing calls this directly
no test coverage detected