Documentation ¶
Overview ¶
Package metric is the API for defining metrics and updating their values.
When you define a metric you must also define the names and types of any fields on that metric. It is an error to define two metrics with the same name (this will cause a panic).
When setting metric values, you must pass correct number of fields, with correct types, or the setter function will panic.
Example:
var ( requests = metric.NewCounter("myapp/requests", "Number of requests", nil, field.String("status")) ) ... func handleRequest() { if success { requests.Add(1, "success") } else { requests.Add(1, "failure") } }
Index ¶
- func InstrumentTransport(ctx context.Context, base http.RoundTripper, client string) http.RoundTripper
- func UpdateHTTPMetrics(ctx context.Context, name string, client string, code int, ...)
- func UpdateServerMetrics(ctx context.Context, name string, code int, duration time.Duration, ...)
- type Bool
- type Counter
- type CumulativeDistribution
- type Float
- type FloatCounter
- type Int
- type NonCumulativeDistribution
- type String
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InstrumentTransport ¶
func InstrumentTransport(ctx context.Context, base http.RoundTripper, client string) http.RoundTripper
InstrumentTransport returns a transport that sends HTTP client metrics via the given context.
If the context has no tsmon initialized (no metrics store installed), returns the original transport unchanged.
Types ¶
type Bool ¶
type Bool interface { types.Metric Get(c context.Context, fieldVals ...interface{}) bool Set(c context.Context, v bool, fieldVals ...interface{}) }
Bool is a boolean-valued metric.
type Counter ¶
Counter is a cumulative integer metric.
func NewCounter ¶
func NewCounter(name string, description string, metadata *types.MetricMetadata, fields ...field.Field) Counter
NewCounter returns a new cumulative integer metric.
type CumulativeDistribution ¶
type CumulativeDistribution interface { NonCumulativeDistribution Add(c context.Context, v float64, fieldVals ...interface{}) }
CumulativeDistribution is a cumulative-distribution-valued metric.
func NewCumulativeDistribution ¶
func NewCumulativeDistribution(name string, description string, metadata *types.MetricMetadata, bucketer *distribution.Bucketer, fields ...field.Field) CumulativeDistribution
NewCumulativeDistribution returns a new cumulative-distribution-valued metric.
type Float ¶
type Float interface { types.Metric Get(c context.Context, fieldVals ...interface{}) float64 Set(c context.Context, v float64, fieldVals ...interface{}) }
Float is a non-cumulative floating-point gauge metric.
type FloatCounter ¶
FloatCounter is a cumulative floating-point metric.
func NewFloatCounter ¶
func NewFloatCounter(name string, description string, metadata *types.MetricMetadata, fields ...field.Field) FloatCounter
NewFloatCounter returns a new cumulative floating-point metric.
type Int ¶
type Int interface { types.Metric Get(c context.Context, fieldVals ...interface{}) int64 Set(c context.Context, v int64, fieldVals ...interface{}) }
Int is a non-cumulative integer gauge metric.
type NonCumulativeDistribution ¶
type NonCumulativeDistribution interface { types.DistributionMetric Get(c context.Context, fieldVals ...interface{}) *distribution.Distribution Set(c context.Context, d *distribution.Distribution, fieldVals ...interface{}) }
NonCumulativeDistribution is a non-cumulative-distribution-valued metric.
func NewNonCumulativeDistribution ¶
func NewNonCumulativeDistribution(name string, description string, metadata *types.MetricMetadata, bucketer *distribution.Bucketer, fields ...field.Field) NonCumulativeDistribution
NewNonCumulativeDistribution returns a new non-cumulative-distribution-valued metric.