metricsx

package
v0.0.41 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 5, 2019 License: Apache-2.0 Imports: 18 Imported by: 10

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Hash

func Hash(value string) string

Hash returns a hashed string of the value.

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 Options added in v0.0.38

type Options struct {
	// Service represents the service name, for example "ory-hydra".
	Service string

	// ClusterID represents the cluster id, typically a hash of some unique configuration properties.
	ClusterID string

	// IsDevelopment should be true if we assume that we're in a development environment.
	IsDevelopment bool

	// WriteKey is the segment API key.
	WriteKey string

	// WhitelistedPaths represents a list of paths that can be transmitted in clear text to segment.
	WhitelistedPaths []string

	// BuildVersion represents the build version.
	BuildVersion string

	// BuildHash represents the build git hash.
	BuildHash string

	// BuildTime represents the build time.
	BuildTime string

	// Config overrides the analytics.Config. If nil, sensible defaults will be used.
	Config *analytics.Config

	// MemoryInterval sets how often memory statistics should be transmitted. Defaults to every 12 hours.
	MemoryInterval time.Duration
}

Options configures the metrics service.

type Service added in v0.0.38

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

Service helps with providing context on metrics.

func New added in v0.0.38

func New(
	cmd *cobra.Command,
	l logrus.FieldLogger,
	o *Options,
) *Service

New returns a new metrics service. If one has been instantiated already, no new instance will be created.

func (*Service) Identify added in v0.0.38

func (sw *Service) Identify()

Identify enables reporting to segment.

func (*Service) ObserveMemory added in v0.0.38

func (sw *Service) ObserveMemory()

ObserveMemory commits memory statistics to segment.

func (*Service) ServeHTTP added in v0.0.38

func (sw *Service) ServeHTTP(rw http.ResponseWriter, r *http.Request, next http.HandlerFunc)

ServeHTTP is a middleware for sending meta information to segment.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL