Skip to content

Commit

Permalink
feat: add honeycomb resource attributes (#331)
Browse files Browse the repository at this point in the history
## Which problem is this PR solving?

- Updates #328 

## Short description of the changes

- Add `honeycomb.agent.name` and `honeycomb.agent.version` as resource
attributes to help distinguish where telemetry came from. This is
similar to the `honeycomb.distro.*` attributes in our distros, and
`telemetry.sdk.*` attributes from otel.
- Update smoke test to check for presence of the name

## How to verify that this has the expected result

Telemetry should include those fields, with no other changes

---------

Co-authored-by: Mike Goldsmth <goldsmith.mike@gmail.com>
  • Loading branch information
JamieDanielson and MikeGoldsmith committed Dec 13, 2023
1 parent 2c5a1f3 commit 59718cc
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
3 changes: 2 additions & 1 deletion handlers/libhoney_event_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ func initLibhoney(config config.Config, version string) func() {
})

// configure global fields that are set on all events
libhoney.AddField("honeycomb.agent_version", version)
libhoney.AddField("honeycomb.agent.name", "Honeycomb Network Agent")
libhoney.AddField("honeycomb.agent.version", version)

if config.AgentNodeIP != "" {
libhoney.AddField("meta.agent.node.ip", config.AgentNodeIP)
Expand Down
3 changes: 2 additions & 1 deletion handlers/otel_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ func NewOtelHandler(config config.Config, k8sClient *utils.CachedK8sClient, even
"x-honeycomb-team": config.APIKey,
}),
otelconfig.WithResourceAttributes(map[string]string{
"honeycomb.agent_version": version,
"honeycomb.agent.name": "Honeycomb Network Agent",
"honeycomb.agent.version": version,
"meta.agent.node.ip": config.AgentNodeIP,
"meta.agent.node.name": config.AgentNodeName,
"meta.agent.serviceaccount.name": config.AgentServiceAccount,
Expand Down
8 changes: 8 additions & 0 deletions smoke-tests/verify.bats
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ SCOPE="hny-network-agent"
assert_equal "$result" '"smokey"'
}

@test "Agent includes Honeycomb agent resource attributes" {
result=$(resource_attributes_received | jq "select(.key == \"honeycomb.agent.name\").value.stringValue")
assert_equal "$result" '"Honeycomb Network Agent"'

version=$(resource_attributes_received | jq "select(.key == \"honeycomb.agent.version\").value.stringValue")
assert_not_empty "$version"
}

@test "Agent emits a span name '{http.method}' (per semconv)" {
result=$(span_names_for ${SCOPE})
assert_equal "$result" '"POST"'
Expand Down

0 comments on commit 59718cc

Please sign in to comment.