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 2019 Datadog, Inc.
Index ¶
- Constants
- func AddListener(ctx context.Context, listener *Listener) context.Context
- func MakeCircuitBreaker(circuitBreakerInterval time.Duration, circuitBreakerTimeout time.Duration, ...) *gobreaker.CircuitBreaker
- type APIClient
- type APIClientOptions
- type APIMetric
- type BatchKey
- type Batcher
- type Client
- type Config
- type Decrypter
- type Distribution
- type Listener
- type Metric
- type MetricType
- type MetricValue
- type Processor
- type TimeService
Constants ¶
const ( // We don't want call to the Serverless Agent to block indefinitely for any reasons, // so here's a configuration of the timeout when calling the Serverless Agent. We also // want to let it having some time for its cold start so we should not set this too low. AgentCallTimeout = 3000 * time.Millisecond )
Variables ¶
This section is empty.
Functions ¶
func AddListener ¶
AddListener adds a metrics listener to a context object
func MakeCircuitBreaker ¶
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 ¶
SendMetrics posts a batch metrics payload to the Datadog API
type APIClientOptions ¶
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 ¶
MakeBatcher creates a new batcher object
func (*Batcher) ToAPIMetrics ¶
ToAPIMetrics converts the current batch of metrics into API metrics
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 ¶
Decrypter attempts to decrypt a key
func MakeKMSDecrypter ¶
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 ¶
GetListener retrieves the metrics listener from a context object.
func MakeListener ¶
MakeListener initializes a new metrics lambda listener
func (*Listener) AddDistributionMetric ¶
func (l *Listener) AddDistributionMetric(metric string, value float64, timestamp time.Time, forceLogForwarder bool, tags ...string)
AddDistributionMetric sends a distribution metric
func (*Listener) HandlerFinished ¶
HandlerFinished implemented as part of the wrapper.HandlerListener interface
func (*Listener) HandlerStarted ¶
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 ¶
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 ¶
TimeService wraps common time related operations
func MakeTimeService ¶
func MakeTimeService() TimeService
MakeTimeService creates a new time service