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
Size: 6515
Language: Go
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
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.
et github.com/rcrowley/go-metrics
et github.com/pivotal-cf/go-metrics-pcf
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.
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)
// ...
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)
})
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