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 more metrics #32932

Merged

Conversation

crobert-1
Copy link
Member

Description:

This change adds a query, scraper, and some more metrics for data from the performance counter SQL server table. The query itself is mostly taken from Telegraf's SQL server plugin. This also reuses the existing metric sqlserver.lock.wait.rate, so now it will be available both from Windows performance counters, as well as other OSs when directly connecting to the SQL server instance.

Naming and format feedback on new metrics would be greatly appreciated.

Link to tracking Issue:
#29865

Testing:
Added tests for the query itself, as well as the new scraper.

AND pc1.[counter_name] LIKE '%base'
WHERE
pc.[counter_name] NOT LIKE '% base'
{filter_instance_name}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This allows us to filter based on instance name, replacing the {filter_instance_name}. I would have liked to have this indented with the above statement, but this breaks tests directly comparing the contents of two queries when loading the expected query from a file. The file would need to have a blank line with a tab, which my editor automatically deletes, and would look bad on GitHub.

@@ -0,0 +1,165 @@

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Empty newline is due to formatting of query in go.

scrapers := setupSQLServerScrapers(receivertest.NewNopCreateSettings(), cfg)
assert.NotNil(t, scrapers)

for _, scraper := range scrapers {
err := scraper.Start(context.Background(), componenttest.NewNopHost())
assert.NoError(t, err)
defer func() { assert.NoError(t, scraper.Shutdown(context.Background())) }()
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The anonymous func() has to be removed here, as with it, scraper.Shutdown is called twice on the second of two scrapers, and not called on the first scraper. (This is how defer works with anonymous funcs by definition, we just need to use them properly for the updated use case.)

@crobert-1 crobert-1 added Run Windows Enable running windows test on a PR enhancement New feature or request labels May 7, 2024
@crobert-1
Copy link
Member Author

Failing test is frequency of #32715, I've added a reference there.

Copy link
Member

@djaglowski djaglowski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@dmitryax dmitryax merged commit d07e7b9 into open-telemetry:main May 13, 2024
177 of 178 checks passed
@github-actions github-actions bot added this to the next release milestone May 13, 2024
jlg-io pushed a commit to jlg-io/opentelemetry-collector-contrib that referenced this pull request May 14, 2024
**Description:**
This change adds a query, scraper, and some more metrics for data from
the performance counter SQL server table. The query itself is mostly
taken from Telegraf's SQL server plugin. This also reuses the existing
metric `sqlserver.lock.wait.rate`, so now it will be available both from
Windows performance counters, as well as other OSs when directly
connecting to the SQL server instance.

**Naming and format feedback on new metrics would be greatly
appreciated.**

**Link to tracking Issue:** open-telemetry#29865

**Testing:** 
Added tests for the query itself, as well as the new scraper.

Co-authored-by: Daniel Jaglowski <jaglows3@gmail.com>
djaglowski pushed a commit that referenced this pull request May 14, 2024
…etric (#33023)

**Description:** <Describe what has changed.>
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
As a result of
#32932
the metric `sqlserver.lock.wait.rate` is now available on Windows, or
when directly connecting to a SQL server instance. Since this metric is
always available, it no longer needs extended documentation about
availability.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request receiver/sqlserver Run Windows Enable running windows test on a PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants