Comments (3)
The metrics library is not really the place for this. I recommend you check out the tracing crate.
from tokio-metrics.
Hi @declanvk, does this function satisfy your use case?
pub async fn with_metrics<F>(future: F) -> (tokio_metrics::TaskMetrics, F::Output)
where
F: std::future::Future
{
let monitor = tokio_metrics::TaskMonitor::new();
let future = monitor.instrument(future);
let result = future.await;
let metrics = monitor.cumulative();
(metrics, result)
}
You can use it like:
let (metrics, other_return_value) = with_metrics(some_future()).await;
from tokio-metrics.
Thanks @jswrenn , I think that works perfectly! I'm a little concerned about the Arc
overhead per new TaskMonitor
, but I think it should be acceptable. Thanks again!
from tokio-metrics.
Related Issues (13)
- Remove default-features = false from readme
- impl Debug for public types
- UI for metrics
- cargo test with 3 failures at main branch (e66d2ff654c72868b887f77bb472cf5d9bbbcc07) HOT 1
- Allow `Stream`s to be instrumented
- compatibility with tokio HOT 4
- Fix based on changes to yield_now HOT 1
- Compatibility with Prometheus and pull-based approach in general HOT 2
- Metric integrity in long-running applications. HOT 2
- Is it worth tracking/exposing `num_scheduled`? HOT 1
- Crisper examples of runtime metrics.
- 0.1 TODOs
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tokio-metrics.