forked from open-telemetry/opentelemetry-collector-contrib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
recorders.go
125 lines (117 loc) · 4.76 KB
/
recorders.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
//go:build windows
package sqlserverreceiver // import "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/sqlserverreceiver"
import (
"go.opentelemetry.io/collector/pdata/pcommon"
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/sqlserverreceiver/internal/metadata"
)
const (
// defaultObjectName is the default object name to query for metrics.
defaultObjectName = "SQLServer"
)
type recordFunc = func(*metadata.MetricsBuilder, pcommon.Timestamp, float64)
type perfCounterRecorderConf struct {
object string
instance string
recorders map[string]recordFunc
}
// perfCounterRecorders is map of perf counter object -> perf counter name -> value recorder.
var perfCounterRecorders = []perfCounterRecorderConf{
{
object: "General Statistics",
recorders: map[string]recordFunc{
"User Connections": func(mb *metadata.MetricsBuilder, ts pcommon.Timestamp, val float64) {
mb.RecordSqlserverUserConnectionCountDataPoint(ts, int64(val))
},
},
},
{
object: "SQL Statistics",
recorders: map[string]recordFunc{
"Batch Requests/sec": func(mb *metadata.MetricsBuilder, ts pcommon.Timestamp, val float64) {
mb.RecordSqlserverBatchRequestRateDataPoint(ts, val)
},
"SQL Compilations/sec": func(mb *metadata.MetricsBuilder, ts pcommon.Timestamp, val float64) {
mb.RecordSqlserverBatchSQLCompilationRateDataPoint(ts, val)
},
"SQL Re-Compilations/sec": func(mb *metadata.MetricsBuilder, ts pcommon.Timestamp, val float64) {
mb.RecordSqlserverBatchSQLRecompilationRateDataPoint(ts, val)
},
},
},
{
object: "Locks",
instance: "_Total",
recorders: map[string]recordFunc{
"Lock Waits/sec": func(mb *metadata.MetricsBuilder, ts pcommon.Timestamp, val float64) {
mb.RecordSqlserverLockWaitRateDataPoint(ts, val)
},
"Average Wait Time (ms)": func(mb *metadata.MetricsBuilder, ts pcommon.Timestamp, val float64) {
mb.RecordSqlserverLockWaitTimeAvgDataPoint(ts, val)
},
},
},
{
object: "Buffer Manager",
recorders: map[string]recordFunc{
"Buffer cache hit ratio": func(mb *metadata.MetricsBuilder, ts pcommon.Timestamp, val float64) {
mb.RecordSqlserverPageBufferCacheHitRatioDataPoint(ts, val)
},
"Checkpoint pages/sec": func(mb *metadata.MetricsBuilder, ts pcommon.Timestamp, val float64) {
mb.RecordSqlserverPageCheckpointFlushRateDataPoint(ts, val)
},
"Lazy writes/sec": func(mb *metadata.MetricsBuilder, ts pcommon.Timestamp, val float64) {
mb.RecordSqlserverPageLazyWriteRateDataPoint(ts, val)
},
"Page life expectancy": func(mb *metadata.MetricsBuilder, ts pcommon.Timestamp, val float64) {
mb.RecordSqlserverPageLifeExpectancyDataPoint(ts, int64(val))
},
"Page reads/sec": func(mb *metadata.MetricsBuilder, ts pcommon.Timestamp, val float64) {
mb.RecordSqlserverPageOperationRateDataPoint(ts, val, metadata.AttributePageOperationsRead)
},
"Page writes/sec": func(mb *metadata.MetricsBuilder, ts pcommon.Timestamp, val float64) {
mb.RecordSqlserverPageOperationRateDataPoint(ts, val, metadata.AttributePageOperationsWrite)
},
},
},
{
object: "Access Methods",
instance: "_Total",
recorders: map[string]recordFunc{
"Page Splits/sec": func(mb *metadata.MetricsBuilder, ts pcommon.Timestamp, val float64) {
mb.RecordSqlserverPageSplitRateDataPoint(ts, val)
},
},
},
{
object: "Databases",
instance: "*",
recorders: map[string]recordFunc{
"Log Bytes Flushed/sec": func(mb *metadata.MetricsBuilder, ts pcommon.Timestamp, val float64) {
mb.RecordSqlserverTransactionLogFlushDataRateDataPoint(ts, val)
},
"Log Flushes/sec": func(mb *metadata.MetricsBuilder, ts pcommon.Timestamp, val float64) {
mb.RecordSqlserverTransactionLogFlushRateDataPoint(ts, val)
},
"Log Flush Waits/sec": func(mb *metadata.MetricsBuilder, ts pcommon.Timestamp, val float64) {
mb.RecordSqlserverTransactionLogFlushWaitRateDataPoint(ts, val)
},
"Log Growths": func(mb *metadata.MetricsBuilder, ts pcommon.Timestamp, val float64) {
mb.RecordSqlserverTransactionLogGrowthCountDataPoint(ts, int64(val))
},
"Log Shrinks": func(mb *metadata.MetricsBuilder, ts pcommon.Timestamp, val float64) {
mb.RecordSqlserverTransactionLogShrinkCountDataPoint(ts, int64(val))
},
"Percent Log Used": func(mb *metadata.MetricsBuilder, ts pcommon.Timestamp, val float64) {
mb.RecordSqlserverTransactionLogUsageDataPoint(ts, int64(val))
},
"Transactions/sec": func(mb *metadata.MetricsBuilder, ts pcommon.Timestamp, val float64) {
mb.RecordSqlserverTransactionRateDataPoint(ts, val)
},
"Write Transactions/sec": func(mb *metadata.MetricsBuilder, ts pcommon.Timestamp, val float64) {
mb.RecordSqlserverTransactionWriteRateDataPoint(ts, val)
},
},
},
}