A high performance/low-overhead OpenMetrics library for Rust

Overview

* * * EXPERIMENTAL * * *

discreet-metrics

A high-performance/low-overhead metrics library aiming to conform with OpenMetrics and to satisfy the following goals:

  • memory requirements for metrics are deterministic and fixed at compile time
  • able to run on no-std targets as well as std
  • sympathetic to hardware with limited support for atomics and floating types
  • avoids the use of an allocator in support bare metal targets

As this library is intended to run on resource-constrained targets, you can expect good performance on targets in general.

An example

use core::ptr::NonNull;
use discreet_metrics::{ encoders::text::TextEncoder, metrics::counter::Counter, MetricDesc, Registry };
use std::sync::Once;

// A registry will be typically declared in a static
static REGISTRY: Registry = Registry::new();

// Then referenced from within a file where it is required
// ```
// extern "Rust" {
//    static REGISTRY: Registry<'static>;
//}

// Declare a metric in a file where it is used, again as a static
static SOME_METRIC: Counter = Counter::new();
static mut SOME_METRIC_DESC: MetricDesc = 
    MetricDesc::new("some-metric", "Some metric", None, &["some-label"], &SOME_METRIC);

// Register the metric descriptor - once, and only once! The following is achieved
// using std::sync::Once, but other methods including the lazy_static library can be
// used. This initialization would also typically appear within the file where the
// metric is used.
static REGISTER_METRICS: Once = Once::new();
    
// later...
REGISTER_METRICS.call_once(|| {
    REGISTRY.register(unsafe { &mut SOME_METRIC_DESC });
});

// Do what we do with metric counters!
SOME_METRIC.inc();

// Elsewhere, establish the encoder and output its bytes somewhere 
// either periodically or on demand.
let mut encoder = TextEncoder;
let _encoder = REGISTRY.encode(&mut encoder);

Contribution policy

Contributions via GitHub pull requests are gladly accepted from their original author. Along with any pull requests, please state that the contribution is your original work and that you license the work to the project under the project's open source license. Whether or not you state this explicitly, by submitting any copyrighted material via pull request, email, or other means you agree to license the material under the project's open source license and warrant that you have the legal authority to do so.

License

This code is open source software licensed under the Apache-2.0 license.

© Copyright Titan Class P/L, 2022

You might also like...
The High Performance Proxy/Load Balancer
The High Performance Proxy/Load Balancer

Silverwind-The Next Generation High-Performance Proxy English 简体中文 The Silverwind is a high-performance reverse proxy/load balancer. And it could be a

A high performance http proxy server & extensions platform & net packet capture tool
A high performance http proxy server & extensions platform & net packet capture tool

CthulhuRs A high performance http proxy server A browser extensions platform A net packet capture tool Demonstration Main features of CthulhuRs Inject

Cross-platform, low level networking using the Rust programming language.

libpnet Linux ∪ OS X Build Status: Windows Build Status: Discussion and support: #libpnet on freenode / #rust-networking on irc.mozilla.org / #rust on

BLEZ - Asynchronous Bluetooth Low Energy on Linux for Rust

BLEZ - Asynchronous Bluetooth Low Energy on Linux for Rust This library provides an asynchronous, fully featured interface to the Bluetooth Low Energy

Fast Function Dispatch: Improving the performance of Rust's dynamic function calls

Fast Function Dispatch: Improving the performance of Rust's dynamic function calls A safe, pragmatic toolkit for high-performance virtual function cal

TCP is so widely used, however QUIC may have a better performance.

TCP is so widely used, however QUIC may have a better performance. For softwares which use protocols built on TCP, this program helps them take FULL advantage of QUIC.

An end-to-end encrypted, anonymous IP-hiding, decentralized, audio/video/file sharing/offline messaging multi-device platform built for both communications and application security and performance.

An end-to-end encrypted, anonymous IP-hiding, decentralized, audio/video/file sharing/offline messaging multi-device platform built for both communications and application security and performance.

A high performence Socks5 proxy server with bind/reverse support implementation by Rust.

rsocx A high performence Socks5 proxy server with bind/reverse support implementation by Rust Features Async-std No unsafe code Single executable Linu

The gRPC library for Rust built on C Core library and futures

gRPC-rs gRPC-rs is a Rust wrapper of gRPC Core. gRPC is a high performance, open source universal RPC framework that puts mobile and HTTP/2 first. Sta

Owner
null
Simple in-network file transfer with barely any overhead.

fftp fftp is the "Fast File Transport Protocol". It transfers files quickly between computers on a network with low overhead. Motivation FTP uses two

leo 4 May 12, 2022
A library-first, lightweight, high-performance, cloud-native supported API gateway🪐 by RUST

Preview version, will not guarantee the stability of the API! Do NOT use in production environment! A library-first, lightweight, high-performance, cl

Ideal World 4 May 7, 2023
A high-performance, lightweight, and cross-platform QUIC library

TQUIC English | 中文 TQUIC is a high-performance, lightweight, and cross-platform library for the IETF QUIC protocol. Advantages High performance: TQUIC

Tencent 11 Oct 27, 2023
High performance I/O framework written by Rust inspired by Netty

Introduction Retty is a High performance I/O framework written by Rust inspired by Netty 基于mio的IO多路复用高并发、高性能网络通信开发框架 Feature Rayon 线程池包装 EventLoop / E

lgphp 9 Dec 25, 2022
Volo is a high-performance and strong-extensibility Rust RPC framework that helps developers build microservices.

Volo is a high-performance and strong-extensibility Rust RPC framework that helps developers build microservices.

CloudWeGo 1.3k Jan 2, 2023
High-performance link shortener

shorty High-performance link shortener written in Rust ?? Hosting In addition to being easy to build from source, shorty is available as a Docker imag

Caleb Denio 49 Jan 3, 2023
A high performance TCP SYN port scanner.

Armada A High-Performance TCP SYN scanner What is Armada? Armada is a high performance TCP SYN scanner. This is equivalent to the type of scanning tha

resync 259 Dec 19, 2022
Drpc-Correct, high performance, robust, easy use Remote invocation framework

Drpc - Correct, high performance, robust, easy use Remote invocation framework

darkrpc 30 Dec 17, 2022
Cloud Native high performance security and privacy SQL proxy.

Fern proxy With the advent of Cloud Native applications, architecture patterns evolved and emerged to take advantage of cloud computing, and build mor

Fern 12 Nov 7, 2022
🚀 10x easier, 🚀 10x cheaper, 🚀 high performance, 🚀 petabyte scale - Elasticsearch/Splunk/Datadog alternative for 🚀 (logs, metrics, traces).

?? 10x easier, ?? 10x cheaper, ?? petabyte scale - Elasticsearch/Splunk/Datadog alternative for ?? (logs, metrics, traces). ZincObserve ZincObserve is

Zinc Labs Inc. 80 Feb 22, 2023