Files
8e9c14c012 [pkg/scraperhelper] Switch scraper/scraperhelper to schema-based configuration (#15318)
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
#### Description

Switch `scraper/scraperhelper` `ControllerConfig` to schema-based
generated configuration.

This adds metadata-driven config generation for the scraper controller
settings, publishes the reusable `controller_config` schema from
`pkg/scraperhelper`, and updates the mdatagen sample scraper to embed
that exported config via schema reference.

<!-- Issue number if applicable -->
#### Link to tracking issue
Fixes #15258

<!--Describe what testing was performed and which tests were added.-->
#### Testing

Added usage example to `samplescraper` test component.

---------

Co-authored-by: Dmitry Anoshin <[email protected]>
2026-05-20 23:06:25 +00:00

24 lines
630 B
Go

// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
package controller // import "go.opentelemetry.io/collector/scraper/scraperhelper/internal/controller"
import (
"errors"
"fmt"
"go.uber.org/multierr"
)
var errNonPositiveInterval = errors.New("requires positive value")
func validateControllerConfig(set *ControllerConfig) (errs error) {
if set.CollectionInterval <= 0 {
errs = multierr.Append(errs, fmt.Errorf(`"collection_interval": %w`, errNonPositiveInterval))
}
if set.Timeout < 0 {
errs = multierr.Append(errs, fmt.Errorf(`"timeout": %w`, errNonPositiveInterval))
}
return errs
}