Skip to content

Commit

Permalink
chore: Add OTEL_AES_CREDENTIAL_PROVIDER key to agent description (#1938)
Browse files Browse the repository at this point in the history
* Add OTEL_AES_CREDENTIAL_PROVIDER key hash to agent description

* Switch to sending key instead of hash, send in NonIdentifyingAttributes
  • Loading branch information
shazlehu authored Nov 5, 2024
1 parent 86a8e15 commit dc0aade
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
6 changes: 6 additions & 0 deletions opamp/observiq/identity.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package observiq

import (
"os"
"runtime"

ios "github.com/observiq/bindplane-agent/internal/os"
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 4 additions & 0 deletions opamp/observiq/identity_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package observiq

import (
"os"
"runtime"
"testing"

Expand Down Expand Up @@ -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"),
},
},
},
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit dc0aade

Please sign in to comment.