func AllRecommendedOptions() []otellambda.Option {
	options, err := tracerProviderAndFlusher()
	if err != nil {
		errorLogger.Println("failed to create recommended configuration: ", err)
		return []otellambda.Option{}
	}
	return append(options, []otellambda.Option{EventToCarrier(), Propagator()}...)
}
AllRecommendedOptions returns a list of all otellambda.Option(s)
recommended for the otellambda package when using AWS XRay
package xrayconfig
import (
	"context"
	"log"
	"os"
	"runtime"
	lambdadetector "go.opentelemetry.io/contrib/detectors/aws/lambda"
	"go.opentelemetry.io/contrib/instrumentation/github.com/aws/aws-lambda-go/otellambda"
	"go.opentelemetry.io/contrib/propagators/aws/xray"
	"go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc"
	"go.opentelemetry.io/otel/propagation"
	sdktrace "go.opentelemetry.io/otel/sdk/trace"
)
var errorLogger = log.New(log.Writer(), "OTel Lambda XRay Configuration Error: ", 0)
func xrayEventToCarrier([]byte) propagation.TextMapCarrier {
	xrayTraceID := os.Getenv("_X_AMZN_TRACE_ID")
	return propagation.HeaderCarrier{"X-Amzn-Trace-Id": []string{xrayTraceID}}
}
type asyncSafeFlusher struct {
	tp *sdktrace.TracerProvider
}
func (f asyncSafeFlusher) ForceFlush(ctx context.Context) error {
	runtime.Gosched()
	return f.tp.ForceFlush(ctx)
}
func tracerProviderAndFlusher() ([]otellambda.Option, error) {
	ctx := context.Background()
	exp, err := otlptracegrpc.New(ctx, otlptracegrpc.WithInsecure())
	if err != nil {
		return []otellambda.Option{}, err
	}
	detector := lambdadetector.NewResourceDetector()
	res, err := detector.Detect(ctx)
	if err != nil {
		return []otellambda.Option{}, err
	}
	tp := sdktrace.NewTracerProvider(
		sdktrace.WithBatcher(exp),
		sdktrace.WithIDGenerator(xray.NewIDGenerator()),
		sdktrace.WithResource(res),
	)
	return []otellambda.Option{otellambda.WithTracerProvider(tp), otellambda.WithFlusher(asyncSafeFlusher{tp: tp})}, nil
}
func EventToCarrier() otellambda.Option {
	return otellambda.WithEventToCarrier(xrayEventToCarrier)
}
func Propagator() otellambda.Option {
	return otellambda.WithPropagator(xray.Propagator{})
}