factory.go 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. // Copyright The OpenTelemetry Authors
  2. // SPDX-License-Identifier: Apache-2.0
  3. package awscloudwatchreceiver // import "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/awscloudwatchreceiver"
  4. import (
  5. "context"
  6. "go.opentelemetry.io/collector/component"
  7. "go.opentelemetry.io/collector/consumer"
  8. "go.opentelemetry.io/collector/receiver"
  9. "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/awscloudwatchreceiver/internal/metadata"
  10. )
  11. // NewFactory returns the component factory for the awscloudwatchreceiver
  12. func NewFactory() receiver.Factory {
  13. return receiver.NewFactory(
  14. metadata.Type,
  15. createDefaultConfig,
  16. receiver.WithLogs(createLogsReceiver, metadata.LogsStability),
  17. )
  18. }
  19. func createLogsReceiver(
  20. _ context.Context,
  21. params receiver.CreateSettings,
  22. rConf component.Config,
  23. consumer consumer.Logs,
  24. ) (receiver.Logs, error) {
  25. cfg := rConf.(*Config)
  26. rcvr := newLogsReceiver(cfg, params.Logger, consumer)
  27. return rcvr, nil
  28. }
  29. func createDefaultConfig() component.Config {
  30. return &Config{
  31. Logs: &LogsConfig{
  32. PollInterval: defaultPollInterval,
  33. MaxEventsPerRequest: defaultEventLimit,
  34. Groups: GroupConfig{
  35. AutodiscoverConfig: &AutodiscoverConfig{
  36. Limit: defaultLogGroupLimit,
  37. },
  38. },
  39. },
  40. }
  41. }