Skip to content

Commit b7ba964

Browse files
rarguelloFkakkoyun
andauthored
internal/telemetry: add process tags to telemetry payloads (#3586)
Co-authored-by: Kemal Akkoyun <[email protected]>
1 parent 0a3b170 commit b7ba964

File tree

3 files changed

+38
-0
lines changed

3 files changed

+38
-0
lines changed

internal/telemetry/internal/transport/body.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ type Application struct {
1818
TracerVersion string `json:"tracer_version"`
1919
LanguageName string `json:"language_name"`
2020
LanguageVersion string `json:"language_version"`
21+
ProcessTags string `json:"process_tags,omitempty"`
2122
}
2223

2324
// Host is identifying information about the host on which the app

internal/telemetry/internal/writer.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323
"github.com/DataDog/dd-trace-go/v2/internal/hostname"
2424
"github.com/DataDog/dd-trace-go/v2/internal/log"
2525
"github.com/DataDog/dd-trace-go/v2/internal/osinfo"
26+
"github.com/DataDog/dd-trace-go/v2/internal/processtags"
2627
"github.com/DataDog/dd-trace-go/v2/internal/telemetry/internal/transport"
2728
"github.com/DataDog/dd-trace-go/v2/internal/version"
2829
)
@@ -67,6 +68,7 @@ func newBody(config TracerConfig, debugMode bool) *transport.Body {
6768
TracerVersion: version.Tag,
6869
LanguageName: "go",
6970
LanguageVersion: runtime.Version(),
71+
ProcessTags: processtags.GlobalTags().String(),
7072
},
7173
Host: transport.Host{
7274
Hostname: osHostname,

internal/telemetry/internal/writer_test.go

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717
"github.com/stretchr/testify/assert"
1818
"github.com/stretchr/testify/require"
1919

20+
"github.com/DataDog/dd-trace-go/v2/internal/processtags"
2021
"github.com/DataDog/dd-trace-go/v2/internal/telemetry/internal/transport"
2122
)
2223

@@ -52,6 +53,40 @@ func TestNewWriter_NoEndpoints(t *testing.T) {
5253
assert.Nil(t, writer)
5354
}
5455

56+
func TestNewWriter_ProcessTags(t *testing.T) {
57+
cfg := WriterConfig{
58+
TracerConfig: TracerConfig{
59+
Service: "test-service",
60+
Env: "test-env",
61+
Version: "1.0.0",
62+
},
63+
Endpoints: []*http.Request{
64+
{Method: http.MethodPost, URL: &url.URL{Scheme: "http", Host: "localhost", Path: "/telemetry"}},
65+
},
66+
}
67+
68+
t.Run("enabled", func(t *testing.T) {
69+
t.Setenv("DD_EXPERIMENTAL_PROPAGATE_PROCESS_TAGS_ENABLED", "true")
70+
processtags.Reload()
71+
72+
w, err := NewWriter(cfg)
73+
require.NoError(t, err)
74+
75+
body := w.(*writer).body
76+
assert.NotEmpty(t, body.Application.ProcessTags)
77+
})
78+
t.Run("disabled", func(t *testing.T) {
79+
t.Setenv("DD_EXPERIMENTAL_PROPAGATE_PROCESS_TAGS_ENABLED", "false")
80+
processtags.Reload()
81+
82+
w, err := NewWriter(cfg)
83+
require.NoError(t, err)
84+
85+
body := w.(*writer).body
86+
assert.Empty(t, body.Application.ProcessTags)
87+
})
88+
}
89+
5590
type testPayload struct {
5691
RequestTypeValue transport.RequestType `json:"request_type"`
5792
marshalJSON func() ([]byte, error)

0 commit comments

Comments
 (0)