Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add config option to set additional attributes on all events #259

Merged
merged 7 commits into from Oct 4, 2023

Conversation

MikeGoldsmith
Copy link
Contributor

@MikeGoldsmith MikeGoldsmith commented Oct 2, 2023

Which problem is this PR solving?

When deploying the agent in multiple clusters, telemetry from each cluster get mixed together and there is no easy way to separate it. There are other use cases of setting per-cluster values too, eg SHA, cloud provider, etc.

This PR adds a configuration option to set a collection of key-value pairs that will be set on all events. For example; cluster-name=dev would add the field cluster-name with a value of dev.

Short description of the changes

  • Add new look up env func that returns a map[string]string created from a env var that holds a string of comma separated key value pairs
  • Adds AgentAttributes to config and populate from ADDITIONAL_ATTRIBUTES env var using new env look up func
  • Add the map of attributes to libhoney fields during libhoney init
  • Update config tests to verify expected behaviour

How to verify that this has the expected result

When additional attributes are provided, they are added to all events.

@MikeGoldsmith MikeGoldsmith added the type: enhancement New feature or request label Oct 2, 2023
@MikeGoldsmith MikeGoldsmith requested a review from a team as a code owner October 2, 2023 11:25
@MikeGoldsmith MikeGoldsmith self-assigned this Oct 2, 2023
@MikeGoldsmith MikeGoldsmith changed the title feat: Add cluster name to config and set in event fields feat: Add config option to set additional fields on all events Oct 3, 2023
Copy link
Contributor

@JamieDanielson JamieDanielson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great! My only thought... naming is hard. I'm thinking we may want something like ADDITIONAL_ATTRIBUTES or something without agent in the name, because it's not about the agent per se. k8s agent uses additionalFields but I think attributes is more of the term we'd be leaning toward as it gets closer to OTel naming schemes. What do you think?

@MikeGoldsmith
Copy link
Contributor Author

Sure, happy to use additional attributes instead 👍🏻

@MikeGoldsmith MikeGoldsmith changed the title feat: Add config option to set additional fields on all events feat: Add config option to set additional attributes on all events Oct 4, 2023
Copy link
Contributor

@JamieDanielson JamieDanielson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉

@JamieDanielson JamieDanielson merged commit e9e82a9 into main Oct 4, 2023
6 checks passed
@JamieDanielson JamieDanielson deleted the mike/cluster-name branch October 4, 2023 13:52
JamieDanielson pushed a commit that referenced this pull request Oct 4, 2023
## Which problem is this PR solving?
Prepares the v0.0.20-alpha release.

## Short description of the changes
- Add changelog entry
- Update agent version

**Note**: The release includes references to the following PRs that are
not merged yet:
- #259 
- #266 

I've also used the @ notation for contributor names to see if GitHub
automatically links them.

## How to verify that this has the expected result
A new release of the agent can be published.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support a configurable cluster name attribute to include in event data
2 participants