-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* implement drop trait Signed-off-by: Dan Bond <[email protected]> * tidy req receives Signed-off-by: Dan Bond <[email protected]> * add atomic stop bool Signed-off-by: Dan Bond <[email protected]> * bump version Signed-off-by: Dan Bond <[email protected]> * Arc::clone Signed-off-by: Dan Bond <[email protected]> * add comments Signed-off-by: Dan Bond <[email protected]> * formatting Signed-off-by: Dan Bond <[email protected]> * don't block when receiving requests Signed-off-by: Dan Bond <[email protected]> * store server Signed-off-by: Dan Bond <[email protected]> * remove serve Signed-off-by: Dan Bond <[email protected]> * no mut Signed-off-by: Dan Bond <[email protected]> * fields -> shared Signed-off-by: Dan Bond <[email protected]> * comments Signed-off-by: Dan Bond <[email protected]> * update docs Signed-off-by: Dan Bond <[email protected]> * swap -> store Signed-off-by: Dan Bond <[email protected]>
- Loading branch information
Showing
6 changed files
with
88 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "metrics_server" | ||
version = "0.2.0" | ||
version = "0.3.0" | ||
authors = ["Dan Bond <[email protected]>"] | ||
edition = "2021" | ||
rust-version = "1.58" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,31 @@ | ||
# Metrics Server | ||
# metrics_server | ||
[](https://github.com/loshz/metrics_server/actions/workflows/ci.yml) | ||
[](https://crates.io/crates/metrics_server) | ||
[](https://docs.rs/metrics_server) | ||
[](https://github.com/loshz/metrics_server/blob/main/LICENSE) | ||
|
||
A hassle-free, single-responsibility, safe HTTP server used to easily expose metrics in an application. | ||
|
||
This crate provides a thread safe, minimalstic HTTP server used to buffer metrics and serve them via a standard `/metrics` endpoint. It's aim is to remove the boilerplate needed to create such simple mechanisms. It is currently somewhat oppinionated and naive in order to maintain little complexity. | ||
|
||
## Usage | ||
|
||
Include the lib in your `Cargo.toml` dependencies: | ||
```toml | ||
[dependencies] | ||
metrics_server = "0.2" | ||
metrics_server = "0.3" | ||
``` | ||
|
||
In your application: | ||
```rust | ||
use metrics_server::MetricsServer; | ||
|
||
// Create a new server and start it in the background. | ||
let server = MetricsServer::new(); | ||
server.serve("localhost:8001"); | ||
// Create a new server and start listening for requests in the background. | ||
let server = MetricsServer::new("localhost:8001"); | ||
|
||
// Publish you application metrics periodically. | ||
// Publish you application metrics. | ||
let bytes = server.update(Vec::from([1, 2, 3, 4])); | ||
assert_eq!(bytes, 4); | ||
``` | ||
|
||
For more comprehensive usage, check out the included [examples](./examples). | ||
For more comprehensive usage, see the included [examples](./examples). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters