-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[receiver/sqlserver] Do not pass metrics details to pkg/winperfcounters
This is refactoring of the sqlserver receiver to make it use pkg/winperfcounters just to retrieve required pert counter values and do not pass metrics details back and forth. They are not needed there. This is one of the steps in bigger refactoring of the interface provided by pkg/winperfcounters.
- Loading branch information
Showing
4 changed files
with
192 additions
and
269 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 0 additions & 64 deletions
64
receiver/sqlserverreceiver/internal/metadata/metrics_builder_ext.go
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
//go:build windows | ||
// +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" | ||
) | ||
|
||
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: "SQLServer:General Statistics", | ||
recorders: map[string]recordFunc{ | ||
"User Connections": func(mb *metadata.MetricsBuilder, ts pcommon.Timestamp, val float64) { | ||
mb.RecordSqlserverUserConnectionCountDataPoint(ts, int64(val)) | ||
}, | ||
}, | ||
}, | ||
{ | ||
object: "SQLServer: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: "SQLServer: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: "SQLServer: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: "SQLServer: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: "SQLServer: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) | ||
}, | ||
}, | ||
}, | ||
} |
Oops, something went wrong.