Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[receiver/sqlserver] Add support for more database IO metrics #32833

Merged
merged 3 commits into from
Jun 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .chloggen/sqlserver_add_io_metrics.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Use this changelog template to create an entry for release notes.

# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: breaking

# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
component: sqlserverreceiver

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: sqlserver.database.io.read_latency has been renamed to sqlserver.database.latency with a `direction` attribute.

# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
issues: [29865]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext:

# If your change doesn't affect end users or the exported elements of any package,
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
# Optional: The change log or logs in which this entry should be included.
# e.g. '[user]' or '[user, api]'
# Include 'user' if the change is relevant to end users.
# Include 'api' if there is a change to a library API.
# Default: '[user]'
change_logs: []
31 changes: 31 additions & 0 deletions .chloggen/sqlserver_io_metrics.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Use this changelog template to create an entry for release notes.

# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: enhancement

# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
component: sqlserverreceiver

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Add support for more Database IO metrics

# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
issues: [29865]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext: |
The following metrics have been added:
- sqlserver.database.latency
- sqlserver.database.io
- sqlserver.database.operations

# If your change doesn't affect end users or the exported elements of any package,
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
# Optional: The change log or logs in which this entry should be included.
# e.g. '[user]' or '[user, api]'
# Include 'user' if the change is relevant to end users.
# Include 'api' if there is a change to a library API.
# Default: '[user]'
change_logs: []
43 changes: 41 additions & 2 deletions receiver/sqlserverreceiver/documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -242,9 +242,28 @@ This metric is only available when the receiver is configured to directly connec
| ---- | ----------- | ------ |
| database.status | The current status of a database | Str: ``online``, ``restoring``, ``recovering``, ``pending_recovery``, ``suspect``, ``offline`` |

### sqlserver.database.io.read_latency
### sqlserver.database.io
crobert-1 marked this conversation as resolved.
Show resolved Hide resolved

Total time that the users waited for reads issued on this file.
The number of bytes of I/O on this file.

This metric is only available when the receiver is configured to directly connect to SQL Server.

| Unit | Metric Type | Value Type | Aggregation Temporality | Monotonic |
| ---- | ----------- | ---------- | ----------------------- | --------- |
| By | Sum | Int | Cumulative | true |

#### Attributes

| Name | Description | Values |
| ---- | ----------- | ------ |
| physical_filename | The physical filename of the file being monitored. | Any Str |
| logical_filename | The logical filename of the file being monitored. | Any Str |
| file_type | The type of file being monitored. | Any Str |
| direction | The direction of flow of bytes or operations. | Str: ``read``, ``write`` |

### sqlserver.database.latency

Total time that the users waited for I/O issued on this file.

This metric is only available when the receiver is configured to directly connect to SQL Server.

Expand All @@ -259,6 +278,26 @@ This metric is only available when the receiver is configured to directly connec
| physical_filename | The physical filename of the file being monitored. | Any Str |
| logical_filename | The logical filename of the file being monitored. | Any Str |
| file_type | The type of file being monitored. | Any Str |
| direction | The direction of flow of bytes or operations. | Str: ``read``, ``write`` |

### sqlserver.database.operations

The number of operations issued on the file.

This metric is only available when the receiver is configured to directly connect to SQL Server.

| Unit | Metric Type | Value Type | Aggregation Temporality | Monotonic |
| ---- | ----------- | ---------- | ----------------------- | --------- |
| {operations} | Sum | Int | Cumulative | true |

#### Attributes

| Name | Description | Values |
| ---- | ----------- | ------ |
| physical_filename | The physical filename of the file being monitored. | Any Str |
| logical_filename | The logical filename of the file being monitored. | Any Str |
| file_type | The type of file being monitored. | Any Str |
| direction | The direction of flow of bytes or operations. | Str: ``read``, ``write`` |

### sqlserver.processes.blocked

Expand Down
11 changes: 10 additions & 1 deletion receiver/sqlserverreceiver/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func createDefaultConfig() component.Config {
func setupQueries(cfg *Config) []string {
var queries []string

if cfg.MetricsBuilderConfig.Metrics.SqlserverDatabaseIoReadLatency.Enabled {
if isDatabaseIOQueryEnabled(&cfg.MetricsBuilderConfig.Metrics) {
queries = append(queries, getSQLServerDatabaseIOQuery(cfg.InstanceName))
}

Expand Down Expand Up @@ -129,3 +129,12 @@ func setupScrapers(params receiver.CreateSettings, cfg *Config) ([]scraperhelper

return opts, nil
}

func isDatabaseIOQueryEnabled(metrics *metadata.MetricsConfig) bool {
if metrics.SqlserverDatabaseLatency.Enabled ||
metrics.SqlserverDatabaseOperations.Enabled ||
metrics.SqlserverDatabaseIo.Enabled {
return true
}
return false
}
2 changes: 1 addition & 1 deletion receiver/sqlserverreceiver/factory_others_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func TestCreateMetricsReceiverOtherOS(t *testing.T) {
cfg.Server = "0.0.0.0"
cfg.Port = 1433
cfg.InstanceName = "instanceName"
cfg.Metrics.SqlserverDatabaseIoReadLatency.Enabled = true
cfg.Metrics.SqlserverDatabaseLatency.Enabled = true
require.NoError(t, cfg.Validate())

require.True(t, directDBConnectionEnabled(cfg))
Expand Down
2 changes: 1 addition & 1 deletion receiver/sqlserverreceiver/factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func TestCreateMetricsReceiver(t *testing.T) {
cfg.Server = "0.0.0.0"
cfg.Port = 1433
require.NoError(t, cfg.Validate())
cfg.Metrics.SqlserverDatabaseIoReadLatency.Enabled = true
cfg.Metrics.SqlserverDatabaseLatency.Enabled = true

require.True(t, directDBConnectionEnabled(cfg))
require.Equal(t, "server=0.0.0.0;user id=sa;password=password;port=1433", getDBConnectionString(cfg))
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading