MCPcopy Index your code
hub / github.com/56quarters/cadence

github.com/56quarters/cadence @1.8.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release 1.8.0 ↗ · + Follow
498 symbols 1,347 edges 43 files 98 documented · 20% updated 2mo ago★ 1034 open issues
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Cadence

build status docs.rs crates.io Rust 1.70+

Cadence Documentation

Macros Documentation

An extensible Statsd client for Rust!

Cadence is a fast and flexible way to emit Statsd metrics from your application.

Features

  • Support for emitting counters, timers, histograms, distributions, gauges, meters, and sets to Statsd over UDP (or optionally Unix sockets).
  • Support for alternate backends via the MetricSink trait.
  • Support for Datadog style metrics tags and extensions.
  • Macros to simplify common calls to emit metrics
  • A simple yet flexible API for sending metrics.

Usage

An example of how to use Cadence for maximum performance is given below. For many more examples and advanced use cases, see the cadence crate or the documentation.

use std::net::UdpSocket;
use cadence::prelude::*;
use cadence::{StatsdClient, QueuingMetricSink, BufferedUdpMetricSink, DEFAULT_PORT};

let socket = UdpSocket::bind("0.0.0.0:0").unwrap();
socket.set_nonblocking(true).unwrap();

let host = ("metrics.example.com", DEFAULT_PORT);
let udp_sink = BufferedUdpMetricSink::from(host, socket).unwrap();
let queuing_sink = QueuingMetricSink::from(udp_sink);
let client = StatsdClient::from_sink("my.prefix", queuing_sink);

client.count("my.counter.thing", 29);
client.time("my.service.call", 214);

Project layout

The cadence crate contains the Statsd client and primary API of Cadence. The cadence-macros crate contains optional macros that can simplify use of the Cadence API.

Documentation

The documentation is available at https://docs.rs/cadence/ or https://docs.rs/cadence-macros/

Source

The source code is available on GitHub at https://github.com/56quarters/cadence

Changes

Release notes for Cadence can be found in the CHANGES.md file.

Development

Cadence uses Cargo for performing various development tasks.

To build Cadence:

$ cargo build

To run tests:

$ cargo test

or:

$ cargo test -- --ignored

To run benchmarks:

$ cargo bench

To build documentation:

$ cargo doc

License

Cadence is licensed under either of

  • Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
  • MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)

at your option.

Example code in Cadence (cadence/examples or cadence-macros/examples) is available under the CC0 Public Domain Dedication (LICENSE-CC0 or https://creativecommons.org/share-your-work/public-domain/cc0/).

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you shall be dual licensed as above, without any additional terms or conditions.

Language Support

Cadence (latest master) supports building with a range of 1.70+ versions.

Guaranteed to Build

The latest version of Cadence is tested against and will always build correctly with

  • The current stable version.
  • The previous two stable versions, stable - 1 and stable - 2.

Best Effort Build

The latest version of Cadence is tested against and will usually build correctly with

  • The next two oldest stable versions, stable - 3 and stable - 4.

Support for these versions may be dropped for a release in order to take advantage of a feature available in newer versions of Rust.

Extension points exported contracts — how you extend this code

Metric (Interface)
Trait for metrics to expose Statsd metric string slice representation. Implementing metrics know how to turn themselves [7 …
cadence/src/types.rs
RequestHandler (Interface)
(no doc) [1 implementers]
cadence/examples/arc-wrapped-client.rs
ToHistogramValue (Interface)
Conversion trait for valid values for histograms This trait must be implemented for any types that are used as histogra [6 …
cadence/src/client.rs
MetricSink (Interface)
Trait for various backends that send Statsd metrics somewhere. The metric string will be in the canonical format to be [13 …
cadence/src/sinks/core.rs
ToCounterValue (Interface)
Conversion trait for valid values for counters This trait must be implemented for any types that are used as counter va [4 …
cadence/src/client.rs
ToTimerValue (Interface)
Conversion trait for valid values for timers This trait must be implemented for any types that are used as timer values [4 …
cadence/src/client.rs

Core symbols most depended-on inside this repo

with_tag
called by 55
cadence/src/client.rs
try_send
called by 46
cadence/src/builder.rs
time
called by 28
cadence/src/client.rs
histogram
called by 24
cadence/src/builder.rs
build
called by 21
cadence/src/client.rs
count_with_tags
called by 19
cadence/src/client.rs
count
called by 19
cadence/src/builder.rs
gauge
called by 19
cadence/src/builder.rs

Shape

Function 227
Method 191
Class 51
Interface 23
Enum 6

Languages

Rust100%

Modules by API surface

cadence/src/client.rs120 symbols
cadence/src/builder.rs69 symbols
cadence/src/sinks/queuing.rs39 symbols
cadence/src/types.rs38 symbols
cadence/src/sinks/udp.rs24 symbols
cadence/src/io.rs22 symbols
cadence/src/sinks/resolve.rs20 symbols
cadence/src/test.rs19 symbols
cadence/src/sinks/unix.rs14 symbols
cadence/src/sinks/spy.rs14 symbols
cadence/src/sinks/core.rs14 symbols
cadence/tests/utils.rs10 symbols

For agents

$ claude mcp add cadence \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact