Documentation ¶
Index ¶
- Constants
- Variables
- func RegisterHandler(metricName, filterTag, filterTagVal string, handler HandlerFn)
- type Client
- type HandlerFn
- type MetricName
- type MetricType
- type NullReporter
- func (r *NullReporter) GetChildReporter(tags map[string]string) Reporter
- func (r *NullReporter) GetTags() map[string]string
- func (r *NullReporter) IncCounter(name string, tags map[string]string, delta int64)
- func (r *NullReporter) InitMetrics(metricMap map[MetricName]MetricType)
- func (r *NullReporter) RecordTimer(name string, tags map[string]string, d time.Duration)
- func (r *NullReporter) StartTimer(name string, tags map[string]string) Stopwatch
- func (r *NullReporter) UpdateGauge(name string, tags map[string]string, value int64)
- type Reporter
- type Stopwatch
- type TestReporter
- func (r *TestReporter) GetChildReporter(tags map[string]string) Reporter
- func (r *TestReporter) GetTags() map[string]string
- func (r *TestReporter) IncCounter(name string, tags map[string]string, delta int64)
- func (r *TestReporter) InitMetrics(metricMap map[MetricName]MetricType)
- func (r *TestReporter) RecordTimer(name string, tags map[string]string, d time.Duration)
- func (r *TestReporter) StartTimer(name string, tags map[string]string) Stopwatch
- func (r *TestReporter) UpdateGauge(name string, tags map[string]string, value int64)
Constants ¶
const ( // ServiceNameTagName is the tag name to identify partner service which uses Chermai client ServiceNameTagName = "serviceName" // DeploymentTagName is the tag name to identify current deployment name DeploymentTagName = "deployment" // DestinationTag is the tag name to identify destination DestinationTag = "destination" // PublisherTypeTag is the tag name to identify publisher type PublisherTypeTag = "publisherType" // ConsumerGroupTag is the tag name to identify consumer group ConsumerGroupTag = "consumerGroup" // PidTag is the tag name to identify process id PidTag = "pid" // ClientTag is the tag name to identify client ClientTag = "client" // HostNameTag is the tag name to identify host name HostNameTag = "hostName" // PublishMessageRate is the rate of message wrote to input PublishMessageRate = "cherami.publish.message.rate" // PublishMessageFailedRate is the rate of message try writting to input but failed PublishMessageFailedRate = "cherami.publish.message.failed" // PublishMessageLatency is the latency of message wrote to input PublishMessageLatency = "cherami.publish.message.latency" // PublishAckRate is the rate of ack got from input PublishAckRate = "cherami.publish.ack.rate" // PublishReconfigureRate is the rate of reconfiguration happening PublishReconfigureRate = "cherami.publish.reconfigure.rate" // PublishDrainRate is the rate of drain happening PublishDrainRate = "cherami.publish.drain.rate" // PublishNumConnections is the number of connections with input PublishNumConnections = "cherami.publish.connections" // PublishNumInflightMessagess is the number of inflight messages hold locally by publisher PublishNumInflightMessagess = "cherami.publish.message.inflights" // PublisherMessageFailed is the number of failed messages on the publisher PublisherMessageFailed = "cherami.publisher.message.failed" // PublisherMessageTimedout is the number of messages timed out on the publisher PublisherMessageTimedout = "cherami.publisher.message.timedout" // ConsumeReadFailed is the metric of consume read failures ConsumeReadFailed = "cherami.consume.read.failed" // ConsumeMessageRate is the rate of message got from output ConsumeMessageRate = "cherami.consume.message.rate" // ConsumeCreditRate is the rate of credit sent to output ConsumeCreditRate = "cherami.consume.credit.rate" // ConsumeCreditFailedRate is the rate of credit try sending to output but failed ConsumeCreditFailedRate = "cherami.consume.credit.failed" // ConsumeCreditLatency is the latency of credit sent to output ConsumeCreditLatency = "cherami.consume.credit.latency" // ConsumeAckRate is the rate of ack sent to output ConsumeAckRate = "cherami.consume.ack.rate" // ConsumeAckFailedRate is the rate of ack try sending to output but failed ConsumeAckFailedRate = "cherami.consume.ack.failed" // ConsumeNackRate is the rate of nack sent to output ConsumeNackRate = "cherami.consume.nack.rate" // ConsumeReconfigureRate is the rate of reconfiguration happening ConsumeReconfigureRate = "cherami.consume.reconfigure.rate" // ConsumeNumConnections is the number of connections with output ConsumeNumConnections = "cherami.consume.connections" // ConsumeLocalCredits is the number of credit hold locally by consumer ConsumeLocalCredits = "cherami.consume.credit.local" // ProcessLatency is the time between the message being read by the consumer, and either acked or nacked ProcessLatency = "cherami.consume.process.latency" // ProcessAckLatency is the time between the message being read by the consumer and being acked ProcessAckLatency = "cherami.consume.ack.latency" // ProcessNackLatency is the time between the message being read by the consumer and being nacked ProcessNackLatency = "cherami.consume.nack.latency" )
Variables ¶
var MetricDefs = map[MetricName]MetricType{ PublishMessageRate: Counter, PublishMessageFailedRate: Counter, PublishMessageLatency: Timer, PublishAckRate: Counter, PublishReconfigureRate: Counter, PublishDrainRate: Counter, PublishNumConnections: Gauge, PublishNumInflightMessagess: Gauge, PublisherMessageFailed: Counter, PublisherMessageTimedout: Counter, ConsumeReadFailed: Counter, ConsumeMessageRate: Counter, ConsumeCreditRate: Counter, ConsumeCreditFailedRate: Counter, ConsumeCreditLatency: Timer, ConsumeAckRate: Counter, ConsumeAckFailedRate: Counter, ConsumeNackRate: Counter, ConsumeReconfigureRate: Counter, ConsumeNumConnections: Gauge, ConsumeLocalCredits: Gauge, ProcessLatency: Timer, ProcessAckLatency: Timer, ProcessNackLatency: Timer, }
MetricDefs contains definition of metrics to its type mapping
Functions ¶
func RegisterHandler ¶ added in v1.20.0
Register a handler (closure) that receives updates for a particular guage or counter based on the metric name and the name/value of one of the metric's tags. If the filterTag/Val are both empty, all updates to that metric will trigger the handler. If metricName is empty, all metrics matching the tag filter will pass through your function. A nil handler unregisters the handler for the given filter parameters
Dev notes: * It is advisible to defer a call to unregister your handler when your test ends * Your handler can be called concurrently. Capture your own sync.Mutex if you must serialize * Counters report the delta; you must maintain the cumulative value of your counter if it is important * Your handler executes synchronously with the metrics code; DO NOT BLOCK
Types ¶
type Client ¶
type Client interface { // IncCounter increments a counter and emits // to m3 backend IncCounter(scope int, counter int) // AddCounter adds delta to the counter and // emits to the m3 backend AddCounter(scope int, counter int, delta int64) // StartTimer starts a timer for the given // metric name StartTimer(scope int, timer int) Stopwatch // RecordTimer starts a timer for the given // metric name RecordTimer(scope int, timer int, d time.Duration) // UpdateGauge reports Gauge type metric to M3 UpdateGauge(scope int, gauge int, delta int64) // GetParentReporter return the parentReporter GetParentReporter() Reporter }
Client is the the interface used to report metrics to m3 backend.
type HandlerFn ¶ added in v1.20.0
func KeepLastValueHandler ¶ added in v1.20.0
KeepLastValueHandler returns a HandlerFn that atomically stores the last value and count of successive calls into the provided atomic variables
func SummingHandler ¶ added in v1.20.0
SummingHandler returns a HandlerFn that atomically stores the sum and count of successive calls into the provided atomic variables NOTE: there are two race-free way to reset the counts together: 1) unregister the handler, then zero the counts, and re-register; may lose events 2) register a new handler with a second set of counting variables
type MetricType ¶
type MetricType int
MetricType is the type of the metric, which can be one of the 3 below
const ( Counter MetricType = iota Timer Gauge )
MetricTypes which are supported
type NullReporter ¶
type NullReporter struct {
// contains filtered or unexported fields
}
NullReporter is a dummy reporter which implements the Reporter interface
func (*NullReporter) GetChildReporter ¶
func (r *NullReporter) GetChildReporter(tags map[string]string) Reporter
GetChildReporter creates the child reporter for this parent reporter
func (*NullReporter) GetTags ¶
func (r *NullReporter) GetTags() map[string]string
GetTags returns the tags for this reporter object
func (*NullReporter) IncCounter ¶
func (r *NullReporter) IncCounter(name string, tags map[string]string, delta int64)
IncCounter reports Counter metric to M3
func (*NullReporter) InitMetrics ¶
func (r *NullReporter) InitMetrics(metricMap map[MetricName]MetricType)
InitMetrics is used to initialize the metrics map with the respective type
func (*NullReporter) RecordTimer ¶
RecordTimer should be used for measuring latency when you cannot start the stop watch.
func (*NullReporter) StartTimer ¶
func (r *NullReporter) StartTimer(name string, tags map[string]string) Stopwatch
StartTimer returns a Stopwatch which when stopped will report the metric
func (*NullReporter) UpdateGauge ¶
func (r *NullReporter) UpdateGauge(name string, tags map[string]string, value int64)
UpdateGauge reports Gauge type metric
type Reporter ¶
type Reporter interface { // InitMetrics is used to initialize the metrics map // with the respective type InitMetrics(metricMap map[MetricName]MetricType) // GetChildReporter is used to get a child reporter from the parent // this also makes sure we have all the tags from the parent in // addition to the tags supplied here GetChildReporter(tags map[string]string) Reporter // GetTags gets the tags for this reporter object GetTags() map[string]string // IncCounter should be used for Counter style metrics IncCounter(name string, tags map[string]string, delta int64) // UpdateGauge should be used for Gauge style metrics UpdateGauge(name string, tags map[string]string, value int64) // StartTimer should be used for measuring latency. // this returns a Stopwatch which can be used to stop the timer StartTimer(name string, tags map[string]string) Stopwatch // RecordTimer should be used for measuring latency when you cannot start the stop watch. RecordTimer(name string, tags map[string]string, d time.Duration) }
Reporter is the the interface used to report stats.
func NewNullReporter ¶
func NewNullReporter() Reporter
NewNullReporter create an instance of Reporter which can be used emit metric to console
func NewTestReporter ¶ added in v1.20.0
NewTestReporter create an instance of Reporter which can be used for driver to emit metric to console
type TestReporter ¶ added in v1.20.0
type TestReporter struct {
// contains filtered or unexported fields
}
TestReporter is the reporter used to analyze metrics for unit tests
func (*TestReporter) GetChildReporter ¶ added in v1.20.0
func (r *TestReporter) GetChildReporter(tags map[string]string) Reporter
GetChildReporter creates the child reporter for this parent reporter
func (*TestReporter) GetTags ¶ added in v1.20.0
func (r *TestReporter) GetTags() map[string]string
GetTags returns the tags for this reporter object
func (*TestReporter) IncCounter ¶ added in v1.20.0
func (r *TestReporter) IncCounter(name string, tags map[string]string, delta int64)
IncCounter reports Counter metric to M3
func (*TestReporter) InitMetrics ¶ added in v1.20.0
func (r *TestReporter) InitMetrics(metricMap map[MetricName]MetricType)
InitMetrics is used to initialize the metrics map with the respective type
func (*TestReporter) RecordTimer ¶ added in v1.20.0
RecordTimer should be used for measuring latency when you cannot start the stop watch.
func (*TestReporter) StartTimer ¶ added in v1.20.0
func (r *TestReporter) StartTimer(name string, tags map[string]string) Stopwatch
StartTimer returns a Stopwatch which when stopped will report the metric to M3
func (*TestReporter) UpdateGauge ¶ added in v1.20.0
func (r *TestReporter) UpdateGauge(name string, tags map[string]string, value int64)
UpdateGauge reports Gauge type metric