check_cold_start

Function check_cold_start 

Source
pub fn check_cold_start() -> bool
Expand description

Checks if this is a cold start and clears the flag.

Returns true on the first call (cold start), and false on all subsequent calls (warm starts).

This function also checks the AWS_LAMBDA_INITIALIZATION_TYPE environment variable. If set to "provisioned-concurrency", the function returns false since provisioned concurrency pre-warms the Lambda container.

§Thread Safety

This function is safe to call from multiple threads. The atomic swap ensures that exactly one invocation will see true.

§Example

use opentelemetry_lambda_tower::check_cold_start;

// First call returns true (cold start)
// Note: In tests, this may return false if other tests ran first
let _ = check_cold_start();

// Subsequent calls return false (warm start)
assert!(!check_cold_start());