Documentation ¶
Index ¶
- type Config
- type LogWrapper
- type Logger
- type Metric
- type Metrics
- type Result
- type Samples
- type Tag
- type Tags
- type Trap
- type TrapMetrics
- func (tm *TrapMetrics) CounterAdjustByValue(name string, tags Tags, val int64) error
- func (tm *TrapMetrics) CounterFetch(name string, tags Tags) (*Metric, error)
- func (tm *TrapMetrics) CounterIncrement(name string, tags Tags) error
- func (tm *TrapMetrics) CounterIncrementByValue(name string, tags Tags, val uint64) error
- func (tm *TrapMetrics) CumulativeHistogramFetch(name string, tags Tags) (*Metric, error)
- func (tm *TrapMetrics) CumulativeHistogramRecordCountForValue(name string, tags Tags, count int64, val float64) error
- func (tm *TrapMetrics) Flush(ctx context.Context) (*Result, error)
- func (tm *TrapMetrics) FlushRawJSON(ctx context.Context, data []byte) (*Result, error)
- func (tm *TrapMetrics) FlushWithBuffer(ctx context.Context, buf bytes.Buffer) (*Result, error)
- func (tm *TrapMetrics) GaugeAdd(name string, tags Tags, val interface{}, ts *time.Time) error
- func (tm *TrapMetrics) GaugeFetch(name string, tags Tags) (*Metric, error)
- func (tm *TrapMetrics) GaugeSet(name string, tags Tags, val interface{}, ts *time.Time) error
- func (tm *TrapMetrics) HistogramFetch(name string, tags Tags) (*Metric, error)
- func (tm *TrapMetrics) HistogramRecordCountForValue(name string, tags Tags, count int64, val float64) error
- func (tm *TrapMetrics) HistogramRecordDuration(name string, tags Tags, val time.Duration) error
- func (tm *TrapMetrics) HistogramRecordTiming(name string, tags Tags, val float64) error
- func (tm *TrapMetrics) HistogramRecordValue(name string, tags Tags, val float64) error
- func (tm *TrapMetrics) JSONMetrics() ([]byte, error)
- func (tm *TrapMetrics) QueueCheckTag(key, val string)
- func (tm *TrapMetrics) TextFetch(name string, tags Tags) (*Metric, error)
- func (tm *TrapMetrics) TextSet(name string, tags Tags, val string, ts *time.Time) error
- func (tm *TrapMetrics) TrapID() string
- func (tm *TrapMetrics) UpdateCheckTags(ctx context.Context) (*apiclient.CheckBundle, error)
- func (tm *TrapMetrics) WriteJSONMetrics(w io.Writer) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { // Trap instance of go-trapcheck (or something satisfying Trap interface) to use trapmetrics as a // metric container and handle transport externally, pass nil Trap Trap // Logger instance of something satisfying Logger interface (default: log.Logger with ioutil.Discard) Logger Logger // NonPrintCharReplace replacement for non-printable characters NonPrintCharReplace string // Trap ID (used for caching check bundle) TrapID string // GlobalTags is a list of tags to be added to every metric GlobalTags Tags // BufferSize size of metric buffer (when flushing), default is defaultBufferSize above BufferSize uint }
type LogWrapper ¶
LogWrapper is a wrapper around Go's log.Logger.
func (*LogWrapper) Debugf ¶
func (lw *LogWrapper) Debugf(fmt string, v ...interface{})
func (*LogWrapper) Errorf ¶
func (lw *LogWrapper) Errorf(fmt string, v ...interface{})
func (*LogWrapper) Infof ¶
func (lw *LogWrapper) Infof(fmt string, v ...interface{})
func (*LogWrapper) Printf ¶
func (lw *LogWrapper) Printf(fmt string, v ...interface{})
func (*LogWrapper) Warnf ¶
func (lw *LogWrapper) Warnf(fmt string, v ...interface{})
type Logger ¶
type Logger interface { Printf(fmt string, v ...interface{}) Debugf(fmt string, v ...interface{}) Infof(fmt string, v ...interface{}) Warnf(fmt string, v ...interface{}) Errorf(fmt string, v ...interface{}) }
Logger is a generic logging interface.
type Metric ¶
type Tags ¶
type Tags []Tag
type Trap ¶
type Trap interface { SendMetrics(ctx context.Context, metrics bytes.Buffer) (*trapcheck.TrapResult, error) UpdateCheckTags(ctx context.Context, tags []string) (*apiclient.CheckBundle, error) }
Trap defines the interface for for submitting metrics.
type TrapMetrics ¶
type TrapMetrics struct { Log Logger // contains filtered or unexported fields }
func New ¶
func New(cfg *Config) (*TrapMetrics, error)
func (*TrapMetrics) CounterAdjustByValue ¶
func (tm *TrapMetrics) CounterAdjustByValue(name string, tags Tags, val int64) error
CounterAdjustByValue will adjust the named counter by the passed value.
func (*TrapMetrics) CounterFetch ¶
func (tm *TrapMetrics) CounterFetch(name string, tags Tags) (*Metric, error)
CounterFetch will return the metric identified by name and tags.
func (*TrapMetrics) CounterIncrement ¶
func (tm *TrapMetrics) CounterIncrement(name string, tags Tags) error
CounterIncrement will increment the named counter by 1.
func (*TrapMetrics) CounterIncrementByValue ¶
func (tm *TrapMetrics) CounterIncrementByValue(name string, tags Tags, val uint64) error
CounterIncrementByValue will increment the named counter by the passed value.
func (*TrapMetrics) CumulativeHistogramFetch ¶
func (tm *TrapMetrics) CumulativeHistogramFetch(name string, tags Tags) (*Metric, error)
CumulativeHistogramFetch will return the metric identified by name and tags.
func (*TrapMetrics) CumulativeHistogramRecordCountForValue ¶
func (tm *TrapMetrics) CumulativeHistogramRecordCountForValue(name string, tags Tags, count int64, val float64) error
CumulativeHistogramRecordCountForValue add count n for value to histogram.
func (*TrapMetrics) Flush ¶
func (tm *TrapMetrics) Flush(ctx context.Context) (*Result, error)
Flush sends metrics to the configured trap check, returns result or an error.
func (*TrapMetrics) FlushRawJSON ¶ added in v0.0.7
FlushRawJSON sends JSON (in httptrap format) data to the broker.
func (*TrapMetrics) FlushWithBuffer ¶ added in v0.0.7
FlushWithBuffer sends metrics to the configured trap check, returns result or an error.
func (*TrapMetrics) GaugeAdd ¶
GaugeAdd adds a sample with a given timestamp for a gauge to the passed value.
func (*TrapMetrics) GaugeFetch ¶
func (tm *TrapMetrics) GaugeFetch(name string, tags Tags) (*Metric, error)
GaugeFetch will return the metric identified by name and tags.
func (*TrapMetrics) GaugeSet ¶
GaugeSet sets a sample with a given timestamp for a gauge to the passed value.
func (*TrapMetrics) HistogramFetch ¶
func (tm *TrapMetrics) HistogramFetch(name string, tags Tags) (*Metric, error)
HistogramFetch will return the metric identified by name and tags.
func (*TrapMetrics) HistogramRecordCountForValue ¶
func (tm *TrapMetrics) HistogramRecordCountForValue(name string, tags Tags, count int64, val float64) error
HistogramRecordCountForValue add count n for value to histogram.
func (*TrapMetrics) HistogramRecordDuration ¶
HistogramRecordDuration adds value to histogram (duration is normalized to time.Second, but supports nanosecond granularity).
func (*TrapMetrics) HistogramRecordTiming ¶
func (tm *TrapMetrics) HistogramRecordTiming(name string, tags Tags, val float64) error
HistogramRecordTiming adds timing value to histogram.
func (*TrapMetrics) HistogramRecordValue ¶
func (tm *TrapMetrics) HistogramRecordValue(name string, tags Tags, val float64) error
HistogramRecordValue adds value to histogram.
func (*TrapMetrics) JSONMetrics ¶
func (tm *TrapMetrics) JSONMetrics() ([]byte, error)
JSONMetrics returns the current metrics in JSON format or an error - to be used when handling submission of metrics externally (e.g. aggregating multiple sets of metrics from different trapmetrics containers).
func (*TrapMetrics) QueueCheckTag ¶ added in v0.0.9
func (tm *TrapMetrics) QueueCheckTag(key, val string)
func (*TrapMetrics) TextFetch ¶
func (tm *TrapMetrics) TextFetch(name string, tags Tags) (*Metric, error)
TextFetch will return the metric identified by name and tags.
func (*TrapMetrics) TextSet ¶
TextSet sets a sample with a given timestamp for a text to the passed value.
func (*TrapMetrics) TrapID ¶ added in v0.0.9
func (tm *TrapMetrics) TrapID() string
func (*TrapMetrics) UpdateCheckTags ¶ added in v0.0.9
func (tm *TrapMetrics) UpdateCheckTags(ctx context.Context) (*apiclient.CheckBundle, error)
func (*TrapMetrics) WriteJSONMetrics ¶ added in v0.0.7
func (tm *TrapMetrics) WriteJSONMetrics(w io.Writer) error
WriteJSONMetrics writes current metrics to provided buffers in JSON format or an error - to be used when handling submission of metrics externally (e.g. aggregating multiple sets of metrics from different trapmetrics containers).