• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

examples/H12-Dec-2014-11794

.gitignoreH A D12-Dec-201451 54

.travis.ymlH A D12-Dec-201413 21

LICENSEH A D12-Dec-20141.3 KiB2521

README.mdH A D12-Dec-20145.8 KiB12096

agent.goH A D12-Dec-20144.3 KiB13896

doc.goH A D12-Dec-2014202 31

gc_metrics.goH A D12-Dec-20141.6 KiB6658

gometrica.goH A D12-Dec-20142.7 KiB10691

http_metrics.goH A D12-Dec-20144.5 KiB195161

memory_metrics.goH A D12-Dec-20142.8 KiB111100

nut.jsonH A D12-Dec-2014264 1615

runtime_metrics.goH A D12-Dec-20144.8 KiB197166

README.md

1# GoRelic
2
3New Relic agent for Go runtime. It collect a lot of metrics about scheduler, garbage collector and memory allocator and
4send them to NewRelic.
5
6### Requirements
7- Go 1.1 or higher
8- github.com/yvasiyarov/gorelic
9- github.com/yvasiyarov/newrelic_platform_go
10- github.com/yvasiyarov/go-metrics
11
12You have to install manually only first two dependencies. All other dependencies will be installed automatically
13by Go toolchain.
14
15### Installation
16```bash
17go get github.com/yvasiyarov/gorelic
18```
19and add to the initialization part of your application following code:
20```go
21import (
22    "github.com/yvasiyarov/gorelic"
23)
24....
25
26agent := gorelic.NewAgent()
27agent.Verbose = true
28agent.NewrelicLicense = "YOUR NEWRELIC LICENSE KEY THERE"
29agent.Run()
30
31```
32
33### Middleware
34If you using Beego, Martini, Revel or Gin framework you can hook up gorelic with your application by using the following middleware:
35- https://github.com/yvasiyarov/beego_gorelic
36- https://github.com/yvasiyarov/martini_gorelic
37- https://github.com/yvasiyarov/gocraft_gorelic
38- http://wiki.colar.net/revel_newelic
39- https://github.com/jingweno/negroni-gorelic
40- https://github.com/brandfolder/gin-gorelic
41
42
43### Configuration
44- NewrelicLicense - its the only mandatory setting of this agent.
45- NewrelicName - component name in NewRelic dashboard. Default value: "Go daemon"
46- NewrelicPollInterval - how often metrics will be sent to NewRelic. Default value: 60 seconds
47- Verbose - print some usefull for debugging information. Default value: false
48- CollectGcStat - should agent collect garbage collector statistic or not. Default value: true
49- CollectHTTPStat - should agent collect HTTP metrics. Default value: false
50- CollectMemoryStat - should agent collect memory allocator statistic or not. Default value: true
51- GCPollInterval - how often should GC statistic collected. Default value: 10 seconds. It has performance impact. For more information, please, see metrics documentation.
52- MemoryAllocatorPollInterval - how often should memory allocator statistic collected. Default value: 60 seconds. It has performance impact. For more information, please, read metrics documentation.
53
54
55## Metrics reported by plugin
56This agent use functions exposed by runtime or runtime/debug packages to collect most important information about Go runtime.
57
58### General metrics
59- Runtime/General/NOGoroutines - number of runned go routines, as it reported by NumGoroutine() from runtime package
60- Runtime/General/NOCgoCalls - number of runned cgo calls, as it reported by NumCgoCall() from runtime package
61
62### Garbage collector metrics
63- Runtime/GC/NumberOfGCCalls - Nuber of GC calls, as it reported by ReadGCStats() from runtime/debug
64- Runtime/GC/PauseTotalTime - Total pause time diring GC calls, as it reported by ReadGCStats() from runtime/debug (in nanoseconds)
65- Runtime/GC/GCTime/Max - max GC time
66- Runtime/GC/GCTime/Min - min GC time
67- Runtime/GC/GCTime/Mean - GC mean time
68- Runtime/GC/GCTime/Percentile95 - 95% percentile of GC time
69
70All this metrics are measured in nanoseconds. Last 4 of them can be inaccurate if GC called more often then once in GCPollInterval.
71If in your workload GC is called more often - you can consider decreasing value of GCPollInterval.
72But be carefull, ReadGCStats() blocks mheap, so its not good idea to set GCPollInterval to very low values.
73
74### Memory allocator
75- Component/Runtime/Memory/SysMem/Total - number of bytes/minute allocated from OS totally.
76- Component/Runtime/Memory/SysMem/Stack - number of bytes/minute allocated from OS for stacks.
77- Component/Runtime/Memory/SysMem/MSpan - number of bytes/minute allocated from OS for internal MSpan structs.
78- Component/Runtime/Memory/SysMem/MCache - number of bytes/minute allocated from OS for internal MCache structs.
79- Component/Runtime/Memory/SysMem/Heap - number of bytes/minute allocated from OS for heap.
80- Component/Runtime/Memory/SysMem/BuckHash - number of bytes/minute allocated from OS for internal BuckHash structs.
81- Component/Runtime/Memory/Operations/NoFrees - number of memory frees per minute
82- Component/Runtime/Memory/Operations/NoMallocs - number of memory allocations per minute
83- Component/Runtime/Memory/Operations/NoPointerLookups - number of pointer lookups per minute
84- Component/Runtime/Memory/InUse/Total - total amount of memory in use
85- Component/Runtime/Memory/InUse/Heap - amount of memory in use for heap
86- Component/Runtime/Memory/InUse/MCacheInuse - amount of memory in use for MCache internal structures
87- Component/Runtime/Memory/InUse/MSpanInuse - amount of memory in use for MSpan internal structures
88- Component/Runtime/Memory/InUse/Stack - amount of memory in use for stacks
89
90### Process metrics
91- Component/Runtime/System/Threads - number of OS threads used
92- Runtime/System/FDSize - number of file descriptors, used by process
93- Runtime/System/Memory/VmPeakSize - VM max size
94- Runtime/System/Memory/VmCurrent  - VM current size
95- Runtime/System/Memory/RssPeak    - max size of resident memory set
96- Runtime/System/Memory/RssCurrent - current size of resident memory set
97
98All this metrics collected once in MemoryAllocatorPollInterval. In order to collect this statistic agent use ReadMemStats() routine.
99This routine calls stoptheworld() internally and it block everything. So, please, consider this when you change MemoryAllocatorPollInterval value.
100
101### HTTP metrics
102- throughput (requests per second), calculated for last minute
103- mean throughput (requests per second)
104- mean response time
105- min response time
106- max response time
107- 75%, 90%, 95% percentiles for response time
108
109
110In order to collect HTTP metrics, handler functions must be wrapped using WrapHTTPHandlerFunc:
111
112```go
113http.HandleFunc("/", agent.WrapHTTPHandlerFunc(handler))
114```
115
116## TODO
117- Collect per-size allocation statistic
118- Collect user defined metrics
119
120