factory.go 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. // Copyright The OpenTelemetry Authors
  2. // SPDX-License-Identifier: Apache-2.0
  3. package awscloudwatchmetricsreceiver // import "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/awscloudwatchmetricsreceiver"
  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/awscloudwatchmetricsreceiver/internal/metadata"
  10. )
  11. // NewFactory creates a factory for awscloudwatchmetrics receiver.
  12. func NewFactory() receiver.Factory {
  13. return receiver.NewFactory(
  14. metadata.Type,
  15. createDefaultConfig,
  16. receiver.WithMetrics(createMetricsReceiver, metadata.MetricsStability),
  17. )
  18. }
  19. func createMetricsReceiver(_ context.Context, params receiver.CreateSettings, baseCfg component.Config, consumer consumer.Metrics) (receiver.Metrics, error) {
  20. cfg := baseCfg.(*Config)
  21. rcvr := newMetricReceiver(cfg, params.Logger, consumer)
  22. return rcvr, nil
  23. }
  24. func createDefaultConfig() component.Config {
  25. return &Config{
  26. PollInterval: defaultPollInterval,
  27. Metrics: &MetricsConfig{},
  28. }
  29. }