diff --git a/opamp/observiq/identity.go b/opamp/observiq/identity.go index 13a7846a2..2c9b020f1 100644 --- a/opamp/observiq/identity.go +++ b/opamp/observiq/identity.go @@ -15,6 +15,7 @@ package observiq import ( + "os" "runtime" ios "github.com/observiq/bindplane-agent/internal/os" @@ -115,6 +116,11 @@ func (i *identity) ToAgentDescription() *protobufs.AgentDescription { nonIdentifyingAttributes = append(nonIdentifyingAttributes, opamp.StringKeyValue("service.labels", *i.labels)) } + key := os.Getenv("OTEL_AES_CREDENTIAL_PROVIDER") + if key != "" { + nonIdentifyingAttributes = append(nonIdentifyingAttributes, opamp.StringKeyValue("service.key", key)) + } + agentDesc := &protobufs.AgentDescription{ IdentifyingAttributes: identifyingAttributes, NonIdentifyingAttributes: nonIdentifyingAttributes, diff --git a/opamp/observiq/identity_test.go b/opamp/observiq/identity_test.go index 487fd26ef..eff6bf22f 100644 --- a/opamp/observiq/identity_test.go +++ b/opamp/observiq/identity_test.go @@ -15,6 +15,7 @@ package observiq import ( + "os" "runtime" "testing" @@ -104,6 +105,7 @@ func TestToAgentDescription(t *testing.T) { opamp.StringKeyValue("os.family", "linux"), opamp.StringKeyValue("host.name", "my-linux-box"), opamp.StringKeyValue("host.mac_address", "68-C7-B4-EB-A8-D2"), + opamp.StringKeyValue("service.key", "test-key"), }, }, }, @@ -135,12 +137,14 @@ func TestToAgentDescription(t *testing.T) { opamp.StringKeyValue("host.name", "my-linux-box"), opamp.StringKeyValue("host.mac_address", "68-C7-B4-EB-A8-D2"), opamp.StringKeyValue("service.labels", labelsContents), + opamp.StringKeyValue("service.key", "test-key"), }, }, }, } for _, tc := range testCases { + os.Setenv("OTEL_AES_CREDENTIAL_PROVIDER", "test-key") t.Run(tc.desc, func(t *testing.T) { actual := tc.ident.ToAgentDescription() assert.Equal(t, tc.expected, actual)