Go
Instructions for installing the Lumigo Go tracer
Overview
Configuring the Lumigo tracer for Go Lambda functions consists of two steps: installation and wrapping your code.
Supported runtimes: go1.x
Installation
Lumigo GO tracer can be installed like any other Go library through go get
:
$ go get github.com/lumigo-io/[email protected]
Or, if you are already using Go Modules, you may specify a version number as well:
$ go get github.com/lumigo-io/[email protected]
Configure Your Environment
Add AWS Lambda Layer:
arn:aws:lambda:<your-region>:114300393969:layer:lumigo-tracer-extension:38
Add Environment variable:
Key | Value |
---|---|
LUMIGO_USE_TRACER_EXTENSION | true |
Wrapping Your Lambda
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 "github.com/lumigo-io/lumigo-go-tracer"
os
)
...
func main() {
wrappedHandler := lumigotracer.WrapHandler(Handler, &lumigotracer.Config{})
lambda.Start(wrappedHandler)
}
Finally, 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.
We advise you to use the most secure available to you to store secrets such as your LUMIGO_TRACER_TOKEN
; additionally, AWS provides integrations for AWS Key Management Service that keep the values of your Lambda environment variables secure.
Then the wrapping will look like this:
import (
...
lumigotracer "github.com/lumigo-io/lumigo-go-tracer"
)
...
func main() {
wrappedHandler := lumigotracer.WrapHandler(Handler, &lumigotracer.Config{})
lambda.Start(wrappedHandler)
}
Track HTTP Requests Beta
Beta
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)
Updated 11 days ago