Skip to content

Commit

Permalink
[chore][receiver/hostmetrics, exporter/awsxray] Fix some more empty I…
Browse files Browse the repository at this point in the history
…Ds (open-telemetry#30994)

**Description:** 

- Makes the test on awsxray exporter use the
`exportertest.NewNopCreateSettings().ID`. This is because this is the ID
passed to `newTracesExporter`:
https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/2f5b0bc52cd160886b4e1ee03461704d6c440a8d/exporter/awsxrayexporter/awsxray_test.go#L109
Currently, this makes no difference, but it will once the ID on
NewNopCreateSettings is fixed.
- Also fixes the hostmetrics receiver ID, just for fun :)


**Link to tracking Issue:** Needed for
open-telemetry/opentelemetry-collector/pull/9414
  • Loading branch information
mx-psi authored and cparkins committed Feb 1, 2024
1 parent 35f1c16 commit 1829233
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
3 changes: 1 addition & 2 deletions exporter/awsxrayexporter/awsxray_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/component/componenttest"
"go.opentelemetry.io/collector/exporter"
"go.opentelemetry.io/collector/exporter/exportertest"
Expand Down Expand Up @@ -70,7 +69,7 @@ func TestTelemetryEnabled(t *testing.T) {
registry := telemetry.NewRegistry()
sink := telemetrytest.NewSenderSink()
// preload the sender that the exporter will use
sender, loaded := registry.LoadOrStore(component.NewID(""), sink)
sender, loaded := registry.LoadOrStore(exportertest.NewNopCreateSettings().ID, sink)
require.False(t, loaded)
require.NotNil(t, sender)
require.Equal(t, sink, sender)
Expand Down
2 changes: 1 addition & 1 deletion receiver/hostmetricsreceiver/hostmetrics_receiver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ func (m *mockFactory) CreateMetricsScraper(context.Context, receiver.CreateSetti
return args.Get(0).(scraperhelper.Scraper), args.Error(1)
}

func (m *mockScraper) ID() component.ID { return component.NewID("") }
func (m *mockScraper) ID() component.ID { return component.NewID("mock_scraper") }
func (m *mockScraper) Start(context.Context, component.Host) error { return nil }
func (m *mockScraper) Shutdown(context.Context) error { return nil }
func (m *mockScraper) Scrape(context.Context) (pmetric.Metrics, error) {
Expand Down

0 comments on commit 1829233

Please sign in to comment.