Skip to content

Finer grained driver loading in SQL receivers #39918

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

Conversation

nozomi-gedimitr
Copy link
Contributor

@nozomi-gedimitr nozomi-gedimitr commented May 7, 2025

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.

@nozomi-gedimitr nozomi-gedimitr marked this pull request as ready for review May 7, 2025 07:38
@nozomi-gedimitr nozomi-gedimitr requested a review from a team as a code owner May 7, 2025 07:38
@nozomi-gedimitr nozomi-gedimitr marked this pull request as draft May 7, 2025 07:39
@nozomi-gedimitr nozomi-gedimitr marked this pull request as ready for review May 7, 2025 10:53
Copy link
Member

@mx-psi mx-psi left a comment

Choose a reason for hiding this comment

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

Thanks for your PR, this looks good to me

@mx-psi mx-psi merged commit 2ab1180 into open-telemetry:main May 7, 2025
209 checks passed
@github-actions github-actions bot added this to the next release milestone May 7, 2025
dragonlord93 pushed a commit to dragonlord93/opentelemetry-collector-contrib that referenced this pull request May 23, 2025
#### 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants