factory_windows_test.go 888 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. // Copyright The OpenTelemetry Authors
  2. // SPDX-License-Identifier: Apache-2.0
  3. //go:build windows
  4. // +build windows
  5. package windowsperfcountersreceiver
  6. import (
  7. "context"
  8. "testing"
  9. "github.com/stretchr/testify/assert"
  10. "go.opentelemetry.io/collector/consumer/consumertest"
  11. )
  12. func TestCreateMetricsReceiver(t *testing.T) {
  13. factory := NewFactory()
  14. cfg := factory.CreateDefaultConfig()
  15. cfg.(*Config).PerfCounters = []ObjectConfig{
  16. {
  17. Object: "object",
  18. Counters: []CounterConfig{{Name: "counter", MetricRep: MetricRep{Name: "metric"}}},
  19. },
  20. }
  21. cfg.(*Config).MetricMetaData = map[string]MetricConfig{
  22. "metric": {
  23. Description: "desc",
  24. Unit: "1",
  25. Gauge: GaugeMetric{},
  26. },
  27. }
  28. mReceiver, err := factory.CreateMetricsReceiver(context.Background(), creationParams, cfg, consumertest.NewNop())
  29. assert.NoError(t, err)
  30. assert.NotNil(t, mReceiver)
  31. }