Git Product home page Git Product logo

finagle-metrics's Introduction

Build Status

finagle-metrics

Easy way to send Finagle metrics to Codahale Metrics library.

Overview

finagle-metrics enables your finagle based application to send its metrics to Codahale Metrics library instead of the default metrics (finagle-stats).

Build

$ git clone https://github.com/rlazoti/finagle-metrics.git
$ cd finagle-metrics
$ sbt package

Test

$ sbt test

Setup

To install it locally, run:

Last Release

$ git checkout tags/version-0.0.1 -b version-0.0.1
$ sbt publish-local

And add the sbt dependency as:

"com.github.rlazoti" %% "finagle-metrics" % "0.0.1"

or

"com.github.rlazoti" % "finagle-metrics_2.11" % "0.0.1"

Usage

Using twitter-server

If you're using twitter-server to create your finagle services, everything you need to do is just adding the finagle-metrics jar to your project.

You don't need to add the finagle-stats to your project, but both libraries will work together without any issue if you need it.

Including your own metrics

You can include your own metrics through the statsReceiver field of TwitterServer, so your metrics will be sent to Codahale Metrics as well.

Including your own metrics through Codahale Metrics

You can obtain an instance of MetricRegistry class through the field metrics of MetricsStatsReceiver.

import com.twitter.finagle.metrics.MetricsStatsReceiver

val myCustomMeter = MetricsStatsReceiver.metrics.meter("my-custom-meter")
myCustomMeter.mark()

Reporting

Codahale Metrics library has reporters for many diferent outputs.

Let's take the GraphiteReporter as example.

import com.codahale.metrics.graphite.{Graphite, GraphiteReporter}
import com.twitter.finagle.metrics.MetricsStatsReceiver
import java.util.concurrent.TimeUnit;

val graphite = new Graphite(new InetSocketAddress("graphite.example.com", 2003));
val reporter = GraphiteReporter.forRegistry(MetricsStatsReceiver.metrics)
                               .prefixedWith("finagle-service.example.com")
                               .convertRatesTo(TimeUnit.SECONDS)
                               .convertDurationsTo(TimeUnit.MILLISECONDS)
                               .build(graphite)

reporter.start(1, TimeUnit.MINUTES)

finagle-metrics's People

Contributors

rlazoti avatar

Watchers

 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.