factory_windows.go 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. // Copyright The OpenTelemetry Authors
  2. // SPDX-License-Identifier: Apache-2.0
  3. //go:build windows
  4. // +build windows
  5. package activedirectorydsreceiver // import "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/activedirectorydsreceiver"
  6. import (
  7. "context"
  8. "fmt"
  9. "go.opentelemetry.io/collector/component"
  10. "go.opentelemetry.io/collector/consumer"
  11. "go.opentelemetry.io/collector/receiver"
  12. "go.opentelemetry.io/collector/receiver/scraperhelper"
  13. "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/activedirectorydsreceiver/internal/metadata"
  14. )
  15. var errConfigNotActiveDirectory = fmt.Errorf("config is not valid for the '%s' receiver", metadata.Type)
  16. func createMetricsReceiver(
  17. ctx context.Context,
  18. params receiver.CreateSettings,
  19. rConf component.Config,
  20. consumer consumer.Metrics,
  21. ) (receiver.Metrics, error) {
  22. c, ok := rConf.(*Config)
  23. if !ok {
  24. return nil, errConfigNotActiveDirectory
  25. }
  26. adds := newActiveDirectoryDSScraper(c.MetricsBuilderConfig, params)
  27. scraper, err := scraperhelper.NewScraper(
  28. metadata.Type,
  29. adds.scrape,
  30. scraperhelper.WithStart(adds.start),
  31. scraperhelper.WithShutdown(adds.shutdown),
  32. )
  33. if err != nil {
  34. return nil, err
  35. }
  36. return scraperhelper.NewScraperControllerReceiver(
  37. &c.ScraperControllerSettings,
  38. params,
  39. consumer,
  40. scraperhelper.AddScraper(scraper),
  41. )
  42. }