diff --git a/.chloggen/hostmetrics-report-scraper-names-in-errors.yaml b/.chloggen/hostmetrics-report-scraper-names-in-errors.yaml new file mode 100644 index 000000000000..c17b936ec68b --- /dev/null +++ b/.chloggen/hostmetrics-report-scraper-names-in-errors.yaml @@ -0,0 +1,27 @@ +# Use this changelog template to create an entry for release notes. + +# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' +change_type: enhancement + +# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver) +component: hostmetrics + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: Adjust scraper creation to make it so the scraper name is reported with hostmetrics scraper errors. + +# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists. +issues: [35814] + +# (Optional) One or more lines of additional information to render under the primary note. +# These lines will be padded with 2 spaces and then inserted directly into the document. +# Use pipe (|) for multiline entries. +subtext: + +# If your change doesn't affect end users or the exported elements of any package, +# you should instead start your pull request title with [chore] or use the "Skip Changelog" label. +# Optional: The change log or logs in which this entry should be included. +# e.g. '[user]' or '[user, api]' +# Include 'user' if the change is relevant to end users. +# Include 'api' if there is a change to a library API. +# Default: '[user]' +change_logs: [] diff --git a/receiver/hostmetricsreceiver/internal/scraper/cpuscraper/factory.go b/receiver/hostmetricsreceiver/internal/scraper/cpuscraper/factory.go index 16aeda432cc9..614133ccf20d 100644 --- a/receiver/hostmetricsreceiver/internal/scraper/cpuscraper/factory.go +++ b/receiver/hostmetricsreceiver/internal/scraper/cpuscraper/factory.go @@ -6,11 +6,11 @@ package cpuscraper // import "github.com/open-telemetry/opentelemetry-collector- import ( "context" + "go.opentelemetry.io/collector/component" "go.opentelemetry.io/collector/receiver" "go.opentelemetry.io/collector/receiver/scraperhelper" "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/hostmetricsreceiver/internal" - hostmeta "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/hostmetricsreceiver/internal/metadata" "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/hostmetricsreceiver/internal/scraper/cpuscraper/internal/metadata" ) @@ -21,6 +21,11 @@ const ( TypeStr = "cpu" ) +var ( + // scraperType is the component type used for the built scraper. + scraperType component.Type = component.MustNewType(TypeStr) +) + // Factory is the Factory for scraper. type Factory struct{} @@ -41,7 +46,7 @@ func (f *Factory) CreateMetricsScraper( s := newCPUScraper(ctx, settings, cfg) return scraperhelper.NewScraper( - hostmeta.Type, + scraperType, s.scrape, scraperhelper.WithStart(s.start), ) diff --git a/receiver/hostmetricsreceiver/internal/scraper/cpuscraper/factory_test.go b/receiver/hostmetricsreceiver/internal/scraper/cpuscraper/factory_test.go index c91a70fd2c16..00d46729f498 100644 --- a/receiver/hostmetricsreceiver/internal/scraper/cpuscraper/factory_test.go +++ b/receiver/hostmetricsreceiver/internal/scraper/cpuscraper/factory_test.go @@ -25,4 +25,5 @@ func TestCreateMetricsScraper(t *testing.T) { assert.NoError(t, err) assert.NotNil(t, scraper) + assert.Equal(t, scraperType.String(), scraper.ID().String()) } diff --git a/receiver/hostmetricsreceiver/internal/scraper/diskscraper/factory.go b/receiver/hostmetricsreceiver/internal/scraper/diskscraper/factory.go index 5c4ea8c8c843..d78a7e973655 100644 --- a/receiver/hostmetricsreceiver/internal/scraper/diskscraper/factory.go +++ b/receiver/hostmetricsreceiver/internal/scraper/diskscraper/factory.go @@ -6,11 +6,11 @@ package diskscraper // import "github.com/open-telemetry/opentelemetry-collector import ( "context" + "go.opentelemetry.io/collector/component" "go.opentelemetry.io/collector/receiver" "go.opentelemetry.io/collector/receiver/scraperhelper" "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/hostmetricsreceiver/internal" - hostmeta "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/hostmetricsreceiver/internal/metadata" "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/hostmetricsreceiver/internal/scraper/diskscraper/internal/metadata" ) @@ -21,6 +21,11 @@ const ( TypeStr = "disk" ) +var ( + // scraperType is the component type used for the built scraper. + scraperType component.Type = component.MustNewType(TypeStr) +) + // Factory is the Factory for scraper. type Factory struct { } @@ -45,7 +50,7 @@ func (f *Factory) CreateMetricsScraper( } return scraperhelper.NewScraper( - hostmeta.Type, + scraperType, s.scrape, scraperhelper.WithStart(s.start), ) diff --git a/receiver/hostmetricsreceiver/internal/scraper/diskscraper/factory_test.go b/receiver/hostmetricsreceiver/internal/scraper/diskscraper/factory_test.go index 435694ee5c11..0367990e7331 100644 --- a/receiver/hostmetricsreceiver/internal/scraper/diskscraper/factory_test.go +++ b/receiver/hostmetricsreceiver/internal/scraper/diskscraper/factory_test.go @@ -25,6 +25,7 @@ func TestCreateMetricsScraper(t *testing.T) { assert.NoError(t, err) assert.NotNil(t, scraper) + assert.Equal(t, scraperType.String(), scraper.ID().String()) } func TestCreateMetricsScraper_Error(t *testing.T) { diff --git a/receiver/hostmetricsreceiver/internal/scraper/filesystemscraper/factory.go b/receiver/hostmetricsreceiver/internal/scraper/filesystemscraper/factory.go index d88441255705..d375fea7d14f 100644 --- a/receiver/hostmetricsreceiver/internal/scraper/filesystemscraper/factory.go +++ b/receiver/hostmetricsreceiver/internal/scraper/filesystemscraper/factory.go @@ -7,11 +7,11 @@ import ( "context" "os" + "go.opentelemetry.io/collector/component" "go.opentelemetry.io/collector/receiver" "go.opentelemetry.io/collector/receiver/scraperhelper" "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/hostmetricsreceiver/internal" - hostmeta "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/hostmetricsreceiver/internal/metadata" "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/hostmetricsreceiver/internal/scraper/filesystemscraper/internal/metadata" ) @@ -22,6 +22,11 @@ const ( TypeStr = "filesystem" ) +var ( + // scraperType is the component type used for the built scraper. + scraperType component.Type = component.MustNewType(TypeStr) +) + // Factory is the Factory for scraper. type Factory struct { } @@ -70,5 +75,5 @@ func (f *Factory) CreateMetricsScraper( } return scraperhelper.NewScraper( - hostmeta.Type, s.scrape, scraperhelper.WithStart(s.start)) + scraperType, s.scrape, scraperhelper.WithStart(s.start)) } diff --git a/receiver/hostmetricsreceiver/internal/scraper/filesystemscraper/factory_test.go b/receiver/hostmetricsreceiver/internal/scraper/filesystemscraper/factory_test.go index 9ebf3607d2bb..fd64e60ce788 100644 --- a/receiver/hostmetricsreceiver/internal/scraper/filesystemscraper/factory_test.go +++ b/receiver/hostmetricsreceiver/internal/scraper/filesystemscraper/factory_test.go @@ -25,6 +25,7 @@ func TestCreateMetricsScraper(t *testing.T) { assert.NoError(t, err) assert.NotNil(t, scraper) + assert.Equal(t, scraperType.String(), scraper.ID().String()) } func TestCreateMetricsScraper_Error(t *testing.T) { diff --git a/receiver/hostmetricsreceiver/internal/scraper/loadscraper/factory.go b/receiver/hostmetricsreceiver/internal/scraper/loadscraper/factory.go index 6466cd5d730e..bdfc2ca9ecaf 100644 --- a/receiver/hostmetricsreceiver/internal/scraper/loadscraper/factory.go +++ b/receiver/hostmetricsreceiver/internal/scraper/loadscraper/factory.go @@ -6,11 +6,11 @@ package loadscraper // import "github.com/open-telemetry/opentelemetry-collector import ( "context" + "go.opentelemetry.io/collector/component" "go.opentelemetry.io/collector/receiver" "go.opentelemetry.io/collector/receiver/scraperhelper" "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/hostmetricsreceiver/internal" - hostmeta "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/hostmetricsreceiver/internal/metadata" "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/hostmetricsreceiver/internal/scraper/loadscraper/internal/metadata" ) @@ -21,6 +21,11 @@ const ( TypeStr = "load" ) +var ( + // scraperType is the component type used for the built scraper. + scraperType component.Type = component.MustNewType(TypeStr) +) + // Factory is the Factory for scraper. type Factory struct { } @@ -42,7 +47,7 @@ func (f *Factory) CreateMetricsScraper( s := newLoadScraper(ctx, settings, cfg) return scraperhelper.NewScraper( - hostmeta.Type, + scraperType, s.scrape, scraperhelper.WithStart(s.start), scraperhelper.WithShutdown(s.shutdown), diff --git a/receiver/hostmetricsreceiver/internal/scraper/loadscraper/factory_test.go b/receiver/hostmetricsreceiver/internal/scraper/loadscraper/factory_test.go index ad97f8eaf5fb..e52b2eb36f04 100644 --- a/receiver/hostmetricsreceiver/internal/scraper/loadscraper/factory_test.go +++ b/receiver/hostmetricsreceiver/internal/scraper/loadscraper/factory_test.go @@ -25,4 +25,5 @@ func TestCreateMetricsScraper(t *testing.T) { assert.NoError(t, err) assert.NotNil(t, scraper) + assert.Equal(t, scraperType.String(), scraper.ID().String()) } diff --git a/receiver/hostmetricsreceiver/internal/scraper/memoryscraper/factory.go b/receiver/hostmetricsreceiver/internal/scraper/memoryscraper/factory.go index bfc3566db6e0..2a43b921720b 100644 --- a/receiver/hostmetricsreceiver/internal/scraper/memoryscraper/factory.go +++ b/receiver/hostmetricsreceiver/internal/scraper/memoryscraper/factory.go @@ -6,11 +6,11 @@ package memoryscraper // import "github.com/open-telemetry/opentelemetry-collect import ( "context" + "go.opentelemetry.io/collector/component" "go.opentelemetry.io/collector/receiver" "go.opentelemetry.io/collector/receiver/scraperhelper" "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/hostmetricsreceiver/internal" - hostmeta "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/hostmetricsreceiver/internal/metadata" "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/hostmetricsreceiver/internal/scraper/memoryscraper/internal/metadata" ) @@ -21,6 +21,11 @@ const ( TypeStr = "memory" ) +var ( + // scraperType is the component type used for the built scraper. + scraperType component.Type = component.MustNewType(TypeStr) +) + // Factory is the Factory for scraper. type Factory struct { } @@ -42,5 +47,5 @@ func (f *Factory) CreateMetricsScraper( s := newMemoryScraper(ctx, settings, cfg) return scraperhelper.NewScraper( - hostmeta.Type, s.scrape, scraperhelper.WithStart(s.start)) + scraperType, s.scrape, scraperhelper.WithStart(s.start)) } diff --git a/receiver/hostmetricsreceiver/internal/scraper/memoryscraper/factory_test.go b/receiver/hostmetricsreceiver/internal/scraper/memoryscraper/factory_test.go index 69cd9c6a913f..0cf3910e89ad 100644 --- a/receiver/hostmetricsreceiver/internal/scraper/memoryscraper/factory_test.go +++ b/receiver/hostmetricsreceiver/internal/scraper/memoryscraper/factory_test.go @@ -25,4 +25,5 @@ func TestCreateMetricsScraper(t *testing.T) { assert.NoError(t, err) assert.NotNil(t, scraper) + assert.Equal(t, scraperType.String(), scraper.ID().String()) } diff --git a/receiver/hostmetricsreceiver/internal/scraper/networkscraper/factory.go b/receiver/hostmetricsreceiver/internal/scraper/networkscraper/factory.go index e90f16c77d4b..a9fe64109e63 100644 --- a/receiver/hostmetricsreceiver/internal/scraper/networkscraper/factory.go +++ b/receiver/hostmetricsreceiver/internal/scraper/networkscraper/factory.go @@ -6,11 +6,11 @@ package networkscraper // import "github.com/open-telemetry/opentelemetry-collec import ( "context" + "go.opentelemetry.io/collector/component" "go.opentelemetry.io/collector/receiver" "go.opentelemetry.io/collector/receiver/scraperhelper" "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/hostmetricsreceiver/internal" - hostmeta "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/hostmetricsreceiver/internal/metadata" "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/hostmetricsreceiver/internal/scraper/networkscraper/internal/metadata" ) @@ -21,6 +21,11 @@ const ( TypeStr = "network" ) +var ( + // scraperType is the component type used for the built scraper. + scraperType component.Type = component.MustNewType(TypeStr) +) + // Factory is the Factory for scraper. type Factory struct { } @@ -45,7 +50,7 @@ func (f *Factory) CreateMetricsScraper( } return scraperhelper.NewScraper( - hostmeta.Type, + scraperType, s.scrape, scraperhelper.WithStart(s.start), ) diff --git a/receiver/hostmetricsreceiver/internal/scraper/networkscraper/factory_test.go b/receiver/hostmetricsreceiver/internal/scraper/networkscraper/factory_test.go index 47aec7c3afb8..0df4552ba1cc 100644 --- a/receiver/hostmetricsreceiver/internal/scraper/networkscraper/factory_test.go +++ b/receiver/hostmetricsreceiver/internal/scraper/networkscraper/factory_test.go @@ -25,6 +25,7 @@ func TestCreateMetricsScraper(t *testing.T) { assert.NoError(t, err) assert.NotNil(t, scraper) + assert.Equal(t, scraperType.String(), scraper.ID().String()) } func TestCreateMetricsScraper_Error(t *testing.T) { diff --git a/receiver/hostmetricsreceiver/internal/scraper/pagingscraper/factory.go b/receiver/hostmetricsreceiver/internal/scraper/pagingscraper/factory.go index 3f435327083a..588f9b4a655b 100644 --- a/receiver/hostmetricsreceiver/internal/scraper/pagingscraper/factory.go +++ b/receiver/hostmetricsreceiver/internal/scraper/pagingscraper/factory.go @@ -6,11 +6,11 @@ package pagingscraper // import "github.com/open-telemetry/opentelemetry-collect import ( "context" + "go.opentelemetry.io/collector/component" "go.opentelemetry.io/collector/receiver" "go.opentelemetry.io/collector/receiver/scraperhelper" "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/hostmetricsreceiver/internal" - hostmeta "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/hostmetricsreceiver/internal/metadata" "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/hostmetricsreceiver/internal/scraper/pagingscraper/internal/metadata" ) @@ -21,6 +21,11 @@ const ( TypeStr = "paging" ) +var ( + // scraperType is the component type used for the built scraper. + scraperType component.Type = component.MustNewType(TypeStr) +) + // Factory is the Factory for scraper. type Factory struct { } @@ -42,7 +47,7 @@ func (f *Factory) CreateMetricsScraper( s := newPagingScraper(ctx, settings, cfg) return scraperhelper.NewScraper( - hostmeta.Type, + scraperType, s.scrape, scraperhelper.WithStart(s.start), ) diff --git a/receiver/hostmetricsreceiver/internal/scraper/pagingscraper/factory_test.go b/receiver/hostmetricsreceiver/internal/scraper/pagingscraper/factory_test.go index aebbf39a87c8..1934b1de6089 100644 --- a/receiver/hostmetricsreceiver/internal/scraper/pagingscraper/factory_test.go +++ b/receiver/hostmetricsreceiver/internal/scraper/pagingscraper/factory_test.go @@ -24,4 +24,5 @@ func TestCreateMetricsScraper(t *testing.T) { scraper, err := factory.CreateMetricsScraper(context.Background(), receivertest.NewNopSettings(), cfg) assert.NoError(t, err) assert.NotNil(t, scraper) + assert.Equal(t, scraperType.String(), scraper.ID().String()) } diff --git a/receiver/hostmetricsreceiver/internal/scraper/processesscraper/factory.go b/receiver/hostmetricsreceiver/internal/scraper/processesscraper/factory.go index 8db31ac8e946..256961a86f03 100644 --- a/receiver/hostmetricsreceiver/internal/scraper/processesscraper/factory.go +++ b/receiver/hostmetricsreceiver/internal/scraper/processesscraper/factory.go @@ -6,11 +6,11 @@ package processesscraper // import "github.com/open-telemetry/opentelemetry-coll import ( "context" + "go.opentelemetry.io/collector/component" "go.opentelemetry.io/collector/receiver" "go.opentelemetry.io/collector/receiver/scraperhelper" "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/hostmetricsreceiver/internal" - hostmeta "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/hostmetricsreceiver/internal/metadata" "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/hostmetricsreceiver/internal/scraper/processesscraper/internal/metadata" ) @@ -21,6 +21,11 @@ const ( TypeStr = "processes" ) +var ( + // scraperType is the component type used for the built scraper. + scraperType component.Type = component.MustNewType(TypeStr) +) + // Factory is the Factory for scraper. type Factory struct { } @@ -42,7 +47,7 @@ func (f *Factory) CreateMetricsScraper( s := newProcessesScraper(ctx, settings, cfg) return scraperhelper.NewScraper( - hostmeta.Type, + scraperType, s.scrape, scraperhelper.WithStart(s.start), ) diff --git a/receiver/hostmetricsreceiver/internal/scraper/processesscraper/factory_test.go b/receiver/hostmetricsreceiver/internal/scraper/processesscraper/factory_test.go index 919e34b88088..5ef1585a0618 100644 --- a/receiver/hostmetricsreceiver/internal/scraper/processesscraper/factory_test.go +++ b/receiver/hostmetricsreceiver/internal/scraper/processesscraper/factory_test.go @@ -25,4 +25,5 @@ func TestCreateMetricsScraper(t *testing.T) { assert.NoError(t, err) assert.NotNil(t, scraper) + assert.Equal(t, scraperType.String(), scraper.ID().String()) } diff --git a/receiver/hostmetricsreceiver/internal/scraper/processscraper/factory.go b/receiver/hostmetricsreceiver/internal/scraper/processscraper/factory.go index 941a39e57214..8aeccf9af8b2 100644 --- a/receiver/hostmetricsreceiver/internal/scraper/processscraper/factory.go +++ b/receiver/hostmetricsreceiver/internal/scraper/processscraper/factory.go @@ -8,12 +8,12 @@ import ( "errors" "runtime" + "go.opentelemetry.io/collector/component" "go.opentelemetry.io/collector/featuregate" "go.opentelemetry.io/collector/receiver" "go.opentelemetry.io/collector/receiver/scraperhelper" "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/hostmetricsreceiver/internal" - hostmeta "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/hostmetricsreceiver/internal/metadata" "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/hostmetricsreceiver/internal/scraper/processscraper/internal/metadata" ) @@ -24,6 +24,11 @@ const ( TypeStr = "process" ) +var ( + // scraperType is the component type used for the built scraper. + scraperType component.Type = component.MustNewType(TypeStr) +) + var ( bootTimeCacheFeaturegateID = "hostmetrics.process.bootTimeCache" bootTimeCacheFeaturegate = featuregate.GlobalRegistry().MustRegister( @@ -62,7 +67,7 @@ func (f *Factory) CreateMetricsScraper( } return scraperhelper.NewScraper( - hostmeta.Type, + scraperType, s.scrape, scraperhelper.WithStart(s.start), ) diff --git a/receiver/hostmetricsreceiver/internal/scraper/processscraper/factory_test.go b/receiver/hostmetricsreceiver/internal/scraper/processscraper/factory_test.go index 0462bc313caa..1b030df19818 100644 --- a/receiver/hostmetricsreceiver/internal/scraper/processscraper/factory_test.go +++ b/receiver/hostmetricsreceiver/internal/scraper/processscraper/factory_test.go @@ -27,6 +27,7 @@ func TestCreateResourceMetricsScraper(t *testing.T) { if runtime.GOOS == "linux" || runtime.GOOS == "windows" || runtime.GOOS == "darwin" { assert.NoError(t, err) assert.NotNil(t, scraper) + assert.Equal(t, scraperType.String(), scraper.ID().String()) } else { assert.Error(t, err) assert.Nil(t, scraper)