Skip to content

Commit f90e8ba

Browse files
authored
profiler: add process tags to profiling payloads (#3583)
1 parent b7ba964 commit f90e8ba

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

profiler/upload.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222

2323
"github.com/DataDog/dd-trace-go/v2/internal/log"
2424
"github.com/DataDog/dd-trace-go/v2/internal/orchestrion"
25+
"github.com/DataDog/dd-trace-go/v2/internal/processtags"
2526
)
2627

2728
// maxRetries specifies the maximum number of retries to have when an error occurs.
@@ -140,6 +141,7 @@ type uploadEvent struct {
140141
Info struct {
141142
Profiler profilerInfo `json:"profiler"`
142143
} `json:"info"`
144+
ProcessTags string `json:"process_tags,omitempty"`
143145
}
144146

145147
// profilerInfo holds profiler-specific information which should be attached to
@@ -187,6 +189,7 @@ func encode(bat batch, cfg *config) (contentType string, body io.Reader, err err
187189
Tags: strings.Join(tags, ","),
188190
EndpointCounts: bat.endpointCounts,
189191
CustomAttributes: bat.customAttributes,
192+
ProcessTags: processtags.GlobalTags().String(),
190193
}
191194

192195
// DD_PROFILING_ENABLED is only used to enable profiling when added with

profiler/upload_test.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
"time"
1515

1616
maininternal "github.com/DataDog/dd-trace-go/v2/internal"
17+
"github.com/DataDog/dd-trace-go/v2/internal/processtags"
1718

1819
"github.com/stretchr/testify/assert"
1920
"github.com/stretchr/testify/require"
@@ -182,3 +183,20 @@ func TestGitMetadata(t *testing.T) {
182183
assert.NotContains(profile.tags, "git.repository_url:github.com/user/repo")
183184
})
184185
}
186+
187+
func TestProcessTags(t *testing.T) {
188+
t.Run("enabled", func(t *testing.T) {
189+
t.Setenv("DD_EXPERIMENTAL_PROPAGATE_PROCESS_TAGS_ENABLED", "true")
190+
processtags.Reload()
191+
192+
profile := doOneShortProfileUpload(t)
193+
assert.NotEmpty(t, profile.event.ProcessTags)
194+
})
195+
t.Run("disabled", func(t *testing.T) {
196+
t.Setenv("DD_EXPERIMENTAL_PROPAGATE_PROCESS_TAGS_ENABLED", "false")
197+
processtags.Reload()
198+
199+
profile := doOneShortProfileUpload(t)
200+
assert.Empty(t, profile.event.ProcessTags)
201+
})
202+
}

0 commit comments

Comments
 (0)