# README
OpenTelemetry AWS Lambda Resource Detector for Golang
This module detects resource attributes available in AWS Lambda.
Installation
go get -u go.opentelemetry.io/contrib/detectors/aws/lambda
Usage
Create a sample Lambda Go application such as below.
package main
import (
"github.com/aws/aws-lambda-go/lambda"
sdktrace "go.opencensus.io/otel/sdk/trace"
lambdadetector "go.opentelemetry.io/contrib/detectors/aws/lambda"
)
func main() {
detector := lambdadetector.NewResourceDetector()
res, err := detector.Detect(context.Background())
if err != nil {
fmt.Printf("failed to detect lambda resources: %v\n", err)
}
tp := sdktrace.NewTracerProvider(
sdktrace.WithResource(res),
)
lambda.Start(<some lambda handler>)
}
Now your TracerProvider
will have the following resource attributes and attach them to new spans:
Resource Attribute | Example Value |
---|---|
cloud.provider | aws |
cloud.region | us-east-1 |
faas.name | MyLambdaFunction |
faas.version | $LATEST |
faas.instance | 2021/06/28/[$LATEST]2f399eb14537447da05ab2a2e39309de |
faas.max_memory | 128 |
Of note, faas.id
and cloud.account.id
are not set by the Lambda resource detector because they are not available outside a Lambda invocation. For this reason, when using the AWS Lambda Instrumentation these attributes are set as additional span attributes.
Useful links
- For more on FaaS attribute conventions, visit https://opentelemetry.io/docs/specs/semconv/faas/faas-spans/
- For more information on OpenTelemetry, visit: https://opentelemetry.io/
- For more about OpenTelemetry Go: https://github.com/open-telemetry/opentelemetry-go
- For help or feedback on this project, join us in GitHub Discussions
License
Apache 2.0 - See LICENSE for more information.
# Functions
NewResourceDetector returns a resource detector that will detect AWS Lambda resources.