Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions profiler/upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (

"github.com/DataDog/dd-trace-go/v2/internal/log"
"github.com/DataDog/dd-trace-go/v2/internal/orchestrion"
"github.com/DataDog/dd-trace-go/v2/internal/processtags"
)

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

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

// DD_PROFILING_ENABLED is only used to enable profiling when added with
Expand Down
18 changes: 18 additions & 0 deletions profiler/upload_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"time"

maininternal "github.com/DataDog/dd-trace-go/v2/internal"
"github.com/DataDog/dd-trace-go/v2/internal/processtags"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -182,3 +183,20 @@ func TestGitMetadata(t *testing.T) {
assert.NotContains(profile.tags, "git.repository_url:github.com/user/repo")
})
}

func TestProcessTags(t *testing.T) {
t.Run("enabled", func(t *testing.T) {
t.Setenv("DD_EXPERIMENTAL_PROPAGATE_PROCESS_TAGS_ENABLED", "true")
processtags.Reload()

profile := doOneShortProfileUpload(t)
assert.NotEmpty(t, profile.event.ProcessTags)
})
t.Run("disabled", func(t *testing.T) {
t.Setenv("DD_EXPERIMENTAL_PROPAGATE_PROCESS_TAGS_ENABLED", "false")
processtags.Reload()

profile := doOneShortProfileUpload(t)
assert.Empty(t, profile.event.ProcessTags)
})
}
Loading