Documentation forSolarWinds Observability SaaS

AWS Lambda instrumentation for Go

Compatibility

The OS-only runtimes provided.al2023 and provided.al2 are supported.

Most of the Go Library features are supported in the AWS Lambda environment. The exceptions are:

Instrument the function

Ensure the otelcol layer is already added and configured. Then use lambda.Start() in the Lambda function's main to initialize the Go Library, which will automatically collect a span for the function handler. The standard OpenTelemetry API can be used in the handler for additional instrumentation.

Example (copied from the README.md):

package main
import (
	"context"
	"github.com/aws/aws-lambda-go/lambda"
	"github.com/solarwinds/apm-go/instrumentation/github.com/aws/aws-lambda-go/swolambda"
)
// Example incoming type
type MyEvent struct {}
// This is an example handler, yours may have a different signature and a 
// different name. It will work as long as it adheres to what the Lambda SDK
// expects. (See "Valid handler signatures"[0])
// [0] https://docs.aws.amazon.com/lambda/latest/dg/golang-handler.html
func ExampleHandler(ctx context.Context, event *MyEvent) (string, error) {
	return "hello world", nil
}
func main() {
	// We wrap our handler here and pass the result to `lambda.Start`
	lambda.Start(swolambda.WrapHandler(ExampleHandler))
}

Configure

Set the required environment variables listed below in your Lambda function's configuration settings. Recommended and useful optional settings are also listed.

Environment Variable Description Requirement
SW_APM_TRANSACTION_NAME

<transaction-name>

Telemetry from the Lambda function will be associated with this Transaction under the SWO Service. If unset, the Transaction name defaults to the Lambda function name.

recommended
SW_APM_INITIAL_SETTINGS_FILE_TIMEOUT

Time to wait in seconds for the sampling settings file to be available. The default is 1. Set to 0 to skip waiting. Must be set to a format recognized by time.ParseDuration. See ParseDuration.

optional
SW_APM_DEBUG_LEVEL

See Logging level.

This may be useful for diagnostic purposes or reduce logging to AWS CloudWatch.

optional

The other standard Go Library configuration options that are supported in the AWS Lambda environment are: