Skip to content

[BUG]: Service-override works inconsistently with go-redis v9 #4337

@d33kayyy

Description

@d33kayyy

Tracer Version(s)

2.4.1

Go Version(s)

1.25

Bug Report

I have multiple Go projects with identical setups. However, the tracing is working correctly with one project but not the other, in which the service-override cannot identify the correct dependency for a project. As a result, the time spent by downstream services is also incorrect.

I don't know if I should post it here or elsewhere, please advice.

Image Image

Reproduction Code

go.mod

	github.com/DataDog/dd-trace-go/contrib/gin-gonic/gin/v2 v2.2.3
	github.com/DataDog/dd-trace-go/contrib/go-redis/redis/v2 v2.2.3
	github.com/DataDog/dd-trace-go/contrib/redis/go-redis.v9/v2 v2.2.3
	github.com/DataDog/dd-trace-go/v2 v2.4.1
	github.com/DataDog/orchestrion v1.5.0

orchestrion.tool.go

// This file was created by `orchestrion pin`, and is used to ensure the
// `go.mod` file contains the necessary entries to ensure repeatable builds when
// using `orchestrion`. It is also used to set up which integrations are enabled.

//go:build tools

//go:generate go run github.com/DataDog/orchestrion pin -generate

package tools

// Imports in this file determine which tracer integrations are enabled in
// orchestrion. New integrations can be automatically discovered by running
// `orchestrion pin` again. You can also manually add new imports here to
// enable additional integrations. When doing so, you can run `orchestrion pin`
// to make sure manually added integrations are valid (i.e, the imported package
// includes a valid `orchestrion.yml` file).
import (
	// Ensures `orchestrion` is present in `go.mod` so that builds are repeatable.
	// Do not remove.
	_ "github.com/DataDog/orchestrion" // integration

	// Just import the necessary integrations
	_ "github.com/DataDog/dd-trace-go/contrib/gin-gonic/gin/v2"     // integration
	_ "github.com/DataDog/dd-trace-go/contrib/go-redis/redis/v2"    // integration
	_ "github.com/DataDog/dd-trace-go/contrib/redis/go-redis.v9/v2" // integration
	_ "github.com/DataDog/dd-trace-go/v2/contrib/os"                // integration
	_ "github.com/DataDog/dd-trace-go/v2/ddtrace/tracer"            // integration
	_ "github.com/DataDog/dd-trace-go/v2/orchestrion"               // integration
	_ "github.com/DataDog/dd-trace-go/v2/profiler"                  // integration
)

environment variables

  DD_TRACE_ENABLED: "true"
  DD_APPSEC_ENABLED: "false"
  DD_LOGS_INJECTION: "true"
  DD_TRACE_SAMPLING_RULES: '[{"sample_rate":0.2}]'

Both apps are built from alpine public.ecr.aws/docker/library/golang:1.25-alpine with args

ENV GOFLAGS="${GOFLAGS} '-toolexec=orchestrion toolexec'"
RUN CGO_ENABLED=0 GOOS=linux GOARCH=$TARGETARCH GOEXPERIMENT=greenteagc go build -tags="sonic avx" -o /go/bin/server ./cmd/api

code that create the redis client

package cache

import (
	"fmt"

	"github.com/redis/go-redis/v9"

	"pkg/config"
)

func New(cfg *config.Config) (*redis.Client, error) {
	if cfg == nil {
		panic("config is required")
	}

	uri := cfg.Redis.URI
	if uri != "" {
		opt, err := redis.ParseURL(uri)
		if err != nil {
			return nil, err
		}
		return redis.NewClient(opt), nil
	}

	return redis.NewClient(&redis.Options{
		Addr:     fmt.Sprintf("%s:%d", cfg.Redis.Host, cfg.Redis.Port),
		Password: cfg.Redis.Password,
		DB:       cfg.Redis.DB,
	}), nil
}

Error Logs

No response

Go Env Output

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugunintended behavior that has to be fixed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions