Repository navigation
collector: add reusable runtime wrapper - #3661
nicolastakashi wants to merge 2 commits into
Conversation
6f1d282 to
bd1a15e
Compare
|
Relates to prometheus/opentelemetry-collector-bridge#41 |
|
Anything I could do to unblock this PR? :) |
bd1a15e to
e49dc09
Compare
Signed-off-by: Nicolas Takashi <nicolas.tcs@hotmail.com>
Signed-off-by: Nicolas Takashi <nicolas.tcs@hotmail.com>
e49dc09 to
c9b5d35
Compare
|
@ArthurSens PTAL |
ArthurSens
left a comment
There was a problem hiding this comment.
Good start :)
I noticed a bug with collector state still depending on global variables, which prevent us from doing something like this:
receivers:
nodeexporter/cpu:
scrape_interval: 10s
exporter_config:
collectors:
cpu: true
filesystem: false
# Other collectors disabled.
nodeexporter/filesystem:
scrape_interval: 60s
exporter_config:
collectors:
cpu: false
filesystem: true
# Other collectors disabled.because both runtimes would be overriding each others enabled collectors state
| type Runtime struct { | ||
| collector *NodeCollector | ||
| } |
There was a problem hiding this comment.
I believe the collectors' enable/disabled state also needs to be part of the runtime object so multiple runtimes don't affect each other.
| WebTelemetryPath string | ||
| WebDisableExporterMetrics bool | ||
| WebMaxRequests int |
There was a problem hiding this comment.
These configuration options don't seem related to configuring the metric collection, could we leave them out?
| WebDisableExporterMetrics bool | ||
| WebMaxRequests int | ||
| CollectorDisableDefaults bool | ||
| RuntimeGoMaxProcs int |
There was a problem hiding this comment.
This one also seems unrelated to metric collection
| WebMaxRequests int | ||
| CollectorDisableDefaults bool | ||
| RuntimeGoMaxProcs int | ||
| EnabledCollectors []string |
There was a problem hiding this comment.
Besides enabling/disabling collectors, it seems like we're missing a lot of config pieces that are specific to one single collector that also need to be here.
For example, we have --collector.textfile.directory, and this isn't present here, therefore we won't be able to configure this option whem embedding node exporter
There was a problem hiding this comment.
You can take a look at another similar PR in another exporter: prometheus/mysqld_exporter#1043
we have things like this:
type Config struct {
Collectors map[string]bool
InfoSchemaProcesslist InfoSchemaProcesslistConfig
// ...
}
type InfoSchemaProcesslistConfig struct {
MinTime int
ProcessesByUser bool
ProcessesByHost bool
}where infoSchemaProcesslistConfig is one of many collectors in MySQL exporter
Summary
This continues the incremental refactor to make
node_exportereasier 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:
collector.Runtimeas a reusable wrapper aroundNodeCollectorCollectors()Registry()EnabledCollectors()Why
Today,
node_exportercollector construction is tied closely to the binary wiring. Introducing a reusable runtime layer is a small but important step toward separating:This does not make
node_exporterfully 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:
Only the runtime layer is intended to be reviewed here; the CLI wiring changes will come in a follow-up PR.