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 ¶
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.
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) 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) 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.