MCPcopy
hub / github.com/IBM/sarama / ExampleConfig_metrics

Function ExampleConfig_metrics

config_test.go:587–607  ·  view source on GitHub ↗

This example shows how to integrate with an existing registry as well as publishing metrics on the standard output

()

Source from the content-addressed store, hash-verified

585// This example shows how to integrate with an existing registry as well as publishing metrics
586// on the standard output
587func 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}

Callers

nothing calls this directly

Calls 1

NewTestConfigFunction · 0.70

Tested by

no test coverage detected