metrics

package
v1.12.0 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2023 License: Apache-2.0 Imports: 23 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

* Unless explicitly stated otherwise all files in this repository are licensed * under the Apache License Version 2.0. * * This product includes software developed at Datadog (https://www.datadoghq.com/). * Copyright 2021 Datadog, Inc.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddListener added in v0.2.4

func AddListener(ctx context.Context, listener *Listener) context.Context

AddListener adds a metrics listener to a context object

func MakeCircuitBreaker added in v0.10.0

func MakeCircuitBreaker(circuitBreakerInterval time.Duration, circuitBreakerTimeout time.Duration, circuitBreakerTotalFailures uint32) *gobreaker.CircuitBreaker

Types

type APIClient

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

APIClient send metrics to Datadog, via the Datadog API

func MakeAPIClient

func MakeAPIClient(ctx context.Context, options APIClientOptions) *APIClient

MakeAPIClient creates a new API client with the given api and app keys

func (*APIClient) SendMetrics

func (cl *APIClient) SendMetrics(metrics []APIMetric) error

SendMetrics posts a batch metrics payload to the Datadog API

type APIClientOptions added in v0.2.4

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

APIClientOptions contains instantiation options from creating an APIClient.

type APIMetric

type APIMetric struct {
	Name       string        `json:"metric"`
	Host       *string       `json:"host,omitempty"`
	Tags       []string      `json:"tags,omitempty"`
	MetricType MetricType    `json:"type"`
	Interval   *float64      `json:"interval,omitempty"`
	Points     []interface{} `json:"points"`
}

APIMetric is a metric that can be marshalled to send to the metrics API

type BatchKey

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

BatchKey identifies a batch of metrics

type Batcher

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

Batcher aggregates metrics with common properties,(metric name, tags, type etc)

func MakeBatcher

func MakeBatcher(batchInterval time.Duration) *Batcher

MakeBatcher creates a new batcher object

func (*Batcher) AddMetric

func (b *Batcher) AddMetric(metric Metric)

AddMetric adds a point to a given metric

func (*Batcher) ToAPIMetrics

func (b *Batcher) ToAPIMetrics() []APIMetric

ToAPIMetrics converts the current batch of metrics into API metrics

type Client

type Client interface {
	SendMetrics(metrics []APIMetric) error
}

Client sends metrics to Datadog

type Config

type Config struct {
	APIKey                      string
	KMSAPIKey                   string
	Site                        string
	ShouldRetryOnFailure        bool
	ShouldUseLogForwarder       bool
	BatchInterval               time.Duration
	EnhancedMetrics             bool
	HTTPClientTimeout           time.Duration
	CircuitBreakerInterval      time.Duration
	CircuitBreakerTimeout       time.Duration
	CircuitBreakerTotalFailures uint32
}

Config gives options for how the listener should work

type Decrypter added in v0.2.4

type Decrypter interface {
	Decrypt(cipherText string) (string, error)
}

Decrypter attempts to decrypt a key

func MakeKMSDecrypter added in v0.2.4

func MakeKMSDecrypter() Decrypter

MakeKMSDecrypter creates a new decrypter which uses the AWS KMS service to decrypt variables

type Distribution

type Distribution struct {
	Name   string
	Tags   []string
	Host   *string
	Values []MetricValue
}

Distribution is a type of metric that is aggregated over multiple hosts

func (*Distribution) AddPoint

func (d *Distribution) AddPoint(timestamp time.Time, value float64)

AddPoint adds a point to the distribution metric

func (*Distribution) Join

func (d *Distribution) Join(metric Metric)

Join creates a union between two metric sets

func (*Distribution) ToAPIMetric

func (d *Distribution) ToAPIMetric(interval time.Duration) []APIMetric

ToAPIMetric converts a distribution into an API ready format.

func (*Distribution) ToBatchKey

func (d *Distribution) ToBatchKey() BatchKey

ToBatchKey returns a key that can be used to batch the metric

type Listener

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

Listener implements wrapper.HandlerListener, injecting metrics into the context

func GetListener added in v0.2.4

func GetListener(ctx context.Context) *Listener

GetListener retrieves the metrics listener from a context object.

func MakeListener

func MakeListener(config Config, extensionManager *extension.ExtensionManager) Listener

MakeListener initializes a new metrics lambda listener

func (*Listener) AddDistributionMetric added in v0.2.4

func (l *Listener) AddDistributionMetric(metric string, value float64, timestamp time.Time, forceLogForwarder bool, tags ...string)

AddDistributionMetric sends a distribution metric

func (*Listener) HandlerFinished

func (l *Listener) HandlerFinished(ctx context.Context, err error)

HandlerFinished implemented as part of the wrapper.HandlerListener interface

func (*Listener) HandlerStarted

func (l *Listener) HandlerStarted(ctx context.Context, msg json.RawMessage) context.Context

HandlerStarted adds metrics service to the context

type Metric

type Metric interface {
	AddPoint(timestamp time.Time, value float64)
	ToAPIMetric(interval time.Duration) []APIMetric
	ToBatchKey() BatchKey
	Join(metric Metric)
}

Metric represents a metric that can have any kind of

type MetricType

type MetricType string

MetricType enumerates all the available metric types

const (

	// DistributionType represents a distribution metric
	DistributionType MetricType = "distribution"
)

type MetricValue added in v0.2.0

type MetricValue struct {
	Value     float64
	Timestamp time.Time
}

MetricValue represents a datapoint for a metric

type Processor

type Processor interface {
	// AddMetric sends a metric to the agent
	AddMetric(metric Metric)
	// StartProcessing begins processing metrics asynchronously
	StartProcessing()
	// FinishProcessing shuts down the agent, and tries to flush any remaining metrics
	FinishProcessing()
	// Whether the processor is still processing
	IsProcessing() bool
}

Processor is used to batch metrics on a background thread, and send them on to a client periodically.

func MakeProcessor

func MakeProcessor(ctx context.Context, client Client, timeService TimeService, batchInterval time.Duration, shouldRetryOnFail bool, circuitBreakerInterval time.Duration, circuitBreakerTimeout time.Duration, circuitBreakerTotalFailures uint32) Processor

MakeProcessor creates a new metrics context

type TimeService

type TimeService interface {
	NewTicker(duration time.Duration) *time.Ticker
	Now() time.Time
}

TimeService wraps common time related operations

func MakeTimeService

func MakeTimeService() TimeService

MakeTimeService creates a new time service

Jump to

Keyboard shortcuts

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