Skip to content

Commit

Permalink
tracer/stats: Only get CI tags when CI Visibility is enabled [1.71 ba…
Browse files Browse the repository at this point in the history
…ckport] (#3142)

Co-authored-by: Andrew Glaude <[email protected]>
  • Loading branch information
mtoffl01 and ajgajg1134 authored Feb 3, 2025
1 parent 1001781 commit 95b9181
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
7 changes: 6 additions & 1 deletion ddtrace/tracer/stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,17 @@ func newConcentrator(c *config, bucketSize int64, statsdClient internal.StatsdCl
env = "unknown-env"
log.Debug("No DD Env found, normally the agent should have one")
}
gitCommitSha := ""
if c.ciVisibilityEnabled {
// We only have this data if we're in CI Visibility
gitCommitSha = utils.GetCITags()[constants.GitCommitSHA]
}
aggKey := stats.PayloadAggregationKey{
Hostname: c.hostname,
Env: env,
Version: c.version,
ContainerID: "", // This intentionally left empty as the Agent will attach the container ID only in certain situations.
GitCommitSha: utils.GetCITags()[constants.GitCommitSHA],
GitCommitSha: gitCommitSha,
ImageTag: "",
}
spanConcentrator := stats.NewSpanConcentrator(sCfg, time.Now())
Expand Down
2 changes: 1 addition & 1 deletion ddtrace/tracer/stats_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func TestConcentrator(t *testing.T) {
t.Run("ciGitSha", func(t *testing.T) {
utils.AddCITags(constants.GitCommitSHA, "DEADBEEF")
transport := newDummyTransport()
c := newConcentrator(&config{transport: transport, env: "someEnv"}, (10 * time.Second).Nanoseconds(), &statsd.NoOpClientDirect{})
c := newConcentrator(&config{transport: transport, env: "someEnv", ciVisibilityEnabled: true}, (10 * time.Second).Nanoseconds(), &statsd.NoOpClientDirect{})
assert.Len(t, transport.Stats(), 0)
ss1, ok := c.newTracerStatSpan(&s1, nil)
assert.True(t, ok)
Expand Down
4 changes: 4 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ module gopkg.in/DataDog/dd-trace-go.v1

go 1.22.0

// This replace is a temporary workaround to deal with a breaking change here that is used by the datadog-agent
// It can safely be removed once this PR is released: https://github.com/DataDog/datadog-agent/pull/33370
replace github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/attributes => github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/attributes v0.20.0

require (
cloud.google.com/go/pubsub v1.36.1
github.com/99designs/gqlgen v0.17.36
Expand Down

0 comments on commit 95b9181

Please sign in to comment.