metrics: more doc fixups

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
Wolfgang Bumiller 2022-02-02 14:30:14 +01:00
parent c609a58086
commit e325f4a0d8
3 changed files with 12 additions and 11 deletions

View File

@ -36,8 +36,7 @@ pub async fn test_influxdb_http(
this.test_connection().await this.test_connection().await
} }
/// Returns a [Metrics] handle that connects and sends data to the /// Get a [`Metrics`] handle for an influxdb server accessed via HTTPS.
/// given influxdb server at the given https url
pub fn influxdb_http( pub fn influxdb_http(
uri: &str, uri: &str,
organization: &str, organization: &str,

View File

@ -22,8 +22,7 @@ pub async fn test_influxdb_udp(address: &str) -> Result<(), Error> {
Ok(()) Ok(())
} }
/// Returns a [`Metrics`] handle that connects and sends data to the /// Get a [`Metrics`] handle for an influxdb server accessed via UDP.
/// given influxdb server at the given udp address/port
/// ///
/// `address` must be in the format of `ip_or_hostname:port` /// `address` must be in the format of `ip_or_hostname:port`
pub fn influxdb_udp(address: &str, mtu: Option<u16>) -> Metrics { pub fn influxdb_udp(address: &str, mtu: Option<u16>) -> Metrics {

View File

@ -11,20 +11,23 @@ mod influxdb;
pub use influxdb::{influxdb_http, influxdb_udp, test_influxdb_http, test_influxdb_udp}; pub use influxdb::{influxdb_http, influxdb_udp, test_influxdb_http, test_influxdb_udp};
#[derive(Clone)] #[derive(Clone)]
/// Structured data for the metric server /// Structured data for the metric server.
pub struct MetricsData { pub struct MetricsData {
/// The category of measurements /// The category of measurements.
pub measurement: String, pub measurement: String,
/// A list of to attach to the measurements
/// A list of to attach to the measurements.
pub tags: HashMap<String, String>, pub tags: HashMap<String, String>,
/// The actual values to send. Only plain (not-nested) objects are supported at the moment. /// The actual values to send. Only plain (not-nested) objects are supported at the moment.
pub values: Value, pub values: Value,
/// The time of the measurement
/// The time of the measurement.
pub ctime: i64, pub ctime: i64,
} }
impl MetricsData { impl MetricsData {
/// Convenient helper to create from references /// Convenient helper to create from references.
pub fn new<V: Serialize>( pub fn new<V: Serialize>(
measurement: &str, measurement: &str,
tags: &[(&str, &str)], tags: &[(&str, &str)],
@ -45,7 +48,7 @@ impl MetricsData {
} }
} }
/// Helper to send a list of [MetricsData] to a list of [Metrics] /// Helper to send a list of [`MetricsData`] to a list of [`Metrics`].
pub async fn send_data_to_channels( pub async fn send_data_to_channels(
values: &[Arc<MetricsData>], values: &[Arc<MetricsData>],
connections: &[Metrics], connections: &[Metrics],
@ -65,7 +68,7 @@ pub async fn send_data_to_channels(
/// Represents connection to the metric server which can be used to send data /// Represents connection to the metric server which can be used to send data
/// ///
/// You can send [MetricsData] by using [`Self::send_data()`], and to flush and /// You can send [`MetricsData`] by using [`Self::send_data()`], and to flush and
/// finish the connection use [`Self::join`]. /// finish the connection use [`Self::join`].
/// ///
/// If dropped, it will abort the connection and not flush out buffered data. /// If dropped, it will abort the connection and not flush out buffered data.