Trace AWS Lambda Go functions
$ go get .com/lumigo-io/lumigo-go-tracer@master
Or, if you are already using Go Modules, you may specify a version number as well:
$ go get .com/lumigo-io/[email protected]
To add the AWS Lambda Layer that supports the provided.al2
runtime:
arn:aws:lambda:<region>:114300393969:layer:lumigo-tracer-extension-arm64:1
To add the AWS Lambda Layer that supports the go1.x
runtime:
arn:aws:lambda:<region>:114300393969:layer:lumigo-tracer-extension-x86_64:1
NOTE: go1.x
will be deprecated by AWS on December 31st, 2023. If your Go functions are still running on go1.x
, You might want to consider migrating to provided.al2
.
Set the LUMIGO_USE_TRACER_EXTENSION
environment variable of your Lambda function as follows; refer to the Using AWS Lambda environment variables documentation for more information.
Key | Value |
---|---|
LUMIGO_USE_TRACER_EXTENSION | true |
You need a Lumigo token which you can find under the Project Settings
in the Lumigo platform. Then you need to wrap your Lambda:
import (
...
lumigotracer ".com/lumigo-io/lumigo-go-tracer"
os
)
...
func main() {
wrappedHandler := lumigotracer.WrapHandler(Handler, &lumigotracer.Config{})
lambda.Start(wrappedHandler)
}
Then the wrapping will look like this:
import (
...
lumigotracer ".com/lumigo-io/lumigo-go-tracer"
)
...
func main() {
wrappedHandler := lumigotracer.WrapHandler(Handler, &lumigotracer.Config{})
lambda.Start(wrappedHandler)
}
Set your Lumigo token as the LUMIGO_TRACER_TOKEN
environment variable of your Lambda function; refer to the Using AWS Lambda environment variables documentation for more information. Your Lumigo token is available in Settings -> Tracing -> Manual tracing
, see the Lumigo Tokens documentation.
We advise you to use the most secure available to you to store secrets such as your LUMIGO_TRACER_TOKEN
; refer to AWS Lambda's Securing environment variables documentation for guidance on keeping the values of your Lambda environment variables secure.
For tracing AWS SDK v2.0 calls check the following example:
client := &http.Client{
Transport: lumigotracer.NewTransport(http.DefaultTransport),
}
// for AWS SDK v1.x
sess := session.Must(session.NewSession(&aws.Config{
HTTPClient: client,
}))
svc := s3.New(sess)
// for AWS SDK v2.x
cfg, _ := config.LoadDefaultConfig(context.Background(), config.WithHTTPClient(client))
svc := s3.NewFromConfig(cfg)
For tracing HTTP calls check the following example:
client := &http.Client{
Transport: lumigotracer.NewTransport(http.DefaultTransport),
}
req, _ := http.NewRequest("GET", "https://<your-url>", nil)
// for net/http
res, err := client.Do(req)
// for golang.org/x/net/context/ctxhttp
res, err := ctxhttp.Do(context.Background(), client, req)
- 1.16
- 1.17
- 1.18
Updated 5 months ago