config.go 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. // Copyright The OpenTelemetry Authors
  2. // SPDX-License-Identifier: Apache-2.0
  3. package filereceiver // import "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/filereceiver"
  4. import (
  5. "errors"
  6. "go.opentelemetry.io/collector/component"
  7. )
  8. // Config defines the configuration for the file receiver.
  9. type Config struct {
  10. // Path of the file to read from. Path is relative to current directory.
  11. Path string `mapstructure:"path"`
  12. // Throttle determines how fast telemetry is replayed. A value of zero means
  13. // that it will be replayed as fast as the system will allow. A value of 1 means
  14. // that it will be replayed at the same rate as the data came in, as indicated
  15. // by the timestamps on the input file's telemetry data. Higher values mean that
  16. // replay will be slower by a corresponding amount. Use a value between 0 and 1
  17. // to replay telemetry at a higher speed. Default: 1.
  18. Throttle float64 `mapstructure:"throttle"`
  19. }
  20. func createDefaultConfig() component.Config {
  21. return &Config{
  22. Throttle: 1,
  23. }
  24. }
  25. func (c Config) Validate() error {
  26. if c.Path == "" {
  27. return errors.New("path cannot be empty")
  28. }
  29. if c.Throttle < 0 {
  30. return errors.New("throttle cannot be negative")
  31. }
  32. return nil
  33. }