Code Monkey home page Code Monkey logo

go-metrics-appoptics's Introduction

This is a reporter for the go-metrics library which posts the metrics to AppOptics/Librato. It is forked from go-metrics-librato and was originally part of the go-metrics library itself.

This library supports tagged metrics only; source-based metrics have been deprecated by Librato. The original go-metrics-librato library can be used if you need to upload source-based metrics instead.

Usage

import "github.com/ysamlan/go-metrics-appoptics"

go appoptics.AppOptics(metrics.DefaultRegistry,
    10*time.Second,              // interval for uploads
    "token",                     // AppOptics API token
    map[string]string{
        "hostname": "localhost", // tags
    }, 
    []float64{0.95},             // percentiles to send
    time.Millisecond,            // time units for timers
    "myservicename.",            // prefix on reported metric names
    nil,                         // (optional) go-metrics runtime.* stats upload whitelist
)

Features

Metric Name Prefix: This reporter supports a prefix argument when initializing. All uploaded metrics will have that prefix prepended to their names. Use "" if you don't want this behavior.

Tags: Tags passed during the initialization are attached to all this reporter's measurements to AppOptics.

Selective runtime metric uploading: If you're using go-metrics' CaptureRuntimeMemStats feature, it's great and automates collecting a lot of useful data. Unfortunately, it also adds 30 metrics, which can eat up a lot of metric hours with AppOptics. The runtimeMetricsWhiteleist parameter lets you cherry-pick which metrics actually get uploaded, without needing to manually collect them yourself. See the source for possible values. Pass nil to allow all, and an empty slice to disable uploads for all runtime. metrics.

Limitations

Tags are attached at the batch level, not to the individual metrics/measurements within the batch. You can work around this by using a different Registry and appoptics.AppOptics goroutine for metrics that need different tags. See #1 for potential approaches for fixing this.

Migrating from rcrowley/go-metrics / mihasya/go-metrics-librato implementation

To get the same behavior you're used to from the original Librato reporter (only with tags instead of sources):

  • Change the import to "github.com/ysamlan/go-metrics-appoptics"
  • Change librato.Librato to appoptics.AppOptics
  • Remove the email argument from the appoptics.AppOptics function call (the updated AppOptics API only requires the token)
  • Change the source argument from a string into a map[string]string for tags - e.g. a source "myhostname" could become the tag map[string]string{"host":"myhostname"}).
  • Use "" for the metric name prefix.
  • Use nil for the runtime-metric-name whitelist (allow-all).

go-metrics-appoptics's People

Contributors

benarent avatar cameront avatar mihasya avatar rengawm avatar ysamlan avatar

Watchers

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