1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
//! A hassle-free, single-responsibility HTTP/S server used to easily expose metrics in an application.
//!
//! This crate provides a thread-safe, minimalistic HTTP/S 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 opinionated and naive in order to
//! maintain little complexity.
//!
//! # Examples
//!
//! ## Start a HTTP server:
//!
//! ```rust
//! use metrics_server::MetricsServer;
//!
//! // Create a new HTTP server and start listening for requests in the background.
//! let server = MetricsServer::http("localhost:8001");
//!
//! // Publish your application metrics.
//! let bytes = server.update("my_awesome_metric = 10".into());
//! assert_eq!(22, bytes);
//!
//! // Stop the server.
//! server.stop().unwrap();
//! ```
//!
//! ## Start a HTTPS server:
//!
//! ```rust
//! use metrics_server::MetricsServer;
//!
//! // Load TLS config.
//! let cert = include_bytes!("/path/to/cert.pem").to_vec();
//! let key = include_bytes!("/path/to/key.pem").to_vec();
//!
//! // Create a new HTTPS server and start listening for requests in the background.
//! let server = MetricsServer::https("localhost:8443", cert, key);
//!
//! // Publish your application metrics.
//! let bytes = server.update("my_awesome_metric = 10".into());
//! assert_eq!(22, bytes);
//!
//! // Stop the server.
//! server.stop().unwrap();
//! ```
//!
//! ## Serve a custom URL
//!
//! ```rust
//! use metrics_server::MetricsServer;
//!
//! // Create a new server and specify the URL path to serve.
//! let mut server = MetricsServer::new("localhost:8001", None, None);
//! server.serve_uri("/path/to/metrics");
//!
//! // Publish your application metrics.
//! let bytes = server.update("my_awesome_metric = 10".into());
//! assert_eq!(22, bytes);
//!
//! // Stop the server.
//! server.stop().unwrap();
//! ```
pub use Error;
pub use ;