Skip to content

Instantly share code, notes, and snippets.

@tedsuo
Last active August 29, 2015 14:06
Show Gist options
  • Save tedsuo/c7627828a97bdebe22ee to your computer and use it in GitHub Desktop.
Save tedsuo/c7627828a97bdebe22ee to your computer and use it in GitHub Desktop.
Dropsonde in Diego

Metrics

Questions

  • where is time recorded?
  • how do we unit test what values we have recorded?

Notes

  • instrumentedResponseWriter does not support the http.CloseNotifier interface
  • instrumentedResponseWriter should only provide interfaces that the underlying ResponseWriter supports

Interfaces

Currently we are liking this style of interface:

package metric

import (
	"time"

	"github.com/cloudfoundry/dropsonde/autowire/metrics"
)

type Counter string

func (c Counter) Increment() {
	metrics.IncrementCounter(string(c))
}

func (c Counter) Add(i uint64) {
	metrics.AddToCounter(string(c), i)
}

type Duration string

func (name Duration) Send(duration time.Duration) {
	metrics.SendValue(string(name), float64(duration), "nanos")
}

So that in our code we can declare our metrics like thus:

const (
	lrpStartIndexCounter   = metric.Counter("request-lrp-start-index")
	lrpStopIndexCounter    = metric.Counter("request-lrp-stop-index")
	lrpStopInstanceCounter = metric.Counter("request-lrp-stop-instance")
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment