| Index: common/tsmon/metric/metric.go
|
| diff --git a/common/tsmon/metric/metric.go b/common/tsmon/metric/metric.go
|
| index 31cb9774e2d285092f4f3a9054a3da922cb079b9..ad19c80f7b51fda2dc7a3a25c46ba400f4ed09d7 100644
|
| --- a/common/tsmon/metric/metric.go
|
| +++ b/common/tsmon/metric/metric.go
|
| @@ -137,30 +137,33 @@ type CallbackDistribution interface {
|
|
|
| // NewInt returns a new non-cumulative integer gauge metric. This will panic if
|
| // another metric already exists with this name.
|
| -func NewInt(name string, description string, fields ...field.Field) Int {
|
| - return NewIntIn(context.Background(), name, description, fields...)
|
| +func NewInt(name string, description string, metadata types.MetricMetadata, fields ...field.Field) Int {
|
| + return NewIntIn(context.Background(), name, description, metadata, fields...)
|
| }
|
|
|
| // NewIntIn is like NewInt but registers in a given context.
|
| -func NewIntIn(c context.Context, name string, description string, fields ...field.Field) Int {
|
| - m := &intMetric{metric{MetricInfo: types.MetricInfo{
|
| - Name: name,
|
| - Description: description,
|
| - Fields: fields,
|
| - ValueType: types.NonCumulativeIntType,
|
| - }}}
|
| +func NewIntIn(c context.Context, name string, description string, metadata types.MetricMetadata, fields ...field.Field) Int {
|
| + m := &intMetric{metric{
|
| + MetricInfo: types.MetricInfo{
|
| + Name: name,
|
| + Description: description,
|
| + Fields: fields,
|
| + ValueType: types.NonCumulativeIntType,
|
| + },
|
| + MetricMetadata: metadata,
|
| + }}
|
| tsmon.Register(c, m)
|
| return m
|
| }
|
|
|
| // NewCounter returns a new cumulative integer metric. This will panic if
|
| // another metric already exists with this name.
|
| -func NewCounter(name string, description string, fields ...field.Field) Counter {
|
| - return NewCounterIn(context.Background(), name, description, fields...)
|
| +func NewCounter(name string, description string, metadata types.MetricMetadata, fields ...field.Field) Counter {
|
| + return NewCounterIn(context.Background(), name, description, metadata, fields...)
|
| }
|
|
|
| // NewCounterIn is like NewCounter but registers in a given context.
|
| -func NewCounterIn(c context.Context, name string, description string, fields ...field.Field) Counter {
|
| +func NewCounterIn(c context.Context, name string, description string, metadata types.MetricMetadata, fields ...field.Field) Counter {
|
| m := &counter{intMetric{metric{MetricInfo: types.MetricInfo{
|
| Name: name,
|
| Description: description,
|
| @@ -173,12 +176,12 @@ func NewCounterIn(c context.Context, name string, description string, fields ...
|
|
|
| // NewFloat returns a new non-cumulative floating-point gauge metric. This will
|
| // panic if another metric already exists with this name.
|
| -func NewFloat(name string, description string, fields ...field.Field) Float {
|
| - return NewFloatIn(context.Background(), name, description, fields...)
|
| +func NewFloat(name string, description string, metadata types.MetricMetadata, fields ...field.Field) Float {
|
| + return NewFloatIn(context.Background(), name, description, metadata, fields...)
|
| }
|
|
|
| // NewFloatIn is like NewFloat but registers in a given context.
|
| -func NewFloatIn(c context.Context, name string, description string, fields ...field.Field) Float {
|
| +func NewFloatIn(c context.Context, name string, description string, metadata types.MetricMetadata, fields ...field.Field) Float {
|
| m := &floatMetric{metric{MetricInfo: types.MetricInfo{
|
| Name: name,
|
| Description: description,
|
| @@ -191,12 +194,12 @@ func NewFloatIn(c context.Context, name string, description string, fields ...fi
|
|
|
| // NewFloatCounter returns a new cumulative floating-point metric. This will
|
| // panic if another metric already exists with this name.
|
| -func NewFloatCounter(name string, description string, fields ...field.Field) FloatCounter {
|
| - return NewFloatCounterIn(context.Background(), name, description, fields...)
|
| +func NewFloatCounter(name string, description string, metadata types.MetricMetadata, fields ...field.Field) FloatCounter {
|
| + return NewFloatCounterIn(context.Background(), name, description, metadata, fields...)
|
| }
|
|
|
| // NewFloatCounterIn is like NewFloatCounter but registers in a given context.
|
| -func NewFloatCounterIn(c context.Context, name string, description string, fields ...field.Field) FloatCounter {
|
| +func NewFloatCounterIn(c context.Context, name string, description string, metadata types.MetricMetadata, fields ...field.Field) FloatCounter {
|
| m := &floatCounter{floatMetric{metric{MetricInfo: types.MetricInfo{
|
| Name: name,
|
| Description: description,
|
| @@ -209,12 +212,12 @@ func NewFloatCounterIn(c context.Context, name string, description string, field
|
|
|
| // NewString returns a new string-valued metric. This will panic if another
|
| // metric already exists with this name.
|
| -func NewString(name string, description string, fields ...field.Field) String {
|
| - return NewStringIn(context.Background(), name, description, fields...)
|
| +func NewString(name string, description string, metadata types.MetricMetadata, fields ...field.Field) String {
|
| + return NewStringIn(context.Background(), name, description, metadata, fields...)
|
| }
|
|
|
| // NewStringIn is like NewString but registers in a given context.
|
| -func NewStringIn(c context.Context, name string, description string, fields ...field.Field) String {
|
| +func NewStringIn(c context.Context, name string, description string, metadata types.MetricMetadata, fields ...field.Field) String {
|
| m := &stringMetric{metric{MetricInfo: types.MetricInfo{
|
| Name: name,
|
| Description: description,
|
| @@ -227,12 +230,12 @@ func NewStringIn(c context.Context, name string, description string, fields ...f
|
|
|
| // NewBool returns a new bool-valued metric. This will panic if another
|
| // metric already exists with this name.
|
| -func NewBool(name string, description string, fields ...field.Field) Bool {
|
| - return NewBoolIn(context.Background(), name, description, fields...)
|
| +func NewBool(name string, description string, metadata types.MetricMetadata, fields ...field.Field) Bool {
|
| + return NewBoolIn(context.Background(), name, description, metadata, fields...)
|
| }
|
|
|
| // NewBoolIn is like NewBool but registers in a given context.
|
| -func NewBoolIn(c context.Context, name string, description string, fields ...field.Field) Bool {
|
| +func NewBoolIn(c context.Context, name string, description string, metadata types.MetricMetadata, fields ...field.Field) Bool {
|
| m := &boolMetric{metric{MetricInfo: types.MetricInfo{
|
| Name: name,
|
| Description: description,
|
| @@ -245,12 +248,12 @@ func NewBoolIn(c context.Context, name string, description string, fields ...fie
|
|
|
| // NewCumulativeDistribution returns a new cumulative-distribution-valued
|
| // metric. This will panic if another metric already exists with this name.
|
| -func NewCumulativeDistribution(name string, description string, bucketer *distribution.Bucketer, fields ...field.Field) CumulativeDistribution {
|
| - return NewCumulativeDistributionIn(context.Background(), name, description, bucketer, fields...)
|
| +func NewCumulativeDistribution(name string, description string, metadata types.MetricMetadata, bucketer *distribution.Bucketer, fields ...field.Field) CumulativeDistribution {
|
| + return NewCumulativeDistributionIn(context.Background(), name, description, metadata, bucketer, fields...)
|
| }
|
|
|
| // NewCumulativeDistributionIn is like NewCumulativeDistribution but registers in a given context.
|
| -func NewCumulativeDistributionIn(c context.Context, name string, description string, bucketer *distribution.Bucketer, fields ...field.Field) CumulativeDistribution {
|
| +func NewCumulativeDistributionIn(c context.Context, name string, description string, metadata types.MetricMetadata, bucketer *distribution.Bucketer, fields ...field.Field) CumulativeDistribution {
|
| m := &cumulativeDistributionMetric{
|
| nonCumulativeDistributionMetric{
|
| metric: metric{MetricInfo: types.MetricInfo{
|
| @@ -268,12 +271,12 @@ func NewCumulativeDistributionIn(c context.Context, name string, description str
|
|
|
| // NewNonCumulativeDistribution returns a new non-cumulative-distribution-valued
|
| // metric. This will panic if another metric already exists with this name.
|
| -func NewNonCumulativeDistribution(name string, description string, bucketer *distribution.Bucketer, fields ...field.Field) NonCumulativeDistribution {
|
| - return NewNonCumulativeDistributionIn(context.Background(), name, description, bucketer, fields...)
|
| +func NewNonCumulativeDistribution(name string, description string, metadata types.MetricMetadata, bucketer *distribution.Bucketer, fields ...field.Field) NonCumulativeDistribution {
|
| + return NewNonCumulativeDistributionIn(context.Background(), name, description, metadata, bucketer, fields...)
|
| }
|
|
|
| // NewNonCumulativeDistributionIn is like NewNonCumulativeDistribution but registers in a given context.
|
| -func NewNonCumulativeDistributionIn(c context.Context, name string, description string, bucketer *distribution.Bucketer, fields ...field.Field) NonCumulativeDistribution {
|
| +func NewNonCumulativeDistributionIn(c context.Context, name string, description string, metadata types.MetricMetadata, bucketer *distribution.Bucketer, fields ...field.Field) NonCumulativeDistribution {
|
| m := &nonCumulativeDistributionMetric{
|
| metric: metric{MetricInfo: types.MetricInfo{
|
| Name: name,
|
| @@ -289,57 +292,57 @@ func NewNonCumulativeDistributionIn(c context.Context, name string, description
|
|
|
| // NewCallbackInt returns a new integer metric whose value is populated by a
|
| // callback at collection time.
|
| -func NewCallbackInt(name string, description string, fields ...field.Field) CallbackInt {
|
| - return NewInt(name, description, fields...)
|
| +func NewCallbackInt(name string, description string, metadata types.MetricMetadata, fields ...field.Field) CallbackInt {
|
| + return NewInt(name, description, metadata, fields...)
|
| }
|
|
|
| // NewCallbackFloat returns a new float metric whose value is populated by a
|
| // callback at collection time.
|
| -func NewCallbackFloat(name string, description string, fields ...field.Field) CallbackFloat {
|
| - return NewFloat(name, description, fields...)
|
| +func NewCallbackFloat(name string, description string, metadata types.MetricMetadata, fields ...field.Field) CallbackFloat {
|
| + return NewFloat(name, description, metadata, fields...)
|
| }
|
|
|
| // NewCallbackString returns a new string metric whose value is populated by a
|
| // callback at collection time.
|
| -func NewCallbackString(name string, description string, fields ...field.Field) CallbackString {
|
| - return NewString(name, description, fields...)
|
| +func NewCallbackString(name string, description string, metadata types.MetricMetadata, fields ...field.Field) CallbackString {
|
| + return NewString(name, description, metadata, fields...)
|
| }
|
|
|
| // NewCallbackBool returns a new bool metric whose value is populated by a
|
| // callback at collection time.
|
| -func NewCallbackBool(name string, description string, fields ...field.Field) CallbackBool {
|
| - return NewBool(name, description, fields...)
|
| +func NewCallbackBool(name string, description string, metadata types.MetricMetadata, fields ...field.Field) CallbackBool {
|
| + return NewBool(name, description, metadata, fields...)
|
| }
|
|
|
| // NewCallbackDistribution returns a new distribution metric whose value is
|
| // populated by a callback at collection time.
|
| -func NewCallbackDistribution(name string, description string, bucketer *distribution.Bucketer, fields ...field.Field) CallbackDistribution {
|
| - return NewNonCumulativeDistribution(name, description, bucketer, fields...)
|
| +func NewCallbackDistribution(name string, description string, metadata types.MetricMetadata, bucketer *distribution.Bucketer, fields ...field.Field) CallbackDistribution {
|
| + return NewNonCumulativeDistribution(name, description, metadata, bucketer, fields...)
|
| }
|
|
|
| // NewCallbackIntIn is like NewCallbackInt but registers in a given context.
|
| -func NewCallbackIntIn(c context.Context, name string, description string, fields ...field.Field) CallbackInt {
|
| - return NewIntIn(c, name, description, fields...)
|
| +func NewCallbackIntIn(c context.Context, name string, description string, metadata types.MetricMetadata, fields ...field.Field) CallbackInt {
|
| + return NewIntIn(c, name, description, metadata, fields...)
|
| }
|
|
|
| // NewCallbackFloatIn is like NewCallbackFloat but registers in a given context.
|
| -func NewCallbackFloatIn(c context.Context, name string, description string, fields ...field.Field) CallbackFloat {
|
| - return NewFloatIn(c, name, description, fields...)
|
| +func NewCallbackFloatIn(c context.Context, name string, description string, metadata types.MetricMetadata, fields ...field.Field) CallbackFloat {
|
| + return NewFloatIn(c, name, description, metadata, fields...)
|
| }
|
|
|
| // NewCallbackStringIn is like NewCallbackString but registers in a given context.
|
| -func NewCallbackStringIn(c context.Context, name string, description string, fields ...field.Field) CallbackString {
|
| - return NewStringIn(c, name, description, fields...)
|
| +func NewCallbackStringIn(c context.Context, name string, description string, metadata types.MetricMetadata, fields ...field.Field) CallbackString {
|
| + return NewStringIn(c, name, description, metadata, fields...)
|
| }
|
|
|
| // NewCallbackBoolIn is like NewCallbackBool but registers in a given context.
|
| -func NewCallbackBoolIn(c context.Context, name string, description string, fields ...field.Field) CallbackBool {
|
| - return NewBoolIn(c, name, description, fields...)
|
| +func NewCallbackBoolIn(c context.Context, name string, description string, metadata types.MetricMetadata, fields ...field.Field) CallbackBool {
|
| + return NewBoolIn(c, name, description, metadata, fields...)
|
| }
|
|
|
| // NewCallbackDistributionIn is like NewCallbackDistribution but registers in a given context.
|
| -func NewCallbackDistributionIn(c context.Context, name string, description string, bucketer *distribution.Bucketer, fields ...field.Field) CallbackDistribution {
|
| - return NewNonCumulativeDistributionIn(c, name, description, bucketer, fields...)
|
| +func NewCallbackDistributionIn(c context.Context, name string, description string, metadata types.MetricMetadata, bucketer *distribution.Bucketer, fields ...field.Field) CallbackDistribution {
|
| + return NewNonCumulativeDistributionIn(c, name, description, metadata, bucketer, fields...)
|
| }
|
|
|
| // genericGet is a convenience function that tries to get a metric value from
|
| @@ -357,11 +360,13 @@ func (m *metric) genericGet(zero interface{}, c context.Context, fieldVals []int
|
|
|
| type metric struct {
|
| types.MetricInfo
|
| + types.MetricMetadata
|
| fixedResetTime time.Time
|
| }
|
|
|
| -func (m *metric) Info() types.MetricInfo { return m.MetricInfo }
|
| -func (m *metric) SetFixedResetTime(t time.Time) { m.fixedResetTime = t }
|
| +func (m *metric) Info() types.MetricInfo { return m.MetricInfo }
|
| +func (m *metric) Metadata() types.MetricMetadata { return m.MetricMetadata }
|
| +func (m *metric) SetFixedResetTime(t time.Time) { m.fixedResetTime = t }
|
|
|
| type intMetric struct{ metric }
|
|
|
|
|