Giter Site home page Giter Site logo

juaby / rust-metrics Goto Github PK

View Code? Open in Web Editor NEW

This project forked from posix4e/rust-metrics

0.0 0.0 0.0 284 KB

Multi reporter metrics library (carbon, graphite, postgresql, prometheus)

License: Apache License 2.0

Shell 0.45% Rust 98.47% Dockerfile 1.07%

rust-metrics's Introduction

This project is stable. New features will be aimed at https://github.com/brayniac/tic. We will only be taking fixes going forward.

rust-metrics

Linux Status Kanban

Metrics are things you can use to safely & directly store metrics with little overhead. Metrics can be attached to a registry and that registry can be collected across a system. This registry also provides reporting services. Current reporters include:

Contact us on #rust-metrics on Mozilla IRC.

...
        let m = StdMeter::new();
        m.mark(

        let c = StdCounter::new();
        c.inc();

        let g = StdGauge::new();
        g.set(2);

        let mut h = Histogram::configure()
            .max_value(100)
            .precision(1)
            .build()
            .unwrap();

        h.increment_by(1, 1).unwrap();

        let mut reporter = CarbonReporter::new("test", "localhost:0".to_string(), "asd.asdf", 5);
        reporter.add("meter1", Metric::Meter(m.clone()));
        reporter.add("counter1", Metric::Counter(c.clone()));
        reporter.add("gauge1", Metric::Gauge(g.clone()));
	// Add a histogram with labels even though they ignored in this reporter
        reporter.addL("histogram", Metric::Histogram(h), Some(HashMap::new()));
        while ... {    c.inc()}
        reporter.stop();

Usage

Add this to your Cargo.toml: push only

metrics =  { version="0.2.0" }

prometheus pull support

metrics =  { version="0.2.0", features=["prometheus"] }

And add this to your crate root:

extern crate metrics

Provided scripts in bin/

  • build_docker This builds the default docker image
  • generate_pb Generates the prometheus protocol buffer code
  • run_docker This will run the docker container once it's been built (or download the last one i pushed)
  • start_docker Use docker_compose to launch prometheus, carbon/graphite and clients which send them data
  • webserver_with_prometheus Starts a webserver which runs with a prometheus reporter
  • start_prometheus_example Use docker-compose to start a prometheus server & hook it up to webserver_with_prometheus
  • webserver_with_carbon Starts a webserver with a carbon reporter
  • start_carbon_example Use docker-compose to start graphite/carbon/whisper and hook it up to webserver_with_carbon

Many of these will only run if prometheus support is enabled

TBD

Local Development

    cargo build # to build the code
    cargo test # to run the tests

To use prometheus you will might need to read these directions

    cargo build --features "prometheus" # To build code with prometheus support

License

rust-metrics is primarily distributed under the terms of both the MIT license and the Apache License (Version 2.0).

See LICENSE-APACHE, LICENSE-MIT for details.

Copyright (c) 2016 Alex Newman.

rust-metrics's People

Contributors

bbangert avatar brayniac avatar carols10cents avatar durch avatar eb4890 avatar jxub avatar kali avatar overvenus avatar pjenvey avatar posix4e avatar sfackler avatar steveklabnik avatar waywardmonkeys avatar whitfin avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.