ddlambda

package module
v2.0.0-...-6854674 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2025 License: Apache-2.0, BSD-3-Clause Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DatadogAPIKeyEnvVar is the environment variable that will be used to set the API key.
	DatadogAPIKeyEnvVar = "DD_API_KEY"
	// DatadogKMSAPIKeyEnvVar is the environment variable that will be sent to KMS for decryption, then used as an API key.
	DatadogKMSAPIKeyEnvVar = "DD_KMS_API_KEY"
	// DatadogSiteEnvVar is the environment variable that will be used as the API host.
	DatadogSiteEnvVar = "DD_SITE"
	// LogLevelEnvVar is the environment variable that will be used to set the log level.
	LogLevelEnvVar = "DD_LOG_LEVEL"
	// ShouldUseLogForwarderEnvVar is the environment variable that enables log forwarding of metrics.
	ShouldUseLogForwarderEnvVar = "DD_FLUSH_TO_LOG"
	// DatadogTraceEnabledEnvVar is the environment variable that enables Datadog tracing.
	DatadogTraceEnabledEnvVar = "DD_TRACE_ENABLED"
	// MergeXrayTracesEnvVar is the environment variable that enables the merging of X-Ray and Datadog traces.
	MergeXrayTracesEnvVar = "DD_MERGE_XRAY_TRACES"
	// UniversalInstrumentation is the environment variable that enables universal instrumentation with the DD Extension
	UniversalInstrumentation = "DD_UNIVERSAL_INSTRUMENTATION"
	// Initialize otel tracer provider if enabled
	OtelTracerEnabled = "DD_TRACE_OTEL_ENABLED"
	// FIPSModeEnvVar is the environment variable that determines whether to enable FIPS mode.
	// Defaults to true in GovCloud regions and false otherwise.
	FIPSModeEnvVar = "DD_LAMBDA_FIPS_MODE"

	// DefaultSite to send API messages to.
	DefaultSite = "datadoghq.com"
	// DefaultEnhancedMetrics enables enhanced metrics by default.
	DefaultEnhancedMetrics = true
)

Variables

This section is empty.

Functions

func AddTraceHeaders

func AddTraceHeaders(ctx context.Context, req *http.Request)

AddTraceHeaders adds Datadog trace headers to a HTTP Request reflecting the current X-Ray subsegment. Deprecated: use native Datadog tracing instead.

func Distribution

func Distribution(metric string, value float64, tags ...string)

Distribution sends a distribution metric to Datadog Deprecated: Use Metric method instead

func GetContext

func GetContext() context.Context

GetContext retrieves the last created lambda context. Only use this if you aren't manually passing context through your call hierarchy.

func GetTraceHeaders

func GetTraceHeaders(ctx context.Context) map[string]string

GetTraceHeaders returns a map containing Datadog trace headers that reflect the current X-Ray subsegment. Deprecated: use native Datadog tracing instead.

func InvokeDryRun

func InvokeDryRun(callback func(ctx context.Context), cfg *Config) (interface{}, error)

InvokeDryRun is a utility to easily run your lambda for testing

func Metric

func Metric(metric string, value float64, tags ...string)

Metric sends a distribution metric to DataDog

func MetricWithTimestamp

func MetricWithTimestamp(metric string, value float64, timestamp time.Time, tags ...string)

MetricWithTimestamp sends a distribution metric to DataDog with a custom timestamp

func WrapFunction

func WrapFunction(handler interface{}, cfg *Config) interface{}

WrapFunction is used to instrument your lambda functions. It returns a modified handler that can be passed directly to the lambda.Start function from aws-lambda-go.

func WrapHandler

func WrapHandler(handler interface{}, cfg *Config) interface{}

WrapHandler is used to instrument your lambda functions. It returns a modified handler that can be passed directly to the lambda.Start function from aws-lambda-go. Deprecated: use WrapFunction instead

func WrapLambdaHandlerInterface

func WrapLambdaHandlerInterface(handler lambda.Handler, cfg *Config) lambda.Handler

WrapLambdaHandlerInterface is used to instrument your lambda functions. It returns a modified handler that can be passed directly to the lambda.StartHandler function from aws-lambda-go.

Types

type Config

type Config struct {
	// APIKey is your Datadog API key. This is used for sending metrics.
	APIKey string
	// KMSAPIKey is your Datadog API key, encrypted using the AWS KMS service. This is used for sending metrics.
	KMSAPIKey string
	// ShouldRetryOnFailure is used to turn on retry logic when sending metrics via the API. This can negatively effect the performance of your lambda,
	// and should only be turned on if you can't afford to lose metrics data under poor network conditions.
	ShouldRetryOnFailure bool
	// ShouldUseLogForwarder enabled the log forwarding method for sending metrics to Datadog. This approach requires the user to set up a custom lambda
	// function that forwards metrics from cloudwatch to the Datadog api. This approach doesn't have any impact on the performance of your lambda function.
	ShouldUseLogForwarder bool
	// BatchInterval is the period of time which metrics are grouped together for processing to be sent to the API or written to logs.
	// Any pending metrics are flushed at the end of the lambda.
	BatchInterval time.Duration
	// Site is the host to send metrics to. If empty, this value is read from the 'DD_SITE' environment variable, or if that is empty
	// will default to 'datadoghq.com'.
	Site string
	// DebugLogging will turn on extended debug logging.
	DebugLogging bool
	// EnhancedMetrics enables the reporting of enhanced metrics under `aws.lambda.enhanced*` and adds enhanced metric tags
	EnhancedMetrics bool
	// DDTraceEnabled enables the Datadog tracer.
	DDTraceEnabled bool
	// MergeXrayTraces will cause Datadog traces to be merged with traces from AWS X-Ray.
	MergeXrayTraces bool
	// HTTPClientTimeout specifies a time limit for requests to the API. It defaults to 5s.
	HTTPClientTimeout time.Duration
	// CircuitBreakerInterval is the cyclic period of the closed state
	// for the CircuitBreaker to clear the internal Counts.
	// default: 30s
	CircuitBreakerInterval time.Duration
	// CircuitBreakerTimeout is the period of the open state,
	// after which the state of the CircuitBreaker becomes half-open.
	// default: 60s
	CircuitBreakerTimeout time.Duration
	// CircuitBreakerTotalFailures after this amount of times
	// of a request failing in the closed state, the state will become open.
	// the counter will get totally reset after CircuitBreakerInterval
	// default: 4
	CircuitBreakerTotalFailures uint32
	// FIPSMode enables FIPS mode. Defaults to true in GovCloud regions and false elsewhere.
	FIPSMode *bool
	// TraceContextExtractor is the function that extracts a root/parent trace context from the Lambda event body.
	// See trace.DefaultTraceExtractor for an example.
	TraceContextExtractor trace.ContextExtractor
	// TracerOptions are additional options passed to the tracer.
	TracerOptions []tracer.StartOption
}

Config gives options for how ddlambda should behave

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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