diff --git a/cmd/trace-agent/config/remote/config.go b/cmd/trace-agent/config/remote/config.go index c0f28ca412fc5d..1e85145e5f7446 100644 --- a/cmd/trace-agent/config/remote/config.go +++ b/cmd/trace-agent/config/remote/config.go @@ -69,10 +69,7 @@ func ConfigHandler(r *api.HTTPReceiver, cf rcclient.ConfigFetcher, cfg *config.A } if configsRequest.GetClient().GetClientTracer() != nil { normalize(&configsRequest) - if configsRequest.Client.ClientTracer.Tags == nil { - configsRequest.Client.ClientTracer.Tags = make([]string, 0) - } - configsRequest.Client.ClientTracer.Tags = append(configsRequest.Client.ClientTracer.Tags, getContainerTags(req, cfg, cidProvider)...) + configsRequest.Client.ClientTracer.ContainerTags = getContainerTags(req, cfg, cidProvider) } cfgResponse, err := cf.ClientGetConfigs(req.Context(), &configsRequest) if err != nil { diff --git a/cmd/trace-agent/config/remote/config_test.go b/cmd/trace-agent/config/remote/config_test.go index 529b2d29fdee5a..7c72add25abd78 100644 --- a/cmd/trace-agent/config/remote/config_test.go +++ b/cmd/trace-agent/config/remote/config_test.go @@ -98,7 +98,7 @@ func TestUpstreamRequest(t *testing.T) { return []string{"baz:qux"}, nil }, }, - expectedUpstreamRequest: `{"client":{"id":"test_client","is_tracer":true,"client_tracer":{"service":"test","tags":["foo:bar","baz:qux"]}}}`, + expectedUpstreamRequest: `{"client":{"id":"test_client","is_tracer":true,"client_tracer":{"service":"test","tags":["foo:bar"],"container_tags":["baz:qux"]}}}`, }, { name: "tracer tags only", @@ -114,7 +114,7 @@ func TestUpstreamRequest(t *testing.T) { return []string{"baz:qux"}, nil }, }, - expectedUpstreamRequest: `{"client":{"id":"test_client","is_tracer":true,"client_tracer":{"service":"test","tags":["baz:qux"]}}}`, + expectedUpstreamRequest: `{"client":{"id":"test_client","is_tracer":true,"client_tracer":{"service":"test","container_tags":["baz:qux"]}}}`, }, { name: "no tracer", @@ -128,6 +128,12 @@ func TestUpstreamRequest(t *testing.T) { expectedUpstreamRequest: `{"client":{"id":"test_client","is_tracer":true,"client_tracer":{"service":"test_ww_w","env":"test_ww","tags":["foo:bar"]}}}`, cfg: &config.AgentConfig{}, }, + { + name: "process tags", + tracerReq: `{"client":{"id":"test_client","is_tracer":true,"client_tracer":{"service":"33","process_tags":["foo:bar"]}}}`, + expectedUpstreamRequest: `{"client":{"id":"test_client","is_tracer":true,"client_tracer":{"service":"33","process_tags":["foo:bar"]}}}`, + cfg: &config.AgentConfig{}, + }, } for _, tc := range tcs { t.Run(tc.name, func(t *testing.T) { diff --git a/pkg/proto/datadog/remoteconfig/remoteconfig.proto b/pkg/proto/datadog/remoteconfig/remoteconfig.proto index 0389f28a749d9e..f6aee4fdc0d462 100644 --- a/pkg/proto/datadog/remoteconfig/remoteconfig.proto +++ b/pkg/proto/datadog/remoteconfig/remoteconfig.proto @@ -100,6 +100,8 @@ message ClientTracer { string env = 5; string app_version = 6; repeated string tags = 7; + repeated string process_tags = 9; + repeated string container_tags = 10; } message ClientAgent { diff --git a/pkg/proto/pbgo/core/remoteconfig.pb.go b/pkg/proto/pbgo/core/remoteconfig.pb.go index fe220b51ad8ec9..6af7d442e4b80e 100644 --- a/pkg/proto/pbgo/core/remoteconfig.pb.go +++ b/pkg/proto/pbgo/core/remoteconfig.pb.go @@ -877,6 +877,8 @@ type ClientTracer struct { Env string `protobuf:"bytes,5,opt,name=env,proto3" json:"env,omitempty"` AppVersion string `protobuf:"bytes,6,opt,name=app_version,json=appVersion,proto3" json:"app_version,omitempty"` Tags []string `protobuf:"bytes,7,rep,name=tags,proto3" json:"tags,omitempty"` + ProcessTags []string `protobuf:"bytes,9,rep,name=process_tags,json=processTags,proto3" json:"process_tags,omitempty"` + ContainerTags []string `protobuf:"bytes,10,rep,name=container_tags,json=containerTags,proto3" json:"container_tags,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -967,6 +969,20 @@ func (x *ClientTracer) GetTags() []string { return nil } +func (x *ClientTracer) GetProcessTags() []string { + if x != nil { + return x.ProcessTags + } + return nil +} + +func (x *ClientTracer) GetContainerTags() []string { + if x != nil { + return x.ContainerTags + } + return nil +} + type ClientAgent struct { state protoimpl.MessageState `protogen:"open.v1"` Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` @@ -2025,7 +2041,7 @@ const file_datadog_remoteconfig_remoteconfig_proto_rawDesc = "" + "\fcapabilities\x18\v \x01(\fR\fcapabilities\x12\x1d\n" + "\n" + "is_updater\x18\x0e \x01(\bR\tisUpdater\x12D\n" + - "\x0eclient_updater\x18\x0f \x01(\v2\x1d.datadog.config.ClientUpdaterR\rclientUpdaterJ\x04\b\x04\x10\x05J\x04\b\x05\x10\x06J\x04\b\f\x10\rJ\x04\b\r\x10\x0e\"\xf8\x01\n" + + "\x0eclient_updater\x18\x0f \x01(\v2\x1d.datadog.config.ClientUpdaterR\rclientUpdaterJ\x04\b\x04\x10\x05J\x04\b\x05\x10\x06J\x04\b\f\x10\rJ\x04\b\r\x10\x0e\"\xc2\x02\n" + "\fClientTracer\x12\x1d\n" + "\n" + "runtime_id\x18\x01 \x01(\tR\truntimeId\x12\x1a\n" + @@ -2036,7 +2052,10 @@ const file_datadog_remoteconfig_remoteconfig_proto_rawDesc = "" + "\x03env\x18\x05 \x01(\tR\x03env\x12\x1f\n" + "\vapp_version\x18\x06 \x01(\tR\n" + "appVersion\x12\x12\n" + - "\x04tags\x18\a \x03(\tR\x04tags\"\xa2\x01\n" + + "\x04tags\x18\a \x03(\tR\x04tags\x12!\n" + + "\fprocess_tags\x18\t \x03(\tR\vprocessTags\x12%\n" + + "\x0econtainer_tags\x18\n" + + " \x03(\tR\rcontainerTags\"\xa2\x01\n" + "\vClientAgent\x12\x12\n" + "\x04name\x18\x01 \x01(\tR\x04name\x12\x18\n" + "\aversion\x18\x02 \x01(\tR\aversion\x12!\n" + diff --git a/pkg/proto/pbgo/core/remoteconfig_gen.go b/pkg/proto/pbgo/core/remoteconfig_gen.go index 267a25930cd692..2c873e817e3b46 100644 --- a/pkg/proto/pbgo/core/remoteconfig_gen.go +++ b/pkg/proto/pbgo/core/remoteconfig_gen.go @@ -851,9 +851,9 @@ func (z *ClientState) Msgsize() (s int) { // MarshalMsg implements msgp.Marshaler func (z *ClientTracer) MarshalMsg(b []byte) (o []byte, err error) { o = msgp.Require(b, z.Msgsize()) - // map header, size 8 + // map header, size 10 // string "RuntimeId" - o = append(o, 0x88, 0xa9, 0x52, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x49, 0x64) + o = append(o, 0x8a, 0xa9, 0x52, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x49, 0x64) o = msgp.AppendString(o, z.RuntimeId) // string "Language" o = append(o, 0xa8, 0x4c, 0x61, 0x6e, 0x67, 0x75, 0x61, 0x67, 0x65) @@ -882,6 +882,18 @@ func (z *ClientTracer) MarshalMsg(b []byte) (o []byte, err error) { for za0002 := range z.Tags { o = msgp.AppendString(o, z.Tags[za0002]) } + // string "ProcessTags" + o = append(o, 0xab, 0x50, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x54, 0x61, 0x67, 0x73) + o = msgp.AppendArrayHeader(o, uint32(len(z.ProcessTags))) + for za0003 := range z.ProcessTags { + o = msgp.AppendString(o, z.ProcessTags[za0003]) + } + // string "ContainerTags" + o = append(o, 0xad, 0x43, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x54, 0x61, 0x67, 0x73) + o = msgp.AppendArrayHeader(o, uint32(len(z.ContainerTags))) + for za0004 := range z.ContainerTags { + o = msgp.AppendString(o, z.ContainerTags[za0004]) + } return } @@ -977,6 +989,44 @@ func (z *ClientTracer) UnmarshalMsg(bts []byte) (o []byte, err error) { return } } + case "ProcessTags": + var zb0004 uint32 + zb0004, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err, "ProcessTags") + return + } + if cap(z.ProcessTags) >= int(zb0004) { + z.ProcessTags = (z.ProcessTags)[:zb0004] + } else { + z.ProcessTags = make([]string, zb0004) + } + for za0003 := range z.ProcessTags { + z.ProcessTags[za0003], bts, err = msgp.ReadStringBytes(bts) + if err != nil { + err = msgp.WrapError(err, "ProcessTags", za0003) + return + } + } + case "ContainerTags": + var zb0005 uint32 + zb0005, bts, err = msgp.ReadArrayHeaderBytes(bts) + if err != nil { + err = msgp.WrapError(err, "ContainerTags") + return + } + if cap(z.ContainerTags) >= int(zb0005) { + z.ContainerTags = (z.ContainerTags)[:zb0005] + } else { + z.ContainerTags = make([]string, zb0005) + } + for za0004 := range z.ContainerTags { + z.ContainerTags[za0004], bts, err = msgp.ReadStringBytes(bts) + if err != nil { + err = msgp.WrapError(err, "ContainerTags", za0004) + return + } + } default: bts, err = msgp.Skip(bts) if err != nil { @@ -999,6 +1049,14 @@ func (z *ClientTracer) Msgsize() (s int) { for za0002 := range z.Tags { s += msgp.StringPrefixSize + len(z.Tags[za0002]) } + s += 12 + msgp.ArrayHeaderSize + for za0003 := range z.ProcessTags { + s += msgp.StringPrefixSize + len(z.ProcessTags[za0003]) + } + s += 14 + msgp.ArrayHeaderSize + for za0004 := range z.ContainerTags { + s += msgp.StringPrefixSize + len(z.ContainerTags[za0004]) + } return }