pivotal-cf/go-metrics-pcf

Name: go-metrics-pcf

Owner: Pivotal Cloud Foundry

Description: A Go library to export Dropwizard style metrics to Metrics Forwarder for PCF. It makes use of rcrowley's go-metrics library.

Created: 2017-04-07 20:25:00.0

Updated: 2017-10-06 15:36:29.0

Pushed: 2018-02-07 18:44:39.0

Homepage:

Size: 6515

Language: Go

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

This is the go-metrics exporter for Pivotal Cloud Foundry (PCF) Metrics.

It is designed to work with the go-metrics library, which is a Go port of Dropwizard metrics.

1. Download and install the Go packages
et github.com/rcrowley/go-metrics
et github.com/pivotal-cf/go-metrics-pcf
2. Import the metrics libraries into your application

Add these import lines to your main.go:

rt (
"time"

// add both of these lines to your application
"github.com/pivotal-cf/go-metrics-pcf"
"github.com/rcrowley/go-metrics"

You'll also want to include the go-metrics import in any other places where you collect metrics.

3. Start the exporter inside your application

This only needs to be called once, so find a convenient place to run this when your application starts.

 main() {
// ... other code here

// start exporting to PCF every minute
go pcfmetrics.StartExporter(metrics.DefaultRegistry)

// ...

4. Add desired instrumentation elsewhere in your code

Remember to import the github.com/rcrowley/go-metrics package everywhere you want to add this instrumentation.

timer := metrics.GetOrRegisterTimer("sample-timer", metrics.DefaultRegistry)

timer.Time(func() {
    time.Sleep(time.Second)
})
5. Create and bind the CF Metrics service to your application

This will bind your application to the metrics service and make sure credentials are available for the metrics API.

 create-service cf-metrics standard my-metrics-service

 bind-service my-app my-metrics-service

 restage my-app

This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.