-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This makes use of the windowsperfcounter watchers, using them to collect SQL Server metrics.
- Loading branch information
1 parent
6417070
commit c7fe9fd
Showing
31 changed files
with
4,756 additions
and
0 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
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,13 @@ | ||
function Install-SQLServer2019 { | ||
Write-Host "Downloading SQL Server 2019..." | ||
$Path = $env:TEMP | ||
$Installer = "SQL2019-SSEI-Dev.exe" | ||
$URL = "https://go.microsoft.com/fwlink/?linkid=866662" | ||
Invoke-WebRequest $URL -OutFile $Path\$Installer | ||
|
||
Write-Host "Installing SQL Server..." | ||
Start-Process -FilePath $Path\$Installer -Args "/ACTION=INSTALL /IACCEPTSQLSERVERLICENSETERMS /QUIET" -Verb RunAs -Wait | ||
Remove-Item $Path\$Installer | ||
} | ||
|
||
Install-SQLServer2019 |
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
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
Large diffs are not rendered by default.
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
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
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
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 @@ | ||
include ../../Makefile.Common |
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,26 @@ | ||
# Microsoft SQL Server Receiver | ||
|
||
The `sqlserver` receiver grabs metrics about a Microsoft SQL Server instance using the Windows Performance Counters. | ||
Because of this, it is a Windows only receiver. | ||
|
||
Supported pipeline types: `metrics` | ||
|
||
## Configuration | ||
|
||
The following settings are optional: | ||
|
||
- `collection_interval` (default = `10s`): The internal at which metrics should be emitted by this receiver. | ||
|
||
Example: | ||
|
||
```yaml | ||
receivers: | ||
sqlserver: | ||
collection_interval: 10s | ||
``` | ||
The full list of settings exposed for this receiver are documented [here](./config.go) with detailed sample configurations [here](./testdata/config.yaml). | ||
## Metrics | ||
Details about the metrics produced by this receiver can be found in [documentation.md](./documentation.md) |
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,27 @@ | ||
// Copyright 2020, 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. | ||
|
||
package sqlserverreceiver // import "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/sqlserverreceiver" | ||
|
||
import ( | ||
"go.opentelemetry.io/collector/receiver/scraperhelper" | ||
|
||
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/sqlserverreceiver/internal/metadata" | ||
) | ||
|
||
// Config defines configuration for a sqlserver receiver. | ||
type Config struct { | ||
scraperhelper.ScraperControllerSettings `mapstructure:",squash"` | ||
Metrics metadata.MetricsSettings `mapstructure:"metrics"` | ||
} |
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,51 @@ | ||
// Copyright 2020, 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. | ||
|
||
package sqlserverreceiver | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
|
||
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/sqlserverreceiver/internal/metadata" | ||
) | ||
|
||
func TestValidate(t *testing.T) { | ||
testCases := []struct { | ||
desc string | ||
cfg *Config | ||
}{ | ||
{ | ||
desc: "valid config", | ||
cfg: &Config{ | ||
Metrics: metadata.DefaultMetricsSettings(), | ||
}, | ||
}, { | ||
desc: "valid config with no metric settings", | ||
cfg: &Config{}, | ||
}, | ||
{ | ||
desc: "default config is valid", | ||
cfg: createDefaultConfig().(*Config), | ||
}, | ||
} | ||
|
||
for _, tc := range testCases { | ||
t.Run(tc.desc, func(t *testing.T) { | ||
actualErr := tc.cfg.Validate() | ||
require.NoError(t, actualErr) | ||
}) | ||
} | ||
} |
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,17 @@ | ||
// 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:generate mdatagen --experimental-gen metadata.yaml | ||
|
||
package sqlserverreceiver // import "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/sqlserverreceiver" |
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,51 @@ | ||
[comment]: <> (Code generated by mdatagen. DO NOT EDIT.) | ||
|
||
# sqlserverreceiver | ||
|
||
## Metrics | ||
|
||
These are the metrics available for this scraper. | ||
|
||
| Name | Description | Unit | Type | Attributes | | ||
| ---- | ----------- | ---- | ---- | ---------- | | ||
| **sqlserver.batch.request.rate** | Number of batch requests received by SQL Server. | {requests}/s | Gauge(Double) | <ul> </ul> | | ||
| **sqlserver.batch.sql_compilation.rate** | Number of SQL compilations needed. | {compilations}/s | Gauge(Double) | <ul> </ul> | | ||
| **sqlserver.batch.sql_recompilation.rate** | Number of SQL recompilations needed. | {compilations}/s | Gauge(Double) | <ul> </ul> | | ||
| **sqlserver.lock.wait.rate** | Number of lock requests resulting in a wait. | {requests}/s | Gauge(Double) | <ul> </ul> | | ||
| **sqlserver.lock.wait_time.avg** | Average wait time for all lock requests that had to wait. | ms | Gauge(Double) | <ul> </ul> | | ||
| **sqlserver.page.buffer_cache.hit_ratio** | Pages found in the buffer pool without having to read from disk. | % | Gauge(Double) | <ul> </ul> | | ||
| **sqlserver.page.checkpoint.flush.rate** | Number of pages flushed by operations requiring dirty pages to be flushed. | {pages}/s | Gauge(Double) | <ul> </ul> | | ||
| **sqlserver.page.lazy_write.rate** | Number of lazy writes moving dirty pages to disk. | {writes}/s | Gauge(Double) | <ul> </ul> | | ||
| **sqlserver.page.life_expectancy** | Time a page will stay in the buffer pool. | s | Gauge(Double) | <ul> </ul> | | ||
| **sqlserver.page.operation.rate** | Number of physical database page operations issued. | {operations}/s | Gauge(Double) | <ul> <li>page.operations</li> </ul> | | ||
| **sqlserver.page.split.rate** | Number of pages split as a result of overflowing index pages. | {pages}/s | Gauge(Double) | <ul> </ul> | | ||
| **sqlserver.transaction.rate** | Number of transactions started for the database (not including XTP-only transactions). | {transactions}/s | Gauge(Double) | <ul> </ul> | | ||
| **sqlserver.transaction.write.rate** | Number of transactions that wrote to the database and committed. | {transactions}/s | Gauge(Double) | <ul> </ul> | | ||
| **sqlserver.transaction_log.flush.data.rate** | Total number of log bytes flushed. | By/s | Gauge(Double) | <ul> </ul> | | ||
| **sqlserver.transaction_log.flush.rate** | Number of log flushes. | {flushes}/s | Gauge(Double) | <ul> </ul> | | ||
| **sqlserver.transaction_log.flush.wait.rate** | Number of commits waiting for a transaction log flush. | {commits}/s | Gauge(Double) | <ul> </ul> | | ||
| **sqlserver.transaction_log.growth.count** | Total number of transaction log expansions for a database. | {growths} | Gauge(Double) | <ul> </ul> | | ||
| **sqlserver.transaction_log.shrink.count** | Total number of transaction log shrinks for a database. | {shrinks} | Gauge(Double) | <ul> </ul> | | ||
| **sqlserver.transaction_log.usage** | Percent of transaction log space used. | % | Gauge(Double) | <ul> </ul> | | ||
| **sqlserver.user.connection.count** | Number of users connected to the SQL Server. | {connections} | Gauge(Double) | <ul> </ul> | | ||
|
||
**Highlighted metrics** are emitted by default. Other metrics are optional and not emitted by default. | ||
Any metric can be enabled or disabled with the following scraper configuration: | ||
|
||
```yaml | ||
metrics: | ||
<metric_name>: | ||
enabled: <true|false> | ||
``` | ||
## Resource attributes | ||
| Name | Description | Type | | ||
| ---- | ----------- | ---- | | ||
| sqlserver.database.name | The name of the SQL Server database. | String | | ||
## Metric attributes | ||
| Name | Description | Values | | ||
| ---- | ----------- | ------ | | ||
| page.operations (type) | The page operation types. | read, write | |
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,45 @@ | ||
// Copyright 2020, 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. | ||
|
||
package sqlserverreceiver // import "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/sqlserverreceiver" | ||
|
||
import ( | ||
"time" | ||
|
||
"go.opentelemetry.io/collector/component" | ||
"go.opentelemetry.io/collector/config" | ||
"go.opentelemetry.io/collector/receiver/scraperhelper" | ||
|
||
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/sqlserverreceiver/internal/metadata" | ||
) | ||
|
||
const typeStr = "sqlserver" | ||
|
||
// NewFactory creates a factory for SQL Server receiver. | ||
func NewFactory() component.ReceiverFactory { | ||
return component.NewReceiverFactory( | ||
typeStr, | ||
createDefaultConfig, | ||
component.WithMetricsReceiver(createMetricsReceiver)) | ||
} | ||
|
||
func createDefaultConfig() config.Receiver { | ||
return &Config{ | ||
ScraperControllerSettings: scraperhelper.ScraperControllerSettings{ | ||
ReceiverSettings: config.NewReceiverSettings(config.NewComponentID(typeStr)), | ||
CollectionInterval: 10 * time.Second, | ||
}, | ||
Metrics: metadata.DefaultMetricsSettings(), | ||
} | ||
} |
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,37 @@ | ||
// 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 ( | ||
"context" | ||
"errors" | ||
|
||
"go.opentelemetry.io/collector/component" | ||
"go.opentelemetry.io/collector/config" | ||
"go.opentelemetry.io/collector/consumer" | ||
) | ||
|
||
// createMetricsReceiver creates a metrics receiver based on provided config. | ||
func createMetricsReceiver( | ||
ctx context.Context, | ||
params component.ReceiverCreateSettings, | ||
cfg config.Receiver, | ||
consumer consumer.Metrics, | ||
) (component.MetricsReceiver, error) { | ||
return nil, errors.New("the sqlserver receiver is only supported on Windows") | ||
} |
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,36 @@ | ||
// 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 ( | ||
"context" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
"go.opentelemetry.io/collector/component/componenttest" | ||
"go.opentelemetry.io/collector/consumer/consumertest" | ||
) | ||
|
||
func TestCreateMetricsReceiver(t *testing.T) { | ||
factory := NewFactory() | ||
cfg := factory.CreateDefaultConfig() | ||
mReceiver, err := factory.CreateMetricsReceiver(context.Background(), componenttest.NewNopReceiverCreateSettings(), cfg, consumertest.NewNop()) | ||
|
||
assert.EqualError(t, err, "the sqlserver receiver is only supported on Windows") | ||
assert.Nil(t, mReceiver) | ||
} |
Oops, something went wrong.