Documentation ¶
Overview ¶
package newrelic is an client for NewRelic's plugin API.
Simple usage:
import ( "runtime" "time" "github.com/neocortical/newrelic" ) func main() { client := newrelic.New("abc123") // license key goes here myplugin := &Plugin{ Name: "My Plugin", GUID: "com.example.newrelic.myplugin", } client.AddPlugin(myplugin) // the easiest way to add a metric is to use a closure metric := newrelic.NewMetric("MyApp/Total CGO Calls", func() (float64, error) { return float64(runtime.NumCgoCall()), nil }) plugin.AddMetric() // call run after doing all plugin config client.Run() // main application code here.. for { time.Sleep(time.Minute) } }
Index ¶
Constants ¶
View Source
const ( // DefaultPollInterval is the recommended poll interval for NewRelic plugins DefaultPollInterval = time.Minute )
Variables ¶
View Source
var LogLevel = LogError
LogLevel can be set globally to tune logging levels
Logger is the logger used by this package. Set to a custom logger if needed.
Functions ¶
func Log ¶
func Log(level LoggingLevel, format string, a ...interface{})
Log a message through the newrelic package
Types ¶
type Client ¶
type Client struct { License string PollInterval time.Duration Plugins []*Plugin // HTTPClient is exposed to allow users to configure proxies, etc. HTTPClient *http.Client // contains filtered or unexported fields }
Client encapsulates a NewRelic plugin client and all the plugins it reports
type CompositeError ¶
type CompositeError []error
CompositeError accumulates errors from calling metric.Poll(). These errors are logged but otherwise ignored so that functioning metrics may still be collected.
func (CompositeError) Accumulate ¶
func (ce CompositeError) Accumulate(err error) CompositeError
Accumulate errors into a single CompositeError
func (CompositeError) Error ¶
func (ce CompositeError) Error() string
Error implements the error interface.
type LoggingLevel ¶
type LoggingLevel int
LoggingLevel enumerates package log levels
const ( // LogAll logs verbosely LogAll LoggingLevel = 0 // LogDebug logs debug or above LogDebug LoggingLevel = 20 // LogInfo logs informational or above LogInfo LoggingLevel = 30 // LogError only logs errors LogError LoggingLevel = 50 // LogNone makes the package silent LogNone LoggingLevel = 100 )
Click to show internal directories.
Click to hide internal directories.