Giter Club home page Giter Club logo

meters4s's Introduction

Meters4s

Meters4s is a thin, functional wrapper around Micrometer designed to integrate with the Cats ecosystem. This allows for in-process metrics aggregation for counters, timers, gauges and distributions.

Install

Presently this library resides in the kaluza maven artifactory which can be added yo your build.sbt with

resolvers ++= Seq(
  "Artifactory Realm" at "https://kaluza.jfrog.io/artifactory/maven"
)

Add the following depdency to your build.sbt:

libraryDependencies += "com.ovoenergy" %% "meters4s" % "0.4.6"

You will likely also want to add the module corresponding to whichever monitoring system you want to report metrics to. All systems supported by micrometer can be used by brining in the corresponding micormeter dependecy and then using Reporter.fromRegistry to construct a reporter.

For developer convience we also provide a couple of modules for particular monitoring systems, specifically Datadog and StatsD to provide and ergonomic means for creating reporters for these registries. These can be added to your poject as follows:

libraryDependencies += "com.ovoenergy" %% "meters4s-datadog" % "0.4.6"

or

libraryDependencies += "com.ovoenergy" %% "meters4s-statsd" % "0.4.6"

Usage

For comprehensive API documentation check the scaladoc.

A simple usage example for incrementing a counter, backed by a Micrometer SimpleMeterRegistry:

import com.ovoenergy.meters4s.{Reporter, MetricsConfig}
import cats.effect.IO
import scala.concurrent.ExecutionContext.Implicits.global

implicit val cs = IO.contextShift(global)

val config = MetricsConfig()
for {
    reporter <- Reporter.createSimple[IO](config)
    counter  <- reporter.counter("my.counter")
    _        <- counter.increment
} yield ()

With Datadog

import com.ovoenergy.meters4s.{MetricsConfig, Reporter}
import com.ovoenergy.meters4s.datadog.{DataDog, DataDogConfig}
import cats.effect.IO

val datadog = DataDog.createReporter[IO](DataDogConfig(apiKey = "1234"), MetricsConfig())
datadog.use { reporter =>
    reporter.counter("my.counter").flatMap { counter =>
        counter.increment
    }
}

Inspiration

This library was heavily inspired by (and in some places copied wholesale from) http4s-micrometer-metrics.

meters4s's People

Contributors

keirlawson avatar filosganga 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.