Skip to content

Unnecessary call to config.Validate during component's initialization #33498

Closed
@rogercoll

Description

@rogercoll

Component(s)

exporter/dataset, exporter/elasticsearch, exporter/opensearch, receiver/dockerstats, receiver/podman

Describe the issue you're reporting

All collector's components must implement the component.ValidateConfig interface. During collector's startup, it goes through all components and calls the Validate method. Its execution is finished if any component returns an error. Nonetheless, some components call the Validate method during its initialization, which is redundant taking into account the collector life cycle. (e.g. Podman receiver)

I think that the Validate interface should be called by the configuration validator consumer (e.g. collector) instead of the configuration producers (components).

Context for Podman's receiver: https://github.com/open-telemetry/opentelemetry-collector-contrib/pull/32981/files#r1621849257

I linked to this issue the components that seems to be internally calling the configuration Validate method. I would not say calling Validate is forbidden, just that might be redundant during collector's execution. However, feel free to unlink your component from this issue if the Validate method call is necessary for your specific use case or if it performs additional checks that are not covered during the startup validation phase.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions