lambda

package module
Version: v0.36.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 20, 2022 License: Apache-2.0 Imports: 6 Imported by: 4

README

OpenTelemetry AWS Lambda Resource Detector for Golang

Go Reference Apache License

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

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.

License

Apache 2.0 - See LICENSE for more information.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewResourceDetector

func NewResourceDetector() resource.Detector

NewResourceDetector returns a resource detector that will detect AWS Lambda resources.

Types

This section is empty.

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL