DataDog / datadog-lambda-go

The Datadog AWS Lambda package for Go
Apache License 2.0
59 stars 40 forks source link

Add support for tracer Env and Version tags #99

Closed xrn closed 2 years ago

xrn commented 2 years ago

I reported first this bug in DataDog/dd-trace-go but I was redirected here. I have problem to set proper Env and Version tag for my lambda -> redis connection.

Code example

import (
    "context"
    "encoding/json"
    "errors"

    ddlambda "github.com/DataDog/datadog-lambda-go"
    golambda "github.com/aws/aws-lambda-go/lambda"
)

func (d *deps) lambdaHandler(ctx context.Context) error {
...

type deps struct {
    ElastiCache      redis.UniversalClient
}

func main() {
    d := deps{
        ElastiCache: redistrace.NewClient(
            &redis.Options{
                Addr: os.Getenv("elastiCacheUrl"),
            },
            redistrace.WithServiceName("ElastiCache"),
            redistrace.WithAnalytics(true),
        ),
    }

       config = &ddlambda.Config{
        DDTraceEnabled:        true,
        MergeXrayTraces:       true,
        ShouldUseLogForwarder: true,
    }

        golambda.Start(ddlambda.WrapHandler(d.lambdaHandler, config))
}

LInk to dd-trace context issue https://github.com/DataDog/dd-trace-go/issues/1102

tianchu commented 2 years ago

@xrn It sounds like a known issue/behavior when using the Forwarder. I would encourage you to migrate to using our Lambda Extension instead. Installation instructions are here. There is also a section specifically about tagging using DD_ENV and DD_SERVICE env variables.

tianchu commented 2 years ago

Closing due to lack of activities.