Coder Social home page Coder Social logo

mustangjaro / barometer Goto Github PK

View Code? Open in Web Editor NEW

This project forked from workiva/barometer

0.0 0.0 0.0 95 KB

A thin clojure wrapper over Coda Hale's metrics library for the JVM.

License: Other

Makefile 0.51% Clojure 80.45% Dockerfile 1.77% Shell 13.68% Ruby 0.31% CSS 3.29%

barometer's Introduction

Barometer Clojars Project

Overview

This provides a thin wrapper over Coda Hale's metrics library for the JVM. It provides constructors for Registry and all the individual metrics (e.g., Timer, Meter, Gauge, etc.). Several protocols (Statistical, Metered, Counting, etc.) are extended onto the codahale objects to represent semantically-equivalent access patterns to the original interfaces. A constructor is also provided for the codahale ConsoleReporter for debugging and more!

The preservation of common interfaces is the primary difference between barometer and metrics-clojure.

Besides the thin wrapper, barometer.core does not provide much. The primary novelty introduced is a strict requirement that every metric be accompanied by documentation at its construction (although no effort is made to filter out empty strings). The documentation can be printed/examined by calling protocol methods explain/explanation on the metric. This protocol is also extended onto the Registry, which gives an explanation for all metrics registered at that time.

A simple example of creating and registering a metric:

(def my-registry (m/registry "This registry holds all my metrics."))
(def my-timer (m/timer "This timer times my operation."))
(m/register my-registry :my-lib.package.my-timer my-timer)

A simple example of using a timer:

(m/with-timer the-best-timer
   (println "Test"))

API Documentation

Clojure API documentation can be found here.

Notable features

(barometer.core/default-registry)

A default (initially empty) registry available to all consumers of barometer s.t. the single registry could potentially be shared across libraries.

barometer.core/with-timer

Simple convenience macro that times the execution of the body, even if an exception is thrown. Timer must be supplied.

barometer.aspects/timed

Designed to work with morphe, this allows simple generation of timers attached to functions.

(ns my-ns
  (:require [[morphe.core :as m]
             [barometer.aspects :as ma]])

(m/defn ^{::d/aspects [ma/timed]} my-fn
   [x y z]
   ...
   )

This will create a timer and register it under the default barometer registry under the name "my-ns.my-fn.timer", with the explanation "Timer for the function: my-ns/my-fn".

barometer.aspects/concurrency-measured

Also designed to work with morphe, this allows a way to measure the number of simultaneous in-flight calls to a method.

(ns my-ns
  (:require [[morphe.core :as m]
             [barometer.aspects :as ma]])

(m/defn ^{::d/aspects [ma/concurrency-measured]} my-fn
   [x y z]
   ...
   )

This will create a counter and register it under the default barometer registry under the name "my-ns.my-fn.concurrency-counter", with the explanation "Concurrency counter for the function: my-ns/my-fn".

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.