Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type MemoryStatistics ¶
type MemoryStatistics struct { sync.Mutex // Alloc is bytes of allocated heap objects. Alloc uint64 `json:"alloc"` // TotalAlloc is cumulative bytes allocated for heap objects. TotalAlloc uint64 `json:"totalAlloc"` // Sys is the total bytes of memory obtained from the OS. Sys uint64 `json:"sys"` // Lookups is the number of pointer lookups performed by the // runtime. Lookups uint64 `json:"lookups"` // Mallocs is the cumulative count of heap objects allocated. // The number of live objects is Mallocs - Frees. Mallocs uint64 `json:"mallocs"` // Frees is the cumulative count of heap objects freed. Frees uint64 `json:"frees"` // HeapAlloc is bytes of allocated heap objects. HeapAlloc uint64 `json:"heapAlloc"` // HeapSys is bytes of heap memory obtained from the OS. HeapSys uint64 `json:"heapSys"` // HeapIdle is bytes in idle (unused) spans. HeapIdle uint64 `json:"heapIdle"` // HeapInuse is bytes in in-use spans. HeapInuse uint64 `json:"heapInuse"` // HeapReleased is bytes of physical memory returned to the OS. HeapReleased uint64 `json:"heapReleased"` // HeapObjects is the number of allocated heap objects. HeapObjects uint64 `json:"heapObjects"` // NumGC is the number of completed GC cycles. NumGC uint32 `json:"numGC"` }
MemoryStatistics is a JSON-able version of runtime.MemStats
func (*MemoryStatistics) ToMap ¶
func (ms *MemoryStatistics) ToMap() map[string]interface{}
ToMap converts to a map[string]interface{}.
func (*MemoryStatistics) Update ¶
func (ms *MemoryStatistics) Update()
Update takes the most recent stats from runtime.
type MetricsManager ¶
type MetricsManager struct { sync.RWMutex Segment analytics.Client `json:"-"` Logger logrus.FieldLogger `json:"-"` ID string `json:"id"` UpTime int64 `json:"uptime"` MemoryStatistics *MemoryStatistics `json:"memory"` BuildVersion string `json:"buildVersion"` BuildHash string `json:"buildHash"` BuildTime string `json:"buildTime"` InstanceID string `json:"instanceId"` ServiceName string `json:"serviceName"` // contains filtered or unexported fields }
MetricsManager helps with providing context on metrics.
func NewMetricsManager ¶
func NewMetricsManager( id string, enable bool, writeKey string, whitelistedURLs []string, logger logrus.FieldLogger, serviceName string, sampling float64, endpoint string, ) *MetricsManager
NewMetricsManager returns a new metrics manager.
func NewMetricsManagerWithConfig ¶
func NewMetricsManagerWithConfig( id string, enable bool, writeKey string, whitelistedURLs []string, logger logrus.FieldLogger, serviceName string, sampling float64, config analytics.Config, ) *MetricsManager
NewMetricsManagerWithConfig returns a new metrics manager and allows configuration.
func (*MetricsManager) CommitMemoryStatistics ¶
func (sw *MetricsManager) CommitMemoryStatistics()
CommitMemoryStatistics commits memory statistics to segment.
func (*MetricsManager) RegisterSegment ¶
func (sw *MetricsManager) RegisterSegment(version, hash, buildTime string)
RegisterSegment enables reporting to segment.
func (*MetricsManager) ServeHTTP ¶
func (sw *MetricsManager) ServeHTTP(rw http.ResponseWriter, r *http.Request, next http.HandlerFunc)
ServeHTTP is a middleware for sending meta information to segment.
Click to show internal directories.
Click to hide internal directories.