This example shows how to integrate with an existing registry as well as publishing metrics on the standard output
()
| 585 | // This example shows how to integrate with an existing registry as well as publishing metrics |
| 586 | // on the standard output |
| 587 | func ExampleConfig_metrics() { |
| 588 | // Our application registry |
| 589 | appMetricRegistry := metrics.NewRegistry() |
| 590 | appGauge := metrics.GetOrRegisterGauge("m1", appMetricRegistry) |
| 591 | appGauge.Update(1) |
| 592 | |
| 593 | config := NewTestConfig() |
| 594 | // Use a prefix registry instead of the default local one |
| 595 | config.MetricRegistry = metrics.NewPrefixedChildRegistry(appMetricRegistry, "sarama.") |
| 596 | |
| 597 | // Simulate a metric created by sarama without starting a broker |
| 598 | saramaGauge := metrics.GetOrRegisterGauge("m2", config.MetricRegistry) |
| 599 | saramaGauge.Update(2) |
| 600 | |
| 601 | metrics.WriteOnce(appMetricRegistry, os.Stdout) |
| 602 | // Output: |
| 603 | // gauge m1 |
| 604 | // value: 1 |
| 605 | // gauge sarama.m2 |
| 606 | // value: 2 |
| 607 | } |
nothing calls this directly
no test coverage detected