Documentation
¶
Overview ¶
Package env reads the environment variables Powertools is configured with.
The names and the accepted values are those of Powertools for AWS Lambda (Python), so that a function keeps its configuration when it moves from one runtime to the other. An explicit option always wins over the variable, which wins over the default.
Index ¶
- Constants
- func Bool(name string, fallback bool) bool
- func Float(name string, fallback float64) float64
- func Get(name string) string
- func IsDebug() bool
- func IsDev() bool
- func IsProvisioned() bool
- func MetricsOff() bool
- func ParseBool(raw string) (value, ok bool)
- func Seconds(name string, fallback time.Duration) time.Duration
- func ServiceNameOr(fallback string) string
Constants ¶
const ( ServiceName = "POWERTOOLS_SERVICE_NAME" Dev = "POWERTOOLS_DEV" Debug = "POWERTOOLS_DEBUG" LogLevel = "POWERTOOLS_LOG_LEVEL" LegacyLogLevel = "LOG_LEVEL" LambdaLogLevel = "AWS_LAMBDA_LOG_LEVEL" LambdaLogFormat = "AWS_LAMBDA_LOG_FORMAT" LoggerSampleRate = "POWERTOOLS_LOGGER_SAMPLE_RATE" LoggerLogEvent = "POWERTOOLS_LOGGER_LOG_EVENT" LogDeduplication = "POWERTOOLS_LOG_DEDUPLICATION_DISABLED" TracerCaptureResp = "POWERTOOLS_TRACER_CAPTURE_RESPONSE" TracerCaptureErr = "POWERTOOLS_TRACER_CAPTURE_ERROR" TraceDisabled = "POWERTOOLS_TRACE_DISABLED" TraceMiddlewares = "POWERTOOLS_TRACE_MIDDLEWARES" MetricsNamespace = "POWERTOOLS_METRICS_NAMESPACE" MetricsDisabled = "POWERTOOLS_METRICS_DISABLED" MetricsFunctionName = "POWERTOOLS_METRICS_FUNCTION_NAME" DatadogFlushToLog = "DD_FLUSH_TO_LOG" ParametersMaxAge = "POWERTOOLS_PARAMETERS_MAX_AGE" ParametersSSMDecrypt = "POWERTOOLS_PARAMETERS_SSM_DECRYPT" IdempotencyDisabled = "POWERTOOLS_IDEMPOTENCY_DISABLED" CircuitBreakerDisabled = "POWERTOOLS_CIRCUIT_BREAKER_DISABLED" LambdaFunctionName = "AWS_LAMBDA_FUNCTION_NAME" LambdaFunctionVersion = "AWS_LAMBDA_FUNCTION_VERSION" LambdaFunctionMemorySize = "AWS_LAMBDA_FUNCTION_MEMORY_SIZE" LambdaInitializationType = "AWS_LAMBDA_INITIALIZATION_TYPE" LambdaTaskRoot = "LAMBDA_TASK_ROOT" LambdaMetadataAPI = "AWS_LAMBDA_METADATA_API" LambdaMetadataToken = "AWS_LAMBDA_METADATA_TOKEN" //nolint:gosec // G101: the name of a variable, not a credential Region = "AWS_REGION" XRayTraceID = "_X_AMZN_TRACE_ID" SAMLocal = "AWS_SAM_LOCAL" )
The variables every utility reads.
const DefaultServiceName = "service_undefined"
DefaultServiceName is the service of a function that does not name one, as Powertools Python calls it.
Variables ¶
This section is empty.
Functions ¶
func Bool ¶
Bool reads the variable name as a truth value, accepting what Powertools Python accepts: 1, y, yes, t, true, on and 0, n, no, f, false, off, in any case. An unset variable gives fallback; a value that is neither warns once and gives fallback too, so a typo never stops a function from starting.
func IsDebug ¶
func IsDebug() bool
IsDebug reports whether POWERTOOLS_DEBUG is on: Powertools writes down what it does internally.
func IsDev ¶
func IsDev() bool
IsDev reports whether POWERTOOLS_DEV is on: utilities trade compactness for readability (pretty JSON logs, verbose errors).
func IsProvisioned ¶
func IsProvisioned() bool
IsProvisioned reports whether the execution environment was initialized by provisioned concurrency, whose invocations never pay a cold start.
func MetricsOff ¶
func MetricsOff() bool
MetricsOff reports whether metrics are switched off, with the rule Powertools Python applies to every metrics provider: POWERTOOLS_METRICS_DISABLED is true, or POWERTOOLS_DEV is on and POWERTOOLS_METRICS_DISABLED is unset. Setting POWERTOOLS_METRICS_DISABLED to false keeps metrics on in development mode.
func ServiceNameOr ¶
ServiceNameOr returns POWERTOOLS_SERVICE_NAME, or fallback when it is unset.
Types ¶
This section is empty.