collector

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2023 License: MIT Imports: 7 Imported by: 3

Documentation

Index

Examples

Constants

View Source
const (
	PERF_COUNTER_RAWCOUNT_HEX           = 0x00000000
	PERF_COUNTER_LARGE_RAWCOUNT_HEX     = 0x00000100
	PERF_COUNTER_TEXT                   = 0x00000b00
	PERF_COUNTER_RAWCOUNT               = 0x00010000
	PERF_COUNTER_LARGE_RAWCOUNT         = 0x00010100
	PERF_DOUBLE_RAW                     = 0x00012000
	PERF_COUNTER_DELTA                  = 0x00400400
	PERF_COUNTER_LARGE_DELTA            = 0x00400500
	PERF_SAMPLE_COUNTER                 = 0x00410400
	PERF_COUNTER_QUEUELEN_TYPE          = 0x00450400
	PERF_COUNTER_LARGE_QUEUELEN_TYPE    = 0x00450500
	PERF_COUNTER_100NS_QUEUELEN_TYPE    = 0x00550500
	PERF_COUNTER_OBJ_TIME_QUEUELEN_TYPE = 0x00650500
	PERF_COUNTER_COUNTER                = 0x10410400
	PERF_COUNTER_BULK_COUNT             = 0x10410500
	PERF_RAW_FRACTION                   = 0x20020400
	PERF_LARGE_RAW_FRACTION             = 0x20020500
	PERF_COUNTER_TIMER                  = 0x20410500
	PERF_PRECISION_SYSTEM_TIMER         = 0x20470500
	PERF_100NSEC_TIMER                  = 0x20510500
	PERF_PRECISION_100NS_TIMER          = 0x20570500
	PERF_OBJ_TIME_TIMER                 = 0x20610500
	PERF_PRECISION_OBJECT_TIMER         = 0x20670500
	PERF_SAMPLE_FRACTION                = 0x20c20400
	PERF_COUNTER_TIMER_INV              = 0x21410500
	PERF_100NSEC_TIMER_INV              = 0x21510500
	PERF_COUNTER_MULTI_TIMER            = 0x22410500
	PERF_100NSEC_MULTI_TIMER            = 0x22510500
	PERF_COUNTER_MULTI_TIMER_INV        = 0x23410500
	PERF_100NSEC_MULTI_TIMER_INV        = 0x23510500
	PERF_AVERAGE_TIMER                  = 0x30020400
	PERF_ELAPSED_TIME                   = 0x30240500
	PERF_COUNTER_NODATA                 = 0x40000200
	PERF_AVERAGE_BULK                   = 0x40020500
	PERF_SAMPLE_BASE                    = 0x40030401
	PERF_AVERAGE_BASE                   = 0x40030402
	PERF_RAW_BASE                       = 0x40030403
	PERF_PRECISION_TIMESTAMP            = 0x40030500
	PERF_LARGE_RAW_BASE                 = 0x40030503
	PERF_COUNTER_MULTI_BASE             = 0x42030500
	PERF_COUNTER_HISTOGRAM_TYPE         = 0x80000000
)
View Source
const (
	Namespace = "perflib"
)

...

Variables

This section is empty.

Functions

func GetPrometheusValueType

func GetPrometheusValueType(counterType uint32) (prometheus.ValueType, error)

func HasMergedLabels

func HasMergedLabels(index uint) bool

Return if a given object has merge definitions

func HasPromotedLabels

func HasPromotedLabels(index uint) bool

Return if a given object has label promotion definitions

func IsBaseValue

func IsBaseValue(counterType uint32) bool

func IsCounter

func IsCounter(counterType uint32) bool

func IsDefPromotedLabel

func IsDefPromotedLabel(objIndex uint, def uint) bool

Return if a given definition is a promoted label for an object

func IsElapsedTime

func IsElapsedTime(counterType uint32) bool

func MakePrometheusLabel

func MakePrometheusLabel(def *perflib.PerfCounterDef) (s string)
Example
objects, err := perflib.QueryPerformanceData("Global")

if err != nil {
	panic(err)
}

testIndices := []uint{
	10,   // File Read Operations/sec
	44,   // Processor Queue Length
	1350, // % Registry Quota In Use
	1676, // Free & Zero Page List Bytes
	94,   // Data Map Hits %
	228,  // Avg. Disk Bytes/Write
	388,  // Bytes Total/sec
	1260, // Logon Total
	1262, // Total Durable Handles
	4412, // Total Failed Persistent Handle Reopen Count
	4552, // Response Time -- Minimum
	4622, // # of resumed workflow jobs/sec
	206,  // Avg. Disk sec/Transfer
}

sort.Slice(testIndices, func(i, j int) bool {
	return testIndices[i] < testIndices[j]
})

names := make(map[uint]string)

for _, o := range objects {
	for _, d := range o.CounterDefs {
		for _, n := range testIndices {
			if d.NameIndex == n {
				names[n] = MakePrometheusLabel(d)
			}
		}
	}
}

for _, n := range testIndices {
	fmt.Printf("%d %s\n", n, names[n])
}

/* Output:
   10 file_read_operations_total
   44 processor_queue_length
   94 data_map_hits_total
   206 avg_disk_sec_per_transfer_total
   228 avg_disk_bytes_per_write_total
   388 bytes_total
   1260 logon
   1262 durable_handles
   1350 registry_quota_in_use_total
   1676 free_and_zero_page_list_bytes
   4412 failed_persistent_handle_reopen_count
   4552 response_time_minimum
   4622 resumed_workflow_jobs_total
*/
Output:

10 file_read_operations_total
44 processor_queue_length
94 data_map_hits_total
206 avg_disk_sec_per_transfer_total
228 avg_disk_bytes_per_write_total
388 bytes_total
1260 logon
1262 durable_handles
1350 registry_quota_in_use_total
1676 free_and_zero_page_list_bytes
4412 failed_persistent_handle_reopen_count
4552 response_time_minimum
4622 resumed_workflow_jobs_total

func MergedLabelsForInstance

func MergedLabelsForInstance(objIndex uint, def uint) (name string, labelName string)

Return a list of merged label names for an instance

Example
fmt.Println(MergedLabelsForInstance(230, 142))
Output:

processor_time_total mode

func MergedMetricForInstance

func MergedMetricForInstance(objIndex uint, def uint) (name string, label string)

Return merged metric name and label value for an instance

Example
fmt.Println(MergedMetricForInstance(230, 142))
Output:

processor_time_total user

func PromotedLabelValuesForInstance

func PromotedLabelValuesForInstance(index uint, instance *perflib.PerfInstance) []string

Get a list of label values for a given object and instance

Example
// Process
objects, err := perflib.QueryPerformanceData("230")

if err != nil {
	panic(err)
}

// First instance is "Idle"
instance := objects[0].Instances[0]
fmt.Println(instance.Name)

values := PromotedLabelValuesForInstance(230, instance)

fmt.Println(values)
Output:

Idle
[0 0]

func PromotedLabelsForObject

func PromotedLabelsForObject(index uint) []string

Get a list of promoted labels for an object

Types

type Collector

type Collector interface {
	// Get new metrics and expose them via prometheus registry.
	Collect(ch chan<- prometheus.Metric) (err error)
}

Collector is the interface a collector has to implement.

type CounterKey

type CounterKey struct {
	ObjectIndex  uint
	CounterIndex uint
	CounterType  uint32 // This is a bit mask
}

func NewCounterKey

func NewCounterKey(object *perflib.PerfObject, def *perflib.PerfCounterDef) CounterKey

type PerflibCollector

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

func NewPerflibCollector

func NewPerflibCollector(l log.Logger, query string) (c PerflibCollector)

func (PerflibCollector) Collect

func (c PerflibCollector) Collect(ch chan<- prometheus.Metric) (err error)

Jump to

Keyboard shortcuts

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