Documentation ¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type GoMetrics ¶
type GoMetrics struct { Dimensions []*cloudwatch.Dimension Namespace string OnError func(error) CollectTotalAlloc bool CollectSys bool CollectLookups bool CollectMallocs bool CollectFrees bool CollectHeapAlloc bool CollectHeapSys bool CollectHeapIdle bool CollectHeapInuse bool CollectHeapReleased bool CollectHeapObjects bool CollectStackInuse bool CollectStackSys bool CollectMSpanInuse bool CollectMSpanSys bool CollectMCacheInuse bool CollectMCacheSys bool CollectBuckHashSys bool CollectGCSys bool CollectNextGC bool CollectLastGC bool CollectPauseTotalNs bool CollectNumGC bool CollectNumForcedGC bool CollectGCCPUFraction bool CollectNumGoroutine bool // contains filtered or unexported fields }
func New ¶
func New(cfg client.ConfigProvider) *GoMetrics
New creates collector of go metrics. Upon creation enable required metrics by toggling appropriate GoMetrics.Collect* fields.
Example ¶
package main import ( "context" "time" "github.com/aws/aws-sdk-go/aws/session" "github.com/molecule-man/cwatsch/gometrics" ) func main() { ctx, cancel := context.WithCancel(context.Background()) defer cancel() go func() { m := gometrics.New(session.Must(session.NewSession())) m.Namespace = "MyApp" m.CollectHeapAlloc = true m.CollectNextGC = true // target heap size of the next GC cycle m.CollectStackInuse = true // bytes in stack spans. m.CollectPauseTotalNs = true // cumulative nanoseconds in GC stop-the-world pauses since the program started. m.CollectNumGC = true // number of completed GC cycles. m.CollectHeapObjects = true // number of allocated heap objects. m.CollectNumGoroutine = true // the metrics will be collected every minute m.Launch(ctx, time.Minute) }() }
Output:
Click to show internal directories.
Click to hide internal directories.