gorelic – github.com/yvasiyarov/gorelic Index | Files | Directories

package gorelic

import "github.com/yvasiyarov/gorelic"

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

Index

Constants

const (
	// DefaultNewRelicPollInterval - how often we will report metrics to NewRelic.
	// Recommended values is 60 seconds
	DefaultNewRelicPollInterval = 60

	// DefaultGcPollIntervalInSeconds - how often we will get garbage collector run statistic
	// Default value is - every 10 seconds
	// During GC stat pooling - mheap will be locked, so be carefull changing this value
	DefaultGcPollIntervalInSeconds = 10

	// DefaultMemoryAllocatorPollIntervalInSeconds - how often we will get memory allocator statistic.
	// Default value is - every 60 seconds
	// During this process stoptheword() is called, so be carefull changing this value
	DefaultMemoryAllocatorPollIntervalInSeconds = 60

	//DefaultAgentGuid is plugin ID in NewRelic.
	//You should not change it unless you want to create your own plugin.
	DefaultAgentGuid = "com.github.yvasiyarov.GoRelic"

	//CurrentAgentVersion is plugin version
	CurrentAgentVersion = "0.0.6"

	//DefaultAgentName in NewRelic GUI. You can change it.
	DefaultAgentName = "Go daemon"
)

Types

type Agent

type Agent struct {
	NewrelicName                string
	NewrelicLicense             string
	NewrelicPollInterval        int
	Verbose                     bool
	CollectGcStat               bool
	CollectMemoryStat           bool
	CollectHTTPStat             bool
	CollectHTTPStatuses         bool
	GCPollInterval              int
	MemoryAllocatorPollInterval int
	AgentGUID                   string
	AgentVersion                string

	HTTPTimer          metrics.Timer
	HTTPStatusCounters map[int]metrics.Counter
	Tracer             *Tracer
	CustomMetrics      []newrelic_platform_go.IMetrica

	// All HTTP requests will be done using this client. Change it if you need
	// to use a proxy.
	Client http.Client
	// contains filtered or unexported fields
}

Agent - is NewRelic agent implementation. Agent start separate go routine which will report data to NewRelic

func NewAgent

func NewAgent() *Agent

NewAgent builds new Agent objects.

func (*Agent) AddCustomMetric

func (agent *Agent) AddCustomMetric(metric newrelic_platform_go.IMetrica)

AddCustomMetric adds metric to be collected periodically with NewrelicPollInterval interval

func (*Agent) Run

func (agent *Agent) Run() error

Run initialize Agent instance and start harvest go routine

func (*Agent) WrapHTTPHandler

func (agent *Agent) WrapHTTPHandler(h http.Handler) http.Handler

WrapHTTPHandler instrument HTTP handler object to collect HTTP metrics

func (*Agent) WrapHTTPHandlerFunc

func (agent *Agent) WrapHTTPHandlerFunc(h tHTTPHandlerFunc) tHTTPHandlerFunc

WrapHTTPHandlerFunc instrument HTTP handler functions to collect HTTP metrics

type Trace

type Trace struct {
	// contains filtered or unexported fields
}

func (*Trace) EndTrace

func (t *Trace) EndTrace()

type TraceTransaction

type TraceTransaction struct {
	// contains filtered or unexported fields
}

type Tracer

type Tracer struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func (*Tracer) BeginTrace

func (t *Tracer) BeginTrace(name string) *Trace

func (*Tracer) Trace

func (t *Tracer) Trace(name string, traceFunc func())

Source Files

agent.go doc.go gc_metrics.go gometrica.go http_metrics.go http_status_metrics.go memory_metrics.go runtime_metrics.go timer_metrics.go tracer_metrics.go

Directories

PathSynopsis
examples
Version
v0.0.7 (latest)
Published
Jun 25, 2019
Platform
js/wasm
Imports
13 packages
Last checked
1 month ago

Tools for package owners.