warn

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package warn is where Powertools tells the developer about a likely mistake: what Powertools Python reports through its warnings module, such as an invalid environment variable, a utility disabled for development, a metric set flushed empty, a Datadog tag that may lose data.

Each warning is a JSON record at WARN on standard error, where Lambda collects it, with the keys Lambda's log-level filtering reads (level, timestamp, message) and the Python warning class as its category, so that a log query matches both runtimes. Unlike internal/debug, warnings are always on; each one is written once per process, as Python's default warnings filter shows a warning the first time its text appears.

Index

Constants

View Source
const (
	UserWarning                  = "UserWarning"
	PowertoolsUserWarning        = "PowertoolsUserWarning"
	DatadogDataValidationWarning = "DatadogDataValidationWarning"
)

Categories name the Python warning classes.

View Source
const NoMetrics = "No application metrics to publish. The cold-start metric may be published if enabled. " +
	"If application metrics should never be empty, consider using 'WithRaiseOnEmptyMetrics'"

NoMetrics is what a metrics flush without metrics says, as Powertools Python says it (with the Go name of the option), for every provider.

Variables

This section is empty.

Functions

func Capture

func Capture(w io.Writer) (restore func())

Capture sends the warnings to w and forgets the ones already written, until the returned function restores standard error. Tests use it; they cannot run in parallel with each other.

func Once

func Once(ctx context.Context, category, msg string, args ...any)

Once writes the warning msg of category with the attributes args, unless the same warning was written before.

Types

This section is empty.

Jump to

Keyboard shortcuts

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