Skip to content

Commit

Permalink
Merge pull request #207 from 56quarters/doc-updates
Browse files Browse the repository at this point in the history
Documentation updates and version bump for 1.4.0
  • Loading branch information
56quarters authored Apr 28, 2024
2 parents d5a01a9 + 23fcf5b commit d61354c
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 3 deletions.
6 changes: 6 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## [v1.4.0](https://github.com/56quarters/cadence/tree/1.4.0) - 2024-04-28
* Make the previously internal `MultiLineWriter` and `SocketStats` structs
available from the `cadence::ext` module per [#206](https://github.com/56quarters/cadence/pull/206).
These can be useful when creating custom `MetricSink` implementations.
Thanks to @mlowicki for this contribution.

## [v1.3.0](https://github.com/56quarters/cadence/tree/1.3.0) - 2024-03-23
* Add support for using `u64`, `i32`, and `u32` types as counters per
[#201](https://github.com/56quarters/cadence/pull/201). Thanks to @James-Bartman
Expand Down
8 changes: 8 additions & 0 deletions MIGRATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

Guides for migrating to different versions of Cadence are below.

## Migrating to 1.4.0

There are no backwards incompatible changes in this release.

## Migrating to 1.3.0

There are no backwards incompatible changes in this release.

## Migrating to 1.2.0

There are no backwards incompatible changes in this release.
Expand Down
4 changes: 2 additions & 2 deletions cadence-macros/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "cadence-macros"
version = "1.3.0"
version = "1.4.0"
authors = ["Nick Pillitteri"]
description = "Macros for Cadence, an extensible Statsd client for Rust"
homepage = "https://github.com/56quarters/cadence"
Expand All @@ -13,7 +13,7 @@ edition = "2021"
autobenches = false

[dependencies]
cadence = { path = "../cadence", version = "1.3" }
cadence = { path = "../cadence", version = "1.4" }

[dev-dependencies]
crossbeam-channel = "0.5.1"
2 changes: 1 addition & 1 deletion cadence/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "cadence"
version = "1.3.0"
version = "1.4.0"
authors = ["Nick Pillitteri"]
description = "An extensible Statsd client for Rust"
homepage = "https://github.com/56quarters/cadence"
Expand Down
31 changes: 31 additions & 0 deletions cadence/src/sinks/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use std::io;
use std::sync::atomic::{AtomicU64, Ordering};
use std::sync::Arc;

/// I/O telemetry for a `MetricSink` implementation.
#[derive(Clone, Debug, Default)]
pub struct SinkStats {
pub bytes_sent: u64,
Expand All @@ -20,6 +21,36 @@ pub struct SinkStats {
pub packets_dropped: u64,
}

/// Thread-safe collection of stats updated by network sinks.
///
/// This struct is meant to be updated internally by `MetricSink` implementations
/// and converted to an instance of `SinkStats` for consumption by external callers.
///
/// # Example
///
/// ```
/// use std::net::{SocketAddr, UdpSocket};
/// use cadence::ext::SocketStats;
/// use cadence::{MetricSink, SinkStats};
///
/// pub struct MyCustomSink {
/// addr: SocketAddr,
/// socket: UdpSocket,
/// stats: SocketStats,
/// }
///
/// impl MetricSink for MyCustomSink {
/// fn emit(&self, metric: &str) -> std::io::Result<usize> {
/// let res = self.socket.send_to(metric.as_bytes(), &self.addr);
/// self.stats.update(res, metric.len())
/// }
///
/// fn stats(&self) -> SinkStats {
/// (&self.stats).into()
/// }
/// }
///
/// ```
#[derive(Debug, Clone, Default)]
pub struct SocketStats {
bytes_sent: Arc<AtomicU64>,
Expand Down

0 comments on commit d61354c

Please sign in to comment.