factory_windows.go 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. // Copyright The OpenTelemetry Authors
  2. // SPDX-License-Identifier: Apache-2.0
  3. //go:build windows
  4. // +build windows
  5. package windowsperfcountersreceiver // import "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/windowsperfcountersreceiver"
  6. import (
  7. "context"
  8. "go.opentelemetry.io/collector/component"
  9. "go.opentelemetry.io/collector/consumer"
  10. "go.opentelemetry.io/collector/receiver"
  11. "go.opentelemetry.io/collector/receiver/scraperhelper"
  12. )
  13. // createMetricsReceiver creates a metrics receiver based on provided config.
  14. func createMetricsReceiver(
  15. ctx context.Context,
  16. params receiver.CreateSettings,
  17. cfg component.Config,
  18. consumer consumer.Metrics,
  19. ) (receiver.Metrics, error) {
  20. oCfg := cfg.(*Config)
  21. scraper := newScraper(oCfg, params.TelemetrySettings)
  22. scrp, err := scraperhelper.NewScraper(
  23. params.ID.String(),
  24. scraper.scrape,
  25. scraperhelper.WithStart(scraper.start),
  26. scraperhelper.WithShutdown(scraper.shutdown),
  27. )
  28. if err != nil {
  29. return nil, err
  30. }
  31. return scraperhelper.NewScraperControllerReceiver(
  32. &oCfg.ScraperControllerSettings,
  33. params,
  34. consumer,
  35. scraperhelper.AddScraper(scrp),
  36. )
  37. }