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

Metrics collection for Services #2

Closed
yazaddaruvala opened this issue Oct 20, 2016 · 7 comments
Closed

Metrics collection for Services #2

yazaddaruvala opened this issue Oct 20, 2016 · 7 comments

Comments

@yazaddaruvala
Copy link

I know this will not be looked at for a while, and this might get moved to a different repo, but I wanted to get my thoughts written down.

I'd love to get more thoughts on two things:

  • We need a trait for Metrics, that a service(via middleware) can then use.
pub trait Metric {
    /// Name of service
    fn service_name(&self) -> &str;

    /// Name of api
    fn api_name(&self) -> &str;

    /// Request Id
    fn request_id(&self) -> &str; // Or `usize` or `T`

    /// Start time for the call; To calculate latency
    fn start(&self) -> Instant;

    /// End time for the call; To calculate latency
    fn end(&self) -> Instant;

    // There are some more here we can discuss later: [children_calls, error_type, or some generic "other_info"]
}
  • How would we end up returning such an object from the Future?
Future<(Response, Metrics), (Error, Metrics)>

This feels really awkward, and it breaks the fluency of Futures with .map and such. What other options do we have? Given the nature of Futures (i.e. long tasks), and the importance of metrics, it could make sense to bake in Metrics into the Future trait, but that may not be possible in a zero-cost way. Does it make sense for Tokio-Service to implement its own Future which has Metrics built-in?

@lunemec
Copy link

lunemec commented Jan 14, 2017

I suggest implementing prometheus metrics which are used by most companies for production server monitoring.

@yazaddaruvala
Copy link
Author

yazaddaruvala commented Jan 17, 2017

@lunemec I can see why you brought that point up in this thread. However, I didn't intend for this thread to be about log formats. Ideally, if we get the in memory model/code interface for Metrics correct, any application should be able to format those objects to the logs in any way they need.

To be more explicit:
Off topic: Log formats, Loggers, Log Processing/Analytics

  • How do we end up getting the metrics into the log files?
  • What do the log files look like?

On topic: The model/interface/implementation of Metrics.

  • What does a struct Metrics { ... } look like?
  • How does Metrics get created/populated in an async environment?
    • Can this be done without allocations?
  • Can we collect/expose metrics for sub-tasks, in the primary-task?

@lunemec
Copy link

lunemec commented Jan 17, 2017

Oh, sorry you are right, this is about a way to collect all these metrics (generally) ...
thank you for the clarification.

@posix4e
Copy link

posix4e commented Mar 28, 2017

I had always hoped this day would come https://github.com/posix4e/rust-metrics. The library is really fine grained. You only need Prometheus if you want them. I'm also happy to donate this code or adapt it as people wish.

@posix4e
Copy link

posix4e commented Mar 28, 2017

Hello everyone @durch is happy to help do this...

alexcrichton added a commit that referenced this issue Oct 24, 2017
In general it's easier to implement and should have more predictable performance
semantics for applications in general. More serious timer usage can go through
`tokio-timer` which has properly configurable timer wheels and such.

Closes #2
Closes #7
@carllerche
Copy link
Member

Closing this due to inactivity. I would say that this behavior can probably be implemented in a standalone crate and mature separately.

@posix4e
Copy link

posix4e commented Oct 25, 2017 via email

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

No branches or pull requests

4 participants