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

Make use of thread pool for sending metrics async #23

Closed
56quarters opened this issue Aug 6, 2016 · 2 comments
Closed

Make use of thread pool for sending metrics async #23

56quarters opened this issue Aug 6, 2016 · 2 comments
Assignees
Milestone

Comments

@56quarters
Copy link
Owner

56quarters commented Aug 6, 2016

Use the Rust thread pool library for writing metrics to the buffer asynchronously. The thread pool size would be user controlled and passed to the sink that makes use of it. Each call to MetricSink.emit would submit a task to the thread pool.

Questions:

@56quarters 56quarters added this to the 0.8.0 milestone Aug 6, 2016
@56quarters 56quarters self-assigned this Aug 6, 2016
@56quarters
Copy link
Owner Author

56quarters commented Aug 21, 2016

It's looking like this will just be an AsyncMetricSink that writes metrics to another sink in a thread. It will have no knowledge of buffering or whatnot and just delegate to another sink. It might make sense to go back and change BufferedUdpMetricSink to just do buffering, not have direct knowledge that it is writing to a UDP socket.

@56quarters
Copy link
Owner Author

Given that Sender and ThreadPool can't be shared between threads, the async metric sink is going to require a slightly different use case. We should create some examples (in docs and code) showing how you could safely use both the async version and plain buffered version.

56quarters added a commit that referenced this issue Aug 26, 2016
Create MetricSink implementation that wraps another metric sink to
emit metrics using worker threads in a thread pool.

As part of making the AsyncMetricSink easy to share between threads,
all sinks now implement reasonable `Clone` behavior. This means for
the UDP sinks that the underlying sockets (or mutex / buffers) are
wrapped in an Arc (Atomic reference count) instance. This allows
the same socket to be shared between threads and still properly
cleaned up.

Fixes #23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant