--- id: safe-init version: "2.0.0" license: MIT license_treatment: permissive maintenance: active --- # safe-init — Safe Init is a Python library that enhances AWS Lambda functions with advanced error handling, logging, monitoring, and resilience features, providing comprehensive observability and reliability for serverless applications. License: permissive · Maintenance: active · Downloads: 198.4K/mo ## What it is and what it does Safe Init is a wrapper library for AWS Lambda handlers that intercepts execution to add error handling, logging, and monitoring without requiring changes to your handler code. You point your Lambda's entry point to `safe_init.handler.handler`, set an environment variable to your original handler, and the library takes over—capturing unhandled exceptions, tracing function call execution times, and forwarding errors to Sentry, Datadog, or Slack depending on your configuration. The library integrates with AWS Secrets Manager for automatic secret resolution, supports dead-letter queues for failed events, detects JSON serialization failures, and sends pre-timeout notifications. It is designed as a safety net rather than a replacement for in-code error handling. Runtime dependencies include boto3 for AWS API access, Datadog and Sentry SDKs for monitoring, Redis for caching, and structlog for structured logging. Use it for: - Wrap existing Lambda functions with centralized error tracking and Sentry integration without modifying handler code - Send Slack alerts when Lambda functions encounter errors or approach timeout limits - Automatically push failed Lambda events to a dead-letter queue for asynchronous retry or analysis - Trace execution time of function calls within Lambda to identify performance bottlenecks - Automatically resolve AWS Secrets Manager secrets from environment variables during Lambda initialization ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Safe Init wraps AWS Lambda handlers to provide automatic error handling, execution tracing, and integration with monitoring services like Sentry, Datadog, and Slack. Yes, if you run AWS Lambda functions and want centralized error handling and monitoring without modifying your handler code. The library is actively maintained, has no known vulnerabilities, and low install friction. Suitable for production use. Caveat: requires Python 3.11 specifically, so verify your Lambda runtime version before adoption. ## Install pip install safe-init uv add safe-init poetry add safe-init ## Installing safe-init Before you install: Low install friction with a pure-Python wheel. Active maintenance with a recent release. Depends on 9 runtime packages including boto3, Datadog, Sentry, and Redis; all are widely used and stable. License in practice: MIT license is permissive and imposes no restrictions on use or redistribution, making it suitable for both open and closed-source projects. Quickstart: pip install safe-init # Set Lambda handler to: safe_init.handler.handler # Set environment variable: SAFE_INIT_HANDLER=mymodule.lambda_handler # Safe Init wraps your handler automatically with error handling and monitoring Requires Python 3.11 (capped at <3.12); Lambda runtime must support this version. Verify before relying: - Performance overhead of execution time tracing on Lambda cold starts and warm invocations - Compatibility with Lambda layers and custom runtimes beyond standard AWS Lambda environments - Behavior when multiple monitoring integrations (Sentry, Datadog, Slack) are configured simultaneously ## Package facts - License: MIT (permissive) - Python support: capped_below_current - Install friction: low - Maintenance: active - Downloads: 198.4K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags aws lambda error handling, lambda monitoring and logging, sentry datadog lambda integration, lambda timeout notifications, serverless error tracking, lambda dead letter queue, lambda execution tracing, aws-lambda, error-handling, observability [View on SkillFed](https://skillfed.io/packages/safe-init) · [View on PyPI](https://pypi.org/project/safe-init/)