config.go 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. // Copyright The OpenTelemetry Authors
  2. // SPDX-License-Identifier: Apache-2.0
  3. package skywalkingexporter // import "github.com/open-telemetry/opentelemetry-collector-contrib/exporter/skywalkingexporter"
  4. import (
  5. "errors"
  6. "go.opentelemetry.io/collector/component"
  7. "go.opentelemetry.io/collector/config/configgrpc"
  8. "go.opentelemetry.io/collector/exporter/exporterhelper"
  9. )
  10. // Config defines configuration for SkyWalking exporter.
  11. type Config struct {
  12. configgrpc.GRPCClientSettings `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct.
  13. exporterhelper.QueueSettings `mapstructure:"sending_queue"`
  14. exporterhelper.RetrySettings `mapstructure:"retry_on_failure"`
  15. exporterhelper.TimeoutSettings `mapstructure:",squash"` // squash ensures fields are correctly decoded in embedded struct.
  16. // The number of grpc streams that send the gRPC requests.
  17. NumStreams int `mapstructure:"num_streams"`
  18. }
  19. var _ component.Config = (*Config)(nil)
  20. // Validate checks if the exporter configuration is valid
  21. func (cfg *Config) Validate() error {
  22. if cfg.Endpoint == "" {
  23. return errors.New("Skywalking exporter cfg requires an Endpoint")
  24. }
  25. if cfg.NumStreams <= 0 {
  26. return errors.New("Skywalking exporter cfg requires at least one stream")
  27. }
  28. return nil
  29. }