Skip to content

collector: add reusable runtime wrapper#3661

Draft
nicolastakashi wants to merge 2 commits into
prometheus:masterfrom
nicolastakashi:embeddable-runtime-foundation
Draft

collector: add reusable runtime wrapper#3661
nicolastakashi wants to merge 2 commits into
prometheus:masterfrom
nicolastakashi:embeddable-runtime-foundation

Conversation

@nicolastakashi
Copy link
Copy Markdown

@nicolastakashi nicolastakashi commented May 19, 2026

Summary

This continues the incremental refactor to make node_exporter easier to embed outside the standalone binary.
The broader goal is to support ongoing work to make Prometheus exporters embeddable inside the Prometheus OpenTelemetry Collector distribution as native receivers, without requiring each exporter to be rewritten as an OpenTelemetry component.
This PR builds on the reusable config package by adding a runtime layer that downstream callers can construct directly from config, independent of CLI parsing and HTTP serving.
Specifically, this PR:

  • adds collector.Runtime as a reusable wrapper around NodeCollector
  • validates reusable config at runtime construction time
  • exposes embeddable APIs for:
    • collector access via Collectors()
    • registry creation via Registry()
    • enabled collector discovery via EnabledCollectors()
  • adds unit tests covering runtime construction, validation, and registry gathering

Why

Today, node_exporter collector construction is tied closely to the binary wiring. Introducing a reusable runtime layer is a small but important step toward separating:

  • binary concerns such as flags, HTTP serving, and process setup
  • reusable exporter concerns such as config validation, collector construction, and metric registry assembly
    This does not make node_exporter fully embeddable yet. In particular, collector-specific process-global configuration and state still need follow-up refactors. The intent here is to establish a reusable runtime API that future changes can build on.

Stack

This PR is part of a stacked series:

Signed-off-by: Nicolas Takashi <nicolas.tcs@hotmail.com>
Signed-off-by: Nicolas Takashi <nicolas.tcs@hotmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant