-
Notifications
You must be signed in to change notification settings - Fork 2.8k
[receiver/postgresql] add basic query sample collection #39311
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/postgresql] add basic query sample collection #39311
Conversation
168878f
to
7781ea0
Compare
7781ea0
to
543872d
Compare
| Distributions | [contrib] | | ||
| Issues | [](https://github.com/open-telemetry/opentelemetry-collector-contrib/issues?q=is%3Aopen+is%3Aissue+label%3Areceiver%2Fpostgresql) [](https://github.com/open-telemetry/opentelemetry-collector-contrib/issues?q=is%3Aclosed+is%3Aissue+label%3Areceiver%2Fpostgresql) | | ||
| [Code Owners](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/CONTRIBUTING.md#becoming-a-code-owner) | \| Seeking more code owners! | | ||
| Emeritus | [@djaglowski](https://www.github.com/djaglowski) | | ||
|
||
[unmaintained]: https://github.com/open-telemetry/opentelemetry-collector/blob/main/docs/component-stability.md#unmaintained | ||
[development]: https://github.com/open-telemetry/opentelemetry-collector/blob/main/docs/component-stability.md#development |
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.
you might like to make yourself a codeowner of this component. Separate PR please.
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.
this is brand new functionality, lgtm though I'm no expert. OK to merge under development label.
…tor-contrib into postgresql-sample-query
Given that postgresqlreceiver is unmaintained, there are no codeowners to review the changes. I tend to lean towards letting code that is clearly labeled in development in as I prefer rapid iteration. I will merge this change now. |
…ry#39311) <!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. Ex. Adding a feature - Explain what this achieves.--> #### Description we introduced the query sample collection to postgresql receiver. this will collect the queries from `pg_stat_activity` and report the related metrics. this will help the end user to identify the queries were executing in database. example output: ``` resourceLogs: - resource: attributes: [] scopeLogs: - logRecords: - attributes: - key: user.name value: stringValue: otelu - key: postgresql.state value: stringValue: idle - key: postgresql.pid value: intValue: 1450 - key: postgresql.application_name value: stringValue: receiver - key: db.system.name value: stringValue: postgresql - key: db.namespace value: stringValue: postgres - key: network.peer.address value: stringValue: "11.4.5.14" - key: network.peer.port value: intValue: 114514 - key: postgresql.client_hostname value: stringValue: otel - key: postgresql.query_start value: stringValue: 2025-02-12T16:37:54.843+08:00 - key: postgresql.wait_event value: stringValue: "" - key: postgresql.wait_event_type value: stringValue: "" - key: postgresql.query_id value: stringValue: "123131231231" - key: db.query.text value: stringValue: "select * from pg_stat_activity where id = ?" body: stringValue: sample scope: name: github.com/open-telemetry/opentelemetry-collector-contrib/receiver/postgresqlreceiver version: v0.0.1 ``` <!-- Issue number (e.g. open-telemetry#1234) or full URL to issue, if applicable. --> #### Link to tracking issue Fixes <!--Describe what testing was performed and which tests were added.--> #### Testing <!--Describe the documentation added.--> #### Documentation <!--Please delete paragraphs that you did not use before submitting.-->
…ry#39311) <!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. Ex. Adding a feature - Explain what this achieves.--> #### Description we introduced the query sample collection to postgresql receiver. this will collect the queries from `pg_stat_activity` and report the related metrics. this will help the end user to identify the queries were executing in database. example output: ``` resourceLogs: - resource: attributes: [] scopeLogs: - logRecords: - attributes: - key: user.name value: stringValue: otelu - key: postgresql.state value: stringValue: idle - key: postgresql.pid value: intValue: 1450 - key: postgresql.application_name value: stringValue: receiver - key: db.system.name value: stringValue: postgresql - key: db.namespace value: stringValue: postgres - key: network.peer.address value: stringValue: "11.4.5.14" - key: network.peer.port value: intValue: 114514 - key: postgresql.client_hostname value: stringValue: otel - key: postgresql.query_start value: stringValue: 2025-02-12T16:37:54.843+08:00 - key: postgresql.wait_event value: stringValue: "" - key: postgresql.wait_event_type value: stringValue: "" - key: postgresql.query_id value: stringValue: "123131231231" - key: db.query.text value: stringValue: "select * from pg_stat_activity where id = ?" body: stringValue: sample scope: name: github.com/open-telemetry/opentelemetry-collector-contrib/receiver/postgresqlreceiver version: v0.0.1 ``` <!-- Issue number (e.g. open-telemetry#1234) or full URL to issue, if applicable. --> #### Link to tracking issue Fixes <!--Describe what testing was performed and which tests were added.--> #### Testing <!--Describe the documentation added.--> #### Documentation <!--Please delete paragraphs that you did not use before submitting.-->
#### Description Between 0.123.0 and 0.124.0, the footprint of the `postgresql` receiver increased sharply when participating in custom builds. As an experiment, builds using the configuration below were done for both 0.123.0 and 0.124.0 releases in MacOS. ``` dist: name: otelcol-custom description: Local OpenTelemetry Collector binary output_path: /tmp/dist exporters: - gomod: go.opentelemetry.io/collector/exporter/debugexporter v0.124.0 receivers: - gomod: github.com/open-telemetry/opentelemetry-collector-contrib/receiver/postgresqlreceiver v0.124.0 processors: - gomod: go.opentelemetry.io/collector/processor/batchprocessor v0.124.0 ``` The generated binary size increased significantly * 0.123.0 --> 25 MB * 0.124.0 --> 63 MB The problem was found to be the recent inclusion of the internal `sqlquery` package (PR #39311): this package registers drivers for all kinds of databases, and thus the `postgresql` receiver got many new (unneeded) dependencies. With this PR, the `internal/sqlquery` package no longer registers drivers for all possible databases: instead this task is expected to be done by the actual users of the package, who know best what drivers they are going to need. Apart from the `postgresql` receiver, the `sqlserver` one got its dependencies accordingly trimmed.
#### Description Between 0.123.0 and 0.124.0, the footprint of the `postgresql` receiver increased sharply when participating in custom builds. As an experiment, builds using the configuration below were done for both 0.123.0 and 0.124.0 releases in MacOS. ``` dist: name: otelcol-custom description: Local OpenTelemetry Collector binary output_path: /tmp/dist exporters: - gomod: go.opentelemetry.io/collector/exporter/debugexporter v0.124.0 receivers: - gomod: github.com/open-telemetry/opentelemetry-collector-contrib/receiver/postgresqlreceiver v0.124.0 processors: - gomod: go.opentelemetry.io/collector/processor/batchprocessor v0.124.0 ``` The generated binary size increased significantly * 0.123.0 --> 25 MB * 0.124.0 --> 63 MB The problem was found to be the recent inclusion of the internal `sqlquery` package (PR open-telemetry#39311): this package registers drivers for all kinds of databases, and thus the `postgresql` receiver got many new (unneeded) dependencies. With this PR, the `internal/sqlquery` package no longer registers drivers for all possible databases: instead this task is expected to be done by the actual users of the package, who know best what drivers they are going to need. Apart from the `postgresql` receiver, the `sqlserver` one got its dependencies accordingly trimmed.
Description
we introduced the query sample collection to postgresql receiver. this will collect the queries from
pg_stat_activity
and report the related metrics. this will help the end user to identify the queries were executing in database.example output:
Link to tracking issue
Fixes
Testing
Documentation