Skip to content

Commit

Permalink
[queue] Don't include instance in queue size metrics (#29)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeromefroe authored and Rob Skillington committed Aug 22, 2017
1 parent dcd2f57 commit 2bf3c97
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/collector/backend/msgpack/queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import (
)

const (
defaultQueueSizeNumBuckets = 10
defaultQueueSizeNumBuckets = 6
)

var (
Expand Down Expand Up @@ -74,7 +74,7 @@ func newInstanceQueue(instance services.PlacementInstance, opts ServerOptions) i
)
q := &queue{
log: iOpts.Logger(),
metrics: newQueueMetrics(iOpts.MetricsScope(), instance.ID(), queueSize),
metrics: newQueueMetrics(iOpts.MetricsScope(), queueSize),
instance: instance,
conn: conn,
bufCh: make(chan msgpack.Buffer, queueSize),
Expand Down Expand Up @@ -146,30 +146,28 @@ func (q *queue) reportQueueSize(reportInterval time.Duration) {
for {
select {
case <-ticker.C:
q.metrics.queueSize.RecordValue(float64(len(q.bufCh)))
q.metrics.queueLen.RecordValue(float64(len(q.bufCh)))
case <-q.doneCh:
return
}
}
}

type queueMetrics struct {
queueSize tally.Histogram
queueLen tally.Histogram
queueClosedErrors tally.Counter
queueFullErrors tally.Counter
connWriteErrors tally.Counter
}

func newQueueMetrics(s tally.Scope, instanceID string, queueSize int) queueMetrics {
func newQueueMetrics(s tally.Scope, queueSize int) queueMetrics {
numBuckets := defaultQueueSizeNumBuckets
if queueSize < numBuckets {
numBuckets = queueSize
}
buckets := tally.MustMakeLinearValueBuckets(0, float64(queueSize/numBuckets), numBuckets)
return queueMetrics{
queueSize: s.Tagged(
map[string]string{"instance-id": instanceID},
).Histogram("queue-size", buckets),
queueLen: s.Histogram("queue-length", buckets),
queueClosedErrors: s.Tagged(
map[string]string{"error-type": "queue-closed", "action": "enqueue"},
).Counter("errors"),
Expand Down

0 comments on commit 2bf3c97

Please sign in to comment.