kikinteractive/gorelic

Name: gorelic

Owner: Kik Interactive

Description: New Relic agent for Go lang

Created: 2015-05-13 09:07:01.0

Updated: 2017-05-21 17:19:46.0

Pushed: 2015-07-23 13:39:11.0

Homepage: null

Size: 179

Language: Go

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

GoRelic

New Relic agent for Go runtime. It collect a lot of metrics about scheduler, garbage collector and memory allocator and send them to NewRelic.

Requirements

You have to install manually only first two dependencies. All other dependencies will be installed automatically by Go toolchain.

Installation
et github.com/yvasiyarov/gorelic

and add to the initialization part of your application following code:

rt (
"github.com/yvasiyarov/gorelic"



t := gorelic.NewAgent()
t.Verbose = true
t.NewrelicLicense = "YOUR NEWRELIC LICENSE KEY THERE"
t.Run()
Middleware

If you using Beego, Martini, Revel or Gin framework you can hook up gorelic with your application by using the following middleware:

Configuration
Metrics reported by plugin

This agent use functions exposed by runtime or runtime/debug packages to collect most important information about Go runtime.

General metrics
Garbage collector metrics

All this metrics are measured in nanoseconds. Last 4 of them can be inaccurate if GC called more often then once in GCPollInterval. If in your workload GC is called more often - you can consider decreasing value of GCPollInterval. But be carefull, ReadGCStats() blocks mheap, so its not good idea to set GCPollInterval to very low values.

Memory allocator
Process metrics

All this metrics collected once in MemoryAllocatorPollInterval. In order to collect this statistic agent use ReadMemStats() routine. This routine calls stoptheworld() internally and it block everything. So, please, consider this when you change MemoryAllocatorPollInterval value.

HTTP metrics

In order to collect HTTP metrics, handler functions must be wrapped using WrapHTTPHandlerFunc:

.HandleFunc("/", agent.WrapHTTPHandlerFunc(handler))
Tracing Metrics

You can collect metrics for blocks of code or methods.

 anyMethod() {
 Trace the whole method.
:= agent.Tracer.BeginTrace("My traced method")
fer t.EndTrace()

.Code here

 Trace a block of code
ent.Tracer.Trace("block trace", func() {
 .. Code here


TODO

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.