dd-trace-go
dd-trace-go copied to clipboard
contrib/go-redis/redis: With env and version
Following: https://docs.datadoghq.com/getting_started/tagging/unified_service_tagging/?tab=logs
In redis tracer we can find
// WithServiceName sets the given service name for the client.
func WithServiceName(name string) ClientOption {
return func(cfg *clientConfig) {
cfg.serviceName = name
}
}
But there is no option to set env and version which is required in my case
Environment and version are specific to the running application. You set these when starting the tracer using tracer.WithEnv
and tracer.WithService
. The Redis client will inherit these, which is correct given that client is part of the original application.
@gbbr I am trying to use it with my lambda but have there no tracer itself
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))
}
Any Idea how to add env and version to redistracer?
I see. This repository is dd-trace-go
. Can you please close this issue and open it in datadog-lambda-go
? They should likely add the ability for you to set service, env, and version when starting (ddlambda.WrapHandler
). However, this is just an assumed solution since I am not familiar with that project. Perhaps they should be made part of ddlambda.Config
.