metrics

package
v0.0.0-...-7429660 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 29, 2023 License: Apache-2.0 Imports: 20 Imported by: 0

README

go-metrics-falcon

This is a reporter for the go-metrics library which will post the metrics to Falcon

Note

This is only compatible with Go 1.7+.

Usage

import "git.inke.cn/tpc/inf/metrics"

go metrics.New(
    metrics.DefaultRegistry, // metrics registry
    time.Second * 60,        // interval
)


fieldMetadata := falcon.FieldMetadata{Name: "request", Tags: map[string]string{"status-code": strconv.Itoa(rw.StatusCode()), "method": req.Method, "path": uriPath}}
// tag metadata is encoded into the existing 'name' field for posting to influx, as json
meter := metrics.NewMeter()
//registry.GetOrRegister(fieldMetadata.String(), meter)

License

Documentation

Index

Constants

View Source
const (
	TagCode    = "code"
	TagComment = "comment"
)

Variables

View Source
var (
	DefBuckets []int
)

Functions

func AddSuccessCode

func AddSuccessCode(cm map[int]int)

func ByteSlice2String

func ByteSlice2String(bs []byte) string

ByteSlice2String bytes to string, copy from string.Builder

func CounterDec

func CounterDec(name string, tags ...interface{})

func CounterInc

func CounterInc(name string, tags ...interface{})

func Falcon

func Falcon(r metrics.Registry, d time.Duration)

Falcon starts a Falcon reporter which will post the metrics from the given registry at each d interval.

func FalconWithTags

func FalconWithTags(r metrics.Registry, d time.Duration, tags map[string]string)

FalconWithTags starts a Falcon reporter which will post the metrics from the given registry at each d interval with the specified tags

func Gauge

func Gauge(name string, value int, tags ...interface{})

func GetOrRegisterTimer

func GetOrRegisterTimer(name string, r metrics.Registry) metrics.Timer

func Meter

func Meter(name string, value int, tags ...interface{})

func NewExpDecaySample

func NewExpDecaySample(reservoirSize int, alpha float64, rescaleThreshold time.Duration) metrics.Sample

NewExpDecaySample constructs a new exponentially-decaying sample with the given reservoir size and alpha.

func NewTimer

func NewTimer() metrics.Timer

func ReloadSuccessCode

func ReloadSuccessCode(cm map[int]int)

func SampleMax

func SampleMax(values []int64) int64

SampleMax returns the maximum value of the slice of int64.

func SampleMean

func SampleMean(values []int64) float64

SampleMean returns the mean value of the slice of int64.

func SampleMin

func SampleMin(values []int64) int64

SampleMin returns the minimum value of the slice of int64.

func SamplePercentile

func SamplePercentile(values int64Slice, p float64) float64

SamplePercentiles returns an arbitrary percentile of the slice of int64.

func SamplePercentiles

func SamplePercentiles(values int64Slice, ps []float64) []float64

SamplePercentiles returns a slice of arbitrary percentiles of the slice of int64.

func SampleStdDev

func SampleStdDev(values []int64) float64

SampleStdDev returns the standard deviation of the slice of int64.

func SampleSum

func SampleSum(values []int64) int64

SampleSum returns the sum of the slice of int64.

func SampleVariance

func SampleVariance(values []int64) float64

SampleVariance returns the variance of the slice of int64.

func SetDefaultRergistryTags

func SetDefaultRergistryTags(tags map[string]string)

func SetStatOutput

func SetStatOutput(name string)

func Timer

func Timer(name string, since time.Time, tags ...interface{})

func TimerDuration

func TimerDuration(name string, duration time.Duration, tags ...interface{})

Types

type ExpDecaySample

type ExpDecaySample struct {
	// contains filtered or unexported fields
}

ExpDecaySample is an exponentially-decaying sample using a forward-decaying priority reservoir. See Cormode et al's "Forward Decay: A Practical Time Decay Model for Streaming Systems".

<http://dimacs.rutgers.edu/~graham/pubs/papers/fwddecay.pdf>

func (*ExpDecaySample) Clear

func (s *ExpDecaySample) Clear()

Clear clears all samples.

func (*ExpDecaySample) Count

func (s *ExpDecaySample) Count() int64

Count returns the number of samples recorded, which may exceed the reservoir size.

func (*ExpDecaySample) Max

func (s *ExpDecaySample) Max() int64

Max returns the maximum value in the sample, which may not be the maximum value ever to be part of the sample.

func (*ExpDecaySample) Mean

func (s *ExpDecaySample) Mean() float64

Mean returns the mean of the values in the sample.

func (*ExpDecaySample) Min

func (s *ExpDecaySample) Min() int64

Min returns the minimum value in the sample, which may not be the minimum value ever to be part of the sample.

func (*ExpDecaySample) Percentile

func (s *ExpDecaySample) Percentile(p float64) float64

Percentile returns an arbitrary percentile of values in the sample.

func (*ExpDecaySample) Percentiles

func (s *ExpDecaySample) Percentiles(ps []float64) []float64

Percentiles returns a slice of arbitrary percentiles of values in the sample.

func (*ExpDecaySample) Size

func (s *ExpDecaySample) Size() int

Size returns the size of the sample, which is at most the reservoir size.

func (*ExpDecaySample) Snapshot

func (s *ExpDecaySample) Snapshot() metrics.Sample

Snapshot returns a read-only copy of the sample.

func (*ExpDecaySample) StdDev

func (s *ExpDecaySample) StdDev() float64

StdDev returns the standard deviation of the values in the sample.

func (*ExpDecaySample) Sum

func (s *ExpDecaySample) Sum() int64

Sum returns the sum of the values in the sample.

func (*ExpDecaySample) Update

func (s *ExpDecaySample) Update(v int64)

Update samples a new value.

func (*ExpDecaySample) Values

func (s *ExpDecaySample) Values() []int64

Values returns a copy of the values in the sample.

func (*ExpDecaySample) Variance

func (s *ExpDecaySample) Variance() float64

Variance returns the variance of the values in the sample.

type FieldMetadata

type FieldMetadata struct {
	Name    string            `json:"n"`
	Tags    map[string]string `json:"t"`
	Comment map[int]string
}

func (*FieldMetadata) String

func (f *FieldMetadata) String() string

type StandardTimer

type StandardTimer struct {
	// contains filtered or unexported fields
}

StandardTimer is the standard implementation of a Timer and uses a Histogram and Meter.

func (*StandardTimer) Count

func (t *StandardTimer) Count() int64

Count returns the number of events recorded.

func (*StandardTimer) Max

func (t *StandardTimer) Max() int64

Max returns the maximum value in the sample.

func (*StandardTimer) Mean

func (t *StandardTimer) Mean() float64

Mean returns the mean of the values in the sample.

func (*StandardTimer) Min

func (t *StandardTimer) Min() int64

Min returns the minimum value in the sample.

func (*StandardTimer) Percentile

func (t *StandardTimer) Percentile(p float64) float64

Percentile returns an arbitrary percentile of the values in the sample.

func (*StandardTimer) Percentiles

func (t *StandardTimer) Percentiles(ps []float64) []float64

Percentiles returns a slice of arbitrary percentiles of the values in the sample.

func (*StandardTimer) Rate1

func (t *StandardTimer) Rate1() float64

Rate1 returns the one-minute moving average rate of events per second.

func (*StandardTimer) Rate15

func (t *StandardTimer) Rate15() float64

Rate15 returns the fifteen-minute moving average rate of events per second.

func (*StandardTimer) Rate5

func (t *StandardTimer) Rate5() float64

Rate5 returns the five-minute moving average rate of events per second.

func (*StandardTimer) RateMean

func (t *StandardTimer) RateMean() float64

RateMean returns the meter's mean rate of events per second.

func (*StandardTimer) Snapshot

func (t *StandardTimer) Snapshot() metrics.Timer

Snapshot returns a read-only copy of the timer.

func (*StandardTimer) StdDev

func (t *StandardTimer) StdDev() float64

StdDev returns the standard deviation of the values in the sample.

func (*StandardTimer) Stop

func (t *StandardTimer) Stop()

Stop stops the meter.

func (*StandardTimer) Sum

func (t *StandardTimer) Sum() int64

Sum returns the sum in the sample.

func (*StandardTimer) Time

func (t *StandardTimer) Time(f func())

Record the duration of the execution of the given function.

func (*StandardTimer) Update

func (t *StandardTimer) Update(d time.Duration)

Record the duration of an event.

func (*StandardTimer) UpdateSince

func (t *StandardTimer) UpdateSince(ts time.Time)

Record the duration of an event that started at a time and ends now.

func (*StandardTimer) Variance

func (t *StandardTimer) Variance() float64

Variance returns the variance of the values in the sample.

type TimerSnapshot

type TimerSnapshot struct {
	// contains filtered or unexported fields
}

TimerSnapshot is a read-only copy of another Timer.

func (*TimerSnapshot) Count

func (t *TimerSnapshot) Count() int64

Count returns the number of events recorded at the time the snapshot was taken.

func (*TimerSnapshot) Max

func (t *TimerSnapshot) Max() int64

Max returns the maximum value at the time the snapshot was taken.

func (*TimerSnapshot) Mean

func (t *TimerSnapshot) Mean() float64

Mean returns the mean value at the time the snapshot was taken.

func (*TimerSnapshot) Min

func (t *TimerSnapshot) Min() int64

Min returns the minimum value at the time the snapshot was taken.

func (*TimerSnapshot) Percentile

func (t *TimerSnapshot) Percentile(p float64) float64

Percentile returns an arbitrary percentile of sampled values at the time the snapshot was taken.

func (*TimerSnapshot) Percentiles

func (t *TimerSnapshot) Percentiles(ps []float64) []float64

Percentiles returns a slice of arbitrary percentiles of sampled values at the time the snapshot was taken.

func (*TimerSnapshot) Rate1

func (t *TimerSnapshot) Rate1() float64

Rate1 returns the one-minute moving average rate of events per second at the time the snapshot was taken.

func (*TimerSnapshot) Rate15

func (t *TimerSnapshot) Rate15() float64

Rate15 returns the fifteen-minute moving average rate of events per second at the time the snapshot was taken.

func (*TimerSnapshot) Rate5

func (t *TimerSnapshot) Rate5() float64

Rate5 returns the five-minute moving average rate of events per second at the time the snapshot was taken.

func (*TimerSnapshot) RateMean

func (t *TimerSnapshot) RateMean() float64

RateMean returns the meter's mean rate of events per second at the time the snapshot was taken.

func (*TimerSnapshot) Snapshot

func (t *TimerSnapshot) Snapshot() metrics.Timer

Snapshot returns the snapshot.

func (*TimerSnapshot) StdDev

func (t *TimerSnapshot) StdDev() float64

StdDev returns the standard deviation of the values at the time the snapshot was taken.

func (*TimerSnapshot) Stop

func (t *TimerSnapshot) Stop()

Stop is a no-op.

func (*TimerSnapshot) Sum

func (t *TimerSnapshot) Sum() int64

Sum returns the sum at the time the snapshot was taken.

func (*TimerSnapshot) Time

func (*TimerSnapshot) Time(func())

Time panics. nolint:iklint

func (*TimerSnapshot) Update

func (*TimerSnapshot) Update(time.Duration)

Update panics. nolint:iklint

func (*TimerSnapshot) UpdateSince

func (*TimerSnapshot) UpdateSince(time.Time)

UpdateSince panics. nolint:iklint

func (*TimerSnapshot) Variance

func (t *TimerSnapshot) Variance() float64

Variance returns the variance of the values at the time the snapshot was taken.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL