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

agents: add metrics transform API to agent #123

Merged
merged 3 commits into from
May 29, 2024

Conversation

trevnorris
Copy link
Member

Allow users to register a callback that will transform the metrics into a std::string that will be written to the endpoint.

Still working on tests.

@trevnorris trevnorris self-assigned this Apr 24, 2024
@trevnorris trevnorris force-pushed the trevnorris/transform-statsd branch 6 times, most recently from 7df5555 to f08389e Compare May 29, 2024 16:16
Copy link
Member

@santigimeno santigimeno left a comment

Choose a reason for hiding this comment

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

This looks much saner to me. LGTM!!

Comment on lines +563 to +554
if (Inst().get() == this) {
ASSERT_EQ(0, OnConfigurationHook(config_agent_cb, weak_from_this()));
}
Copy link
Member

Choose a reason for hiding this comment

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

This is because of the test right? Why aren't you adding the ThreadAdded/RemovedHook methods inside that conditional as well?

Copy link
Member Author

Choose a reason for hiding this comment

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

Mostly because I am being lazy. There are two main assumptions:

  1. A StatsDAgent instance will be used for the entire process lifetime
  2. At most 2 StatsDAgent instances will ever be created.

Using these assumptions, I decided it would be easier for each StatsDAgent instance to set up its own hooks to check when a new thread is created/destroyed rather than have a single global hook that would iterate through a list of StatsDAgent instances when a thread is created/destroyed. This simplified the logic a lot and will be easy to fix if we ever add the ability to remove a hook.

Though, now that I type this up I realize that all the stuff I added for the agent_list_ can be removed. Since it was never used. Will make that change.

Add API to allow retrieving all currently available SharedEnvInst
instances.

PR-URL: #123
Reviewed-by: Santiago Gimeno <santiago.gimeno@gmail.com>
The user shouldn't have access to start/stop. No need to expose them.

Also remove stop() completely.

PR-URL: #123
Reviewed-by: Santiago Gimeno <santiago.gimeno@gmail.com>
Allow users to register a callback that will transform the metrics into
a std::string that will be written to the endpoint.

In order to do this some of the internals needed to be rewritten so that
config() could be called from any thread. The internal usage of config()
has been renamed since it will always be called from the StatsDAgent
thread.

PR-URL: #123
Reviewed-by: Santiago Gimeno <santiago.gimeno@gmail.com>
@trevnorris trevnorris force-pushed the trevnorris/transform-statsd branch from f08389e to 9b03aaa Compare May 29, 2024 20:24
@trevnorris trevnorris merged commit 9b03aaa into node-v20.x-nsolid-v5.x May 29, 2024
18 of 19 checks passed
@trevnorris trevnorris deleted the trevnorris/transform-statsd branch May 29, 2024 22:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants