metricemitter

package
v0.0.0-...-1fc00ed Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2024 License: Apache-2.0, BSD-3-Clause, MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client is used to initialize and emit metrics on a given pulse interval.

func NewClient

func NewClient(addr string, opts ...ClientOption) (*Client, error)

NewClient initializes a new Client and opens a gRPC connection to the given address.

func (*Client) EmitEvent

func (c *Client) EmitEvent(title, body string)

EmitEvent will emit an event as an asynchrounous metric. NOTE: Currently, due to the fact that loggregator only accepts envelopes via streaming, we are going to ignore the errors. Streams do not give proper feedback for errors due to batching. When/if loggregator accepts envelopes with a normal RPC call, we will be able to do something with an error.

func (*Client) NewCounter

func (c *Client) NewCounter(name string, opts ...MetricOption) *Counter

NewCounter will return a new Counter metric that can be incremented. The value of the counter will be sent to the Clients IngressClient at the interval configured on the Client. When the counters value is sent to the IngressClient the value is reset to 0.

func (*Client) NewGauge

func (c *Client) NewGauge(name, unit string, opts ...MetricOption) *Gauge

NewGauge will return a new Gauge metric that has a value that can be set. The value of the gauge will be sent to the Clients IngressClient at the interval configured on the Client.

type ClientOption

type ClientOption func(*Client)

ClientOption is a function that can be passed into the NewClient for optional configuration on the client.

func WithDeployment

func WithDeployment(deployment, job, index string) ClientOption

WithDeployment is a ClientOption that will set a deployment, job and index tab on every envelope sent to the IngressClient.

func WithGRPCDialOptions

func WithGRPCDialOptions(opts ...grpc.DialOption) ClientOption

WithGRPCDialOptions is a ClientOption that will set the gRPC dial options on the Clients IngressClient.

func WithOrigin

func WithOrigin(name string) ClientOption

WithOrigin is a ClientOption that will set an origin tag to be added to every envelope sent to the IngressClient.

func WithPulseInterval

func WithPulseInterval(d time.Duration) ClientOption

WithPulseInterval is a ClientOption will set the rate at which each metric will be sent to the IngressClient.

func WithSourceID

func WithSourceID(s string) ClientOption

WithSourceID is a ClientOption that will set the SourceID to be set on every envelope sent to the IngressClient.

type Counter

type Counter struct {
	Tagged
	// contains filtered or unexported fields
}

Counter stores data about a counter metric to be used by the metric emitter Client.

func NewCounter

func NewCounter(name, sourceID string, opts ...MetricOption) *Counter

NewCounter initializes a new Counter metric with a given name, sourceID and MetricOptions. This should be initialized through the metric emitter Client but is exported for making it easier to test metric emission.

func (*Counter) GetDelta

func (m *Counter) GetDelta() uint64

GetDelta atomically returns the Counters current delta.

func (*Counter) Increment

func (m *Counter) Increment(c uint64)

Increment atomically adds the given value to the Counters delta.

func (*Counter) WithEnvelope

func (m *Counter) WithEnvelope(fn func(*loggregator_v2.Envelope) error) error

WithEnvelope will take in a function that will receive a V2 Envelope. This is used by the metric emitter Client when the Counter metric is send to the IngressClient. When WithEnvelope is called the Counters delta is reset to 0, if an error is returned by the given function, the delta will be atomically added back to the Counters delta.

type Gauge

type Gauge struct {
	Tagged
	// contains filtered or unexported fields
}

Gauge stores data about a gauge metric to be used by the metric emitter Client.

func NewGauge

func NewGauge(name, unit, sourceID string, opts ...MetricOption) *Gauge

NewGauge initializes a new Gauge metric with a given name, unit, sourceID and MetricOptions. This should be initialized through the metric emitter Client but is exported for making it easier to test metric emission.

func (*Gauge) Decrement

func (m *Gauge) Decrement(value float64)

Decrement decrements the gauge by a specified value.

func (*Gauge) GetValue

func (m *Gauge) GetValue() float64

GetValue atomically returns the current value of the gauge.

func (*Gauge) Increment

func (m *Gauge) Increment(value float64)

Increment increments the gauge by a specified value.

func (*Gauge) Set

func (m *Gauge) Set(value float64)

Set atomically sets the value of the Gauge.

func (*Gauge) WithEnvelope

func (m *Gauge) WithEnvelope(fn func(*loggregator_v2.Envelope) error) error

WithEnvelope will take in a function that will receive a V2 Envelope. This is used by the metric emitter Client when the Gauge metric is send to the IngressClient.

type MetricOption

type MetricOption func(Tagged)

MetricOption is a function that can be passed to a metric on initialization that configures the metric.

func WithTags

func WithTags(tags map[string]string) MetricOption

WithTags is a MetricOption that is used to set tags on the metrics V2 Envelope when created.

func WithVersion

func WithVersion(major, minor uint) MetricOption

WithVersion is a MetricOption that can be used to set the metric version.

type Tagged

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

Tagged is a struct that is embedded into metrics to give them common functionality around tags.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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