Skip to content

Commit

Permalink
[chore] use metadata.Type with nsxtreceiver (#21992)
Browse files Browse the repository at this point in the history
  • Loading branch information
atoulme authored May 17, 2023
1 parent 1b921c8 commit 3f5370e
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 14 deletions.
4 changes: 3 additions & 1 deletion receiver/nsxtreceiver/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import (
"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/config/confighttp"
"go.opentelemetry.io/collector/confmap/confmaptest"

"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/nsxtreceiver/internal/metadata"
)

func TestMetricValidation(t *testing.T) {
Expand Down Expand Up @@ -96,7 +98,7 @@ func TestLoadConfig(t *testing.T) {
factory := NewFactory()
cfg := factory.CreateDefaultConfig()

sub, err := cm.Sub(component.NewIDWithName(typeStr, "").String())
sub, err := cm.Sub(component.NewIDWithName(metadata.Type, "").String())
require.NoError(t, err)
require.NoError(t, component.UnmarshalConfig(sub, cfg))

Expand Down
2 changes: 1 addition & 1 deletion receiver/nsxtreceiver/documentation.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[comment]: <> (Code generated by mdatagen. DO NOT EDIT.)

# nsxtreceiver
# nsxt

## Default Metrics

Expand Down
8 changes: 2 additions & 6 deletions receiver/nsxtreceiver/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,12 @@ import (
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/nsxtreceiver/internal/metadata"
)

const (
typeStr = "nsxt"
)

var errConfigNotNSX = errors.New("config was not a NSX receiver config")

// NewFactory creates a new receiver factory
func NewFactory() receiver.Factory {
return receiver.NewFactory(
typeStr,
metadata.Type,
createDefaultConfig,
receiver.WithMetrics(createMetricsReceiver, metadata.MetricsStability),
)
Expand All @@ -59,7 +55,7 @@ func createMetricsReceiver(ctx context.Context, params receiver.CreateSettings,
s := newScraper(cfg, params)

scraper, err := scraperhelper.NewScraper(
typeStr,
metadata.Type,
s.scrape,
scraperhelper.WithStart(s.start),
)
Expand Down
4 changes: 3 additions & 1 deletion receiver/nsxtreceiver/factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,14 @@ import (
"go.opentelemetry.io/collector/consumer/consumertest"
"go.opentelemetry.io/collector/receiver/receivertest"
"go.opentelemetry.io/collector/receiver/scraperhelper"

"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/nsxtreceiver/internal/metadata"
)

func TestType(t *testing.T) {
factory := NewFactory()
ft := factory.Type()
require.EqualValues(t, typeStr, ft)
require.EqualValues(t, metadata.Type, ft)
}

func TestDefaultConfig(t *testing.T) {
Expand Down
6 changes: 3 additions & 3 deletions receiver/nsxtreceiver/internal/metadata/generated_config.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion receiver/nsxtreceiver/metadata.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
type: nsxtreceiver
type: nsxt

status:
class: receiver
Expand Down

0 comments on commit 3f5370e

Please sign in to comment.