Skip to content

Make service discoveries removable through Go build tags#45148

Merged
atoulme merged 3 commits intoopen-telemetry:mainfrom
ArthurSens:removable-sds
Jan 21, 2026
Merged

Make service discoveries removable through Go build tags#45148
atoulme merged 3 commits intoopen-telemetry:mainfrom
ArthurSens:removable-sds

Conversation

@ArthurSens
Copy link
Copy Markdown
Member

@ArthurSens ArthurSens commented Dec 24, 2025

Description

This PR is built on top of prometheus/prometheus#17736. There are a lot of go mod changes, and that also inherits fixes to interface changes that were made since Prometheus 3.8

The only change that is really about making SDs removable is this change in imports in factory.go:

-	_ "github.com/prometheus/prometheus/discovery/install" // init() of this package registers service discovery impl.
+	_ "github.com/prometheus/prometheus/plugins" // init() of this package registers service discovery impl.

Link to tracking issue

Fixes #44406

Testing

Used two builder configs and measured the binary size difference:

Without build tags(120MB):

dist:
  module: github.com/open-telemetry/otelcontribcol
  name: otelcontribcol
  version: 0.143.0
  output_path: ./cmd/otelcontribcol/sd-test/full

receivers:
  - gomod: github.com/open-telemetry/opentelemetry-collector-contrib/receiver/prometheusreceiver v0.143.0
    path: ./receiver/prometheusreceiver

exporters:
  - gomod: go.opentelemetry.io/collector/exporter/debugexporter v0.143.0

With build tags(63MG):

dist:
  module: github.com/open-telemetry/otelcontribcol
  name: otelcontribcol
  version: 0.143.0
  output_path: ./cmd/otelcontribcol/sd-test/no-sd
  build_tags: "remove_all_sd"

receivers:
  - gomod: github.com/open-telemetry/opentelemetry-collector-contrib/receiver/prometheusreceiver v0.143.0
    path: ./receiver/prometheusreceiver

exporters:
  - gomod: go.opentelemetry.io/collector/exporter/debugexporter v0.143.0

@ArthurSens
Copy link
Copy Markdown
Member Author

I'm opening this PR just to show how it works, but discussions should be done upstream at prometheus/prometheus :)

@atoulme atoulme marked this pull request as draft January 2, 2026 07:28
@atoulme
Copy link
Copy Markdown
Contributor

atoulme commented Jan 2, 2026

Moving to draft since this is not to be merged.

@github-actions
Copy link
Copy Markdown
Contributor

This PR was marked stale due to lack of activity. It will be closed in 14 days.

@github-actions github-actions bot added the Stale label Jan 17, 2026
@ArthurSens ArthurSens marked this pull request as ready for review January 19, 2026 12:53
@ArthurSens
Copy link
Copy Markdown
Member Author

ArthurSens commented Jan 19, 2026

PR finally ready for review @dashpole :)

I've also updated the PR description to mention how to test these changes

Signed-off-by: Arthur Silva Sens <[email protected]>
Signed-off-by: Arthur Silva Sens <[email protected]>
Copy link
Copy Markdown
Contributor

@atoulme atoulme left a comment

Choose a reason for hiding this comment

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

LGTM

@atoulme atoulme merged commit 6f1d79c into open-telemetry:main Jan 21, 2026
191 checks passed
@ArthurSens ArthurSens deleted the removable-sds branch January 21, 2026 19:17
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.

[prometheusreceiver] Consider separating prom service discovery from the receiver module

5 participants