Skip to content

[SqlClient] Recognise more keywords#3671

Merged
alanwest merged 2 commits intoopen-telemetry:mainfrom
martincostello:gh-3666
Jan 9, 2026
Merged

[SqlClient] Recognise more keywords#3671
alanwest merged 2 commits intoopen-telemetry:mainfrom
martincostello:gh-3666

Conversation

@martincostello
Copy link
Copy Markdown
Member

@martincostello martincostello commented Jan 8, 2026

Fixes #3666

Changes

Recognise more SQL keywords to improve query summaries.

I used the Transact-SQL statements documentation as a starting point, and went through any keywords not already present that were either a unique new first keyword (e.g. GRANT) or were a unique secondary keyword (e.g. STATISTICS).

I'm open to adding/removing the keywords or tweaking the summaries generated.

Depends on #3660.

Merge requirement checklist

  • CONTRIBUTING guidelines followed (license requirements, nullable enabled, static analysis, etc.)
  • Unit tests added/updated
  • Appropriate CHANGELOG.md files updated for non-trivial changes
  • Changes in public API reviewed (if applicable)

@github-actions github-actions Bot added infra Infra work - CI/CD, code coverage, linters dependencies Pull requests that update a dependency file labels Jan 8, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Jan 8, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 71.62%. Comparing base (224c66b) to head (5864847).
⚠️ Report is 1 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3671      +/-   ##
==========================================
+ Coverage   71.46%   71.62%   +0.16%     
==========================================
  Files         455      455              
  Lines       17654    17700      +46     
==========================================
+ Hits        12616    12678      +62     
+ Misses       5038     5022      -16     
Flag Coverage Δ
unittests-Contrib.Shared.Tests 87.87% <100.00%> (+0.68%) ⬆️
unittests-Exporter.Geneva 54.08% <ø> (+0.32%) ⬆️
unittests-Exporter.InfluxDB 95.14% <ø> (ø)
unittests-Exporter.Instana 74.86% <ø> (ø)
unittests-Exporter.OneCollector 94.62% <ø> (ø)
unittests-Extensions 90.65% <ø> (ø)
unittests-Extensions.Enrichment 100.00% <ø> (ø)
unittests-Extensions.Enrichment.AspNetCore 86.27% <ø> (ø)
unittests-Extensions.Enrichment.Http 94.33% <ø> (ø)
unittests-Instrumentation.AWS 83.42% <ø> (ø)
unittests-Instrumentation.AspNet 77.92% <ø> (-0.23%) ⬇️
unittests-Instrumentation.AspNetCore 71.69% <ø> (ø)
unittests-Instrumentation.Cassandra 23.52% <ø> (ø)
unittests-Instrumentation.ConfluentKafka 14.10% <ø> (ø)
unittests-Instrumentation.ElasticsearchClient 80.12% <ø> (ø)
unittests-Instrumentation.EntityFrameworkCore 80.80% <ø> (ø)
unittests-Instrumentation.EventCounters 77.27% <ø> (ø)
unittests-Instrumentation.GrpcCore 91.42% <ø> (ø)
unittests-Instrumentation.GrpcNetClient 79.61% <ø> (ø)
unittests-Instrumentation.Hangfire 86.05% <ø> (ø)
unittests-Instrumentation.Http 74.22% <ø> (ø)
unittests-Instrumentation.Owin 88.62% <ø> (ø)
unittests-Instrumentation.Process 100.00% <ø> (ø)
unittests-Instrumentation.Quartz 78.76% <ø> (ø)
unittests-Instrumentation.Runtime 100.00% <ø> (ø)
unittests-Instrumentation.ServiceFabricRemoting 34.54% <ø> (ø)
unittests-Instrumentation.SqlClient 87.03% <ø> (ø)
unittests-Instrumentation.StackExchangeRedis 71.80% <ø> (ø)
unittests-Instrumentation.Wcf 79.57% <ø> (ø)
unittests-OpAmp.Client 80.16% <ø> (ø)
unittests-PersistentStorage 74.91% <ø> (ø)
unittests-Resources.AWS 74.42% <ø> (ø)
unittests-Resources.Azure 85.31% <ø> (ø)
unittests-Resources.Container 67.34% <ø> (ø)
unittests-Resources.Gcp 71.42% <ø> (ø)
unittests-Resources.Host 71.85% <ø> (ø)
unittests-Resources.OperatingSystem 76.98% <ø> (ø)
unittests-Resources.Process 100.00% <ø> (ø)
unittests-Resources.ProcessRuntime 79.59% <ø> (ø)
unittests-Sampler.AWS 94.30% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/Shared/SqlProcessor.cs 99.22% <100.00%> (+0.07%) ⬆️

... and 2 files with indirect coverage changes

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions github-actions Bot added comp:instrumentation.entityframeworkcore Things related to OpenTelemetry.Instrumentation.EntityFrameworkCore comp:instrumentation.sqlclient Things related to OpenTelemetry.Instrumentation.SqlClient labels Jan 8, 2026
@martincostello
Copy link
Copy Markdown
Member Author

/cc @stevejgordon

Recognise more SQL keywords to improve query summaries.

Resolves open-telemetry#3666.
@github-actions github-actions Bot removed infra Infra work - CI/CD, code coverage, linters dependencies Pull requests that update a dependency file labels Jan 9, 2026
@martincostello martincostello marked this pull request as ready for review January 9, 2026 09:48
@martincostello martincostello requested a review from a team as a code owner January 9, 2026 09:48
Copilot AI review requested due to automatic review settings January 9, 2026 09:48
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request enhances SQL parsing capabilities by adding recognition for additional T-SQL keywords to improve query summary generation. The changes address issue #3666 by implementing support for commands like GRANT, DENY, REVOKE, TRUNCATE, BACKUP, RESTORE, BULK INSERT, and ENABLE/DISABLE TRIGGER.

Key changes:

  • Added 12 new SQL keywords (BACKUP, BULK, CONNECT, DENY, DISABLE, ENABLE, EXECUTE, GRANT, RESTORE, REVOKE, STATISTICS, TRUNCATE) to the SQL processor
  • Updated keyword relationship mappings to properly handle multi-word SQL commands
  • Modified existing test cases to reflect new expected behavior (e.g., "REVOKE SELECT" now summarizes as "REVOKE")
  • Added comprehensive test coverage for all new keywords

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
src/Shared/SqlProcessor.cs Added new SQL keyword enums, keyword info instances, and configured keyword relationships and capture logic for T-SQL statement recognition
test/OpenTelemetry.Contrib.Shared.Tests/SqlProcessorAdditionalTestCases.json Updated existing test cases to reflect new summary behavior and added 7 new test cases for newly supported keywords
src/OpenTelemetry.Instrumentation.SqlClient/CHANGELOG.md Documented the improvement to SQL parsing for T-SQL keywords
src/OpenTelemetry.Instrumentation.EntityFrameworkCore/CHANGELOG.md Documented the improvement to SQL parsing for T-SQL keywords

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/Shared/SqlProcessor.cs
Copy link
Copy Markdown
Member

@alanwest alanwest left a comment

Choose a reason for hiding this comment

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

Approving, but just sharing the observation that even prior to this PR we appear to have some inconsistency for when we capture the target of an operation in the db.query.summary.

I don't feel strongly that anything needs to be addressed in this PR, but we should probably discuss our general stance for when/why we include a target in db.query.summary.

"db.query.text": [
"DISABLE TRIGGER Person.uAddress ON Person.Address;"
],
"db.query.summary": "DISABLE TRIGGER Person.uAddress"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Sometimes db.query.summary contains the target of the operation.

Comment on lines +1311 to +1313
"RESTORE DATABASE AdventureWorks2022 FROM AdventureWorks2022Backups;"
],
"db.query.summary": "RESTORE DATABASE"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Other times it does not.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yeah, I got a bit bogged down in exactly how to configure things in the code to get it to capture things or not.

Rather than sink too much time into it (or breaking something) I just figured incremental improvement was best for now.

@alanwest alanwest enabled auto-merge January 9, 2026 22:06
@github-actions github-actions Bot requested a review from matt-hensley January 9, 2026 22:06
@alanwest alanwest added this pull request to the merge queue Jan 9, 2026
Merged via the queue into open-telemetry:main with commit b6723bb Jan 9, 2026
633 of 636 checks passed
@martincostello martincostello deleted the gh-3666 branch January 10, 2026 16:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp:instrumentation.entityframeworkcore Things related to OpenTelemetry.Instrumentation.EntityFrameworkCore comp:instrumentation.sqlclient Things related to OpenTelemetry.Instrumentation.SqlClient

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug] Missing SQL keywords for query summaries

4 participants