Deep Dive: AWS Lambda Functions
Deep Dive: Go Agent Configuration for AWS Lambda Functions
Last updated
Was this helpful?
Deep Dive: Go Agent Configuration for AWS Lambda Functions
This page is a deep dive into configuring the SeaLights Go Agent for AWS Lambda Functions. For more direct instructions, visit Using the SeaLights Go Agent with a Lambda Function.
AWS Lambda functions have unique performance and network constraints that require specialized agent configuration. The SeaLights Go Agent provides Light Mode specifically designed for Lambda environments.
Lambda functions must start quickly and minimize resource usage. The standard SeaLights agent includes background processes that are incompatible with Lambda's execution model:
Cold Start Impact: Background processes increase Lambda initialization time
Memory Constraints: Multiple agent threads consume precious Lambda memory allocation
Network Efficiency: Lambda benefits from optimized network routing via collectors
Execution Model: Lambda's stateless nature doesn't require persistent agent connections
Light Mode transforms the agent into a lightweight coverage collector by:
Processes Disabled:
Agent heartbeat communication
Remote configuration retrieval
Log submission to SeaLights backend
Idle mode notifications
Test event processing (footprints only)
Optimizations Enabled:
Preferential use of collector URLs for network efficiency
Special agent mode headers for backend optimization
Simplified footprint reporting without execution ID requirements
Reduced memory footprint and CPU usage
Environment Variables (Set in Lambda Configuration):
Why Runtime Configuration: These parameters should be set as Lambda environment variables, not during the build-time config/instrument steps. Setting SL_LIGHT_MODE=true during build configuration can interfere with unit test coverage collection during development.
When Light Mode is enabled, the agent:
Simplified Startup: Skips standard agent initialization processes
Footprint Only: Processes lightweight coverage footprints
Collector Priority: Routes all traffic through collector URLs (as configured with SL_COLLECTOR_URL
Cold Start Optimization:
Eliminates background goroutines that delay Lambda initialization
Reduces memory allocation during startup
Minimizes network connections during function bootstrap
Runtime Efficiency:
Lower CPU usage through simplified processing
Reduced memory footprint
Optimized network routing through collector infrastructure
No persistent connections or heartbeat overhead
Lambda Environment Variables:
Terraform Configuration:
Use Only for Lambda: Light Mode should exclusively be used for Lambda functions. It disables agent features that are beneficial for long-running applications and test runners.
Coverage Collection: Light Mode is designed for Coverage Listener Mode only. It cannot be used effectively in Test Runner Mode.
Feature Restrictions: Remote configuration, agent statistics, and real-time monitoring features are unavailable in Light Mode.
For collector setup and configuration details, refer to the SeaLights Collector Documentation.
The collector provides:
Reduced network latency for Lambda functions
Optimized data routing to SeaLights backend
Regional deployment options for compliance requirements
Last updated
Was this helpful?
Was this helpful?
SL_LIGHT_MODE=true
SL_COLLECTOR_URL=<your-collector-endpoint>SL_LIGHT_MODE=true
SL_COLLECTOR_URL=https://your-collector.example.com
SL_TOKEN=your-sealights-token
SL_LAB_ID=lambda-production-environmentresource "aws_lambda_function" "instrumented_function" {
# ... other configuration
environment {
variables = {
SL_LIGHT_MODE = "true"
SL_COLLECTOR_URL = var.sealights_collector_url
SL_TOKEN = var.sealights_token
SL_LAB_ID = "lambda-${var.environment}"
}
}
}
