-
Notifications
You must be signed in to change notification settings - Fork 3k
[receiver/mysql] Add query sample collection for MySQL #40965
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
Merged
Merged
Conversation
This file contains hidden or 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
dmitryax
reviewed
Jul 4, 2025
dmitryax
reviewed
Jul 4, 2025
dmitryax
reviewed
Jul 4, 2025
dmitryax
reviewed
Jul 4, 2025
dmitryax
approved these changes
Jul 8, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@antonblock, @ishleenk17 PTAL once you have a chance. This is the same approach that is being used in other database receivers to scrape similar events |
It's been 3 weeks since the PR's open. I'm merging this |
Dylan-M
pushed a commit
to Dylan-M/opentelemetry-collector-contrib
that referenced
this pull request
Aug 5, 2025
…y#40965) <!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. Ex. Adding a feature - Explain what this achieves.--> #### Description This PR introduced query-level data collection for `MySQL` receiver in the logs pipeline. We introduced `Query Sample` collection in this initial PR (Query samples are those queries which are currently running at the moment that scraper is working) #### Configuration We introduced 2 configurations for the feature(see receiver's README for details): * `events."db.server.query_sample".enabled`: Flag to enable the feature. * `query_sample_collection.max_rows_per_query`: The expected report numbers of queries sample in each scrape. ##### Example output" ``` resourceLogs: - resource: {} scopeLogs: - logRecords: - attributes: - key: db.system.name value: stringValue: mysql - key: mysql.threads.thread_id value: intValue: "1034384" - key: user.name value: stringValue: myuser - key: db.namespace value: stringValue: adventureworks - key: mysql.threads.processlist_command value: stringValue: Query - key: mysql.threads.processlist_state value: stringValue: executing - key: db.query.text value: stringValue: SELECT soh.SalesOrderID, soh.OrderDate, c.CustomerID, p.Name AS ProductName, sod.OrderQty, sod.LineTotal FROM salesorderheader soh JOIN salesorderdetail sod ON soh.SalesOrderID = sod.SalesOrderID JOIN product p ON sod.ProductID = p.ProductID JOIN customer c ON soh.CustomerID = c.CustomerID ORDER BY soh.OrderDate DESC - key: mysql.events_statements_current.digest value: stringValue: aaaaaa - key: mysql.event_id value: intValue: "17470257762" - key: mysql.wait_type value: stringValue: CPU - key: mysql.events_waits_current.timer_wait value: doubleValue: 1.2851652e-05 - key: client.address value: stringValue: 192.168.1.80 - key: client.port value: intValue: "1234" - key: network.peer.address value: stringValue: 192.168.1.80 - key: network.peer.port value: intValue: "1234" body: {} eventName: db.server.query_sample spanId: "" timeUnixNano: "1751033212422664000" traceId: "" scope: name: github.com/open-telemetry/opentelemetry-collector-contrib/receiver/mysqlreceiver version: latest ``` <!-- Issue number (e.g. open-telemetry#1234) or full URL to issue, if applicable. --> #### Link to tracking issue n/a <!--Describe what testing was performed and which tests were added.--> #### Testing Added <!--Describe the documentation added.--> #### Documentation Added <!--Please delete paragraphs that you did not use before submitting.-->
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR introduced query-level data collection for
MySQL
receiver in the logs pipeline.We introduced
Query Sample
collection in this initial PR (Query samples are those queries which are currently running at the moment that scraper is working)Configuration
We introduced 2 configurations for the feature(see receiver's README for details):
events."db.server.query_sample".enabled
: Flag to enable the feature.query_sample_collection.max_rows_per_query
: The expected report numbers of queries sample in each scrape.Example output"
Link to tracking issue
n/a
Testing
Added
Documentation
Added