Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[chore] updating scrapers to use default method from scraperhelper #22138

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .chloggen/msg_ensure-standardised-collector-intervals.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Use this changelog template to create an entry for release notes.
# If your change doesn't affect end users, such as a test fix or a tooling change,
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.

# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: breaking
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this still a breaking change?

If I understand correctly, the change in components' behavior is that they start scraping after 1 second and not after their default collection interval, is this right? In that case, I believe we should call it out in the release notes (using the subtext below?).

Copy link
Contributor Author

@MovieStoreGuy MovieStoreGuy May 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏽 , that makes sense but at this point this is a transparent change until the upstream is merged.

However, I think this missed the v0.78.0 release so we have time to fix this up.
I can correct it in the next release with more details.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I understand correctly, the change in components' behavior is that they start scraping after 1 second and not after their default collection interval, is this right?

This comment of mine is actually incorrect 🙂 Not until the core PR gets merged:

Looking at this PR again in detail, it wasn't (meant as) a breaking change, rather a refactoring. The only (accidental, I suppose) breaking change is that the Apache receiver's default collection interval has changed from 10s to 60s. This should probably be fixed in a future PR.


# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
component: receivers

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Updating receivers that run intervals to use standard interval by default

# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
issues: [22138]

# (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:
8 changes: 4 additions & 4 deletions receiver/activedirectorydsreceiver/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ func NewFactory() receiver.Factory {
}

func createDefaultConfig() component.Config {
cfg := scraperhelper.NewDefaultScraperControllerSettings(metadata.Type)
cfg.CollectionInterval = defaultCollectionInterval
return &Config{
ScraperControllerSettings: scraperhelper.ScraperControllerSettings{
CollectionInterval: defaultCollectionInterval,
},
MetricsBuilderConfig: metadata.DefaultMetricsBuilderConfig(),
ScraperControllerSettings: cfg,
MetricsBuilderConfig: metadata.DefaultMetricsBuilderConfig(),
}
}
12 changes: 5 additions & 7 deletions receiver/aerospikereceiver/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,10 @@ func createMetricsReceiver(

func createDefaultConfig() component.Config {
return &Config{
ScraperControllerSettings: scraperhelper.ScraperControllerSettings{
CollectionInterval: time.Minute,
},
Endpoint: defaultEndpoint,
Timeout: defaultTimeout,
CollectClusterMetrics: defaultCollectClusterMetrics,
MetricsBuilderConfig: metadata.DefaultMetricsBuilderConfig(),
ScraperControllerSettings: scraperhelper.NewDefaultScraperControllerSettings(metadata.Type),
Endpoint: defaultEndpoint,
Timeout: defaultTimeout,
CollectClusterMetrics: defaultCollectClusterMetrics,
MetricsBuilderConfig: metadata.DefaultMetricsBuilderConfig(),
}
}
4 changes: 1 addition & 3 deletions receiver/apachereceiver/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ func NewFactory() receiver.Factory {

func createDefaultConfig() component.Config {
return &Config{
ScraperControllerSettings: scraperhelper.ScraperControllerSettings{
CollectionInterval: 10 * time.Second,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this was missed and effectively the Apache receiver's default collection interval has changed from 10s to 60s?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shit, I can revert in a follow up PR.

},
ScraperControllerSettings: scraperhelper.NewDefaultScraperControllerSettings(metadata.Type),
HTTPClientSettings: confighttp.HTTPClientSettings{
Endpoint: defaultEndpoint,
Timeout: 10 * time.Second,
Expand Down
7 changes: 4 additions & 3 deletions receiver/apachesparkreceiver/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,11 @@ func NewFactory() receiver.Factory {

// createDefaultConfig creates a config for Spark with as many default values as possible
func createDefaultConfig() component.Config {
cfg := scraperhelper.NewDefaultScraperControllerSettings(metadata.Type)
cfg.CollectionInterval = defaultCollectionInterval

return &Config{
ScraperControllerSettings: scraperhelper.ScraperControllerSettings{
CollectionInterval: defaultCollectionInterval,
},
ScraperControllerSettings: cfg,
HTTPClientSettings: confighttp.HTTPClientSettings{
Endpoint: defaultEndpoint,
},
Expand Down
11 changes: 8 additions & 3 deletions receiver/azuremonitorreceiver/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ import (
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/azuremonitorreceiver/internal/metadata"
)

const (
defaultCollectionInterval = 10 * time.Second
)

var errConfigNotAzureMonitor = errors.New("Config was not a Azure Monitor receiver config")

// NewFactory creates a new receiver factory
Expand All @@ -27,10 +31,11 @@ func NewFactory() receiver.Factory {
}

func createDefaultConfig() component.Config {
cfg := scraperhelper.NewDefaultScraperControllerSettings(metadata.Type)
cfg.CollectionInterval = defaultCollectionInterval

return &Config{
ScraperControllerSettings: scraperhelper.ScraperControllerSettings{
CollectionInterval: 10 * time.Second,
},
ScraperControllerSettings: cfg,
MetricsBuilderConfig: metadata.DefaultMetricsBuilderConfig(),
CacheResources: 24 * 60 * 60,
CacheResourcesDefinitions: 24 * 60 * 60,
Expand Down
6 changes: 2 additions & 4 deletions receiver/couchdbreceiver/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,8 @@ func NewFactory() receiver.Factory {

func createDefaultConfig() component.Config {
return &Config{
MetricsBuilderConfig: metadata.DefaultMetricsBuilderConfig(),
ScraperControllerSettings: scraperhelper.ScraperControllerSettings{
CollectionInterval: 1 * time.Minute,
},
MetricsBuilderConfig: metadata.DefaultMetricsBuilderConfig(),
ScraperControllerSettings: scraperhelper.NewDefaultScraperControllerSettings(metadata.Type),
HTTPClientSettings: confighttp.HTTPClientSettings{
TLSSetting: configtls.TLSClientSetting{},
Endpoint: defaultEndpoint,
Expand Down
7 changes: 4 additions & 3 deletions receiver/elasticsearchreceiver/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,11 @@ func NewFactory() receiver.Factory {

// createDefaultConfig creates the default elasticsearchreceiver config.
func createDefaultConfig() component.Config {
cfg := scraperhelper.NewDefaultScraperControllerSettings(metadata.Type)
cfg.CollectionInterval = defaultCollectionInterval

return &Config{
ScraperControllerSettings: scraperhelper.ScraperControllerSettings{
CollectionInterval: defaultCollectionInterval,
},
ScraperControllerSettings: cfg,
HTTPClientSettings: confighttp.HTTPClientSettings{
Endpoint: defaultEndpoint,
Timeout: defaultHTTPClientTimeout,
Expand Down
7 changes: 2 additions & 5 deletions receiver/filestatsreceiver/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ package filestatsreceiver // import "github.com/open-telemetry/opentelemetry-col

import (
"context"
"time"

"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/consumer"
Expand All @@ -25,10 +24,8 @@ func NewFactory() receiver.Factory {

func newDefaultConfig() component.Config {
return &Config{
ScraperControllerSettings: scraperhelper.ScraperControllerSettings{
CollectionInterval: 1 * time.Minute,
},
MetricsBuilderConfig: metadata.DefaultMetricsBuilderConfig(),
ScraperControllerSettings: scraperhelper.NewDefaultScraperControllerSettings(metadata.Type),
MetricsBuilderConfig: metadata.DefaultMetricsBuilderConfig(),
}
}

Expand Down
7 changes: 4 additions & 3 deletions receiver/flinkmetricsreceiver/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@ func NewFactory() receiver.Factory {
}

func createDefaultConfig() component.Config {
cfg := scraperhelper.NewDefaultScraperControllerSettings(metadata.Type)
cfg.CollectionInterval = 10 * time.Second

return &Config{
ScraperControllerSettings: scraperhelper.ScraperControllerSettings{
CollectionInterval: 10 * time.Second,
},
ScraperControllerSettings: cfg,
HTTPClientSettings: confighttp.HTTPClientSettings{
Endpoint: defaultEndpoint,
Timeout: 10 * time.Second,
Expand Down
4 changes: 1 addition & 3 deletions receiver/googlecloudspannerreceiver/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@ func NewFactory() receiver.Factory {

func createDefaultConfig() component.Config {
return &Config{
ScraperControllerSettings: scraperhelper.ScraperControllerSettings{
CollectionInterval: defaultCollectionInterval,
},
ScraperControllerSettings: scraperhelper.NewDefaultScraperControllerSettings(metadata.Type),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The defaultCollectionInterval const defined above is now left unused. This could trick someone trying to change it and seeing no effect. We should remove that const.

TopMetricsQueryMaxRows: defaultTopMetricsQueryMaxRows,
BackfillEnabled: defaultBackfillEnabled,
HideTopnLockstatsRowrangestartkey: defaultHideTopnLockstatsRowrangestartkey,
Expand Down
7 changes: 2 additions & 5 deletions receiver/haproxyreceiver/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ package haproxyreceiver // import "github.com/open-telemetry/opentelemetry-colle

import (
"context"
"time"

"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/consumer"
Expand All @@ -25,10 +24,8 @@ func NewFactory() receiver.Factory {

func newDefaultConfig() component.Config {
return &Config{
ScraperControllerSettings: scraperhelper.ScraperControllerSettings{
CollectionInterval: 1 * time.Minute,
},
MetricsBuilderConfig: metadata.DefaultMetricsBuilderConfig(),
ScraperControllerSettings: scraperhelper.NewDefaultScraperControllerSettings(metadata.Type),
MetricsBuilderConfig: metadata.DefaultMetricsBuilderConfig(),
}
}

Expand Down
7 changes: 4 additions & 3 deletions receiver/httpcheckreceiver/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,11 @@ func NewFactory() receiver.Factory {
}

func createDefaultConfig() component.Config {
cfg := scraperhelper.NewDefaultScraperControllerSettings(metadata.Type)
cfg.CollectionInterval = 10 * time.Second

return &Config{
ScraperControllerSettings: scraperhelper.ScraperControllerSettings{
CollectionInterval: 10 * time.Second,
},
ScraperControllerSettings: cfg,
HTTPClientSettings: confighttp.HTTPClientSettings{
Endpoint: defaultEndpoint,
Timeout: 10 * time.Second,
Expand Down
8 changes: 2 additions & 6 deletions receiver/iisreceiver/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
package iisreceiver // import "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/iisreceiver"

import (
"time"

"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/receiver"
"go.opentelemetry.io/collector/receiver/scraperhelper"
Expand All @@ -23,9 +21,7 @@ func NewFactory() receiver.Factory {

func createDefaultConfig() component.Config {
return &Config{
ScraperControllerSettings: scraperhelper.ScraperControllerSettings{
CollectionInterval: time.Minute,
},
MetricsBuilderConfig: metadata.DefaultMetricsBuilderConfig(),
ScraperControllerSettings: scraperhelper.NewDefaultScraperControllerSettings(metadata.Type),
MetricsBuilderConfig: metadata.DefaultMetricsBuilderConfig(),
}
}
9 changes: 5 additions & 4 deletions receiver/memcachedreceiver/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,12 @@ func NewFactory() receiver.Factory {
}

func createDefaultConfig() component.Config {
cfg := scraperhelper.NewDefaultScraperControllerSettings(metadata.Type)
cfg.CollectionInterval = defaultCollectionInterval

return &Config{
ScraperControllerSettings: scraperhelper.ScraperControllerSettings{
CollectionInterval: defaultCollectionInterval,
},
Timeout: defaultTimeout,
ScraperControllerSettings: cfg,
Timeout: defaultTimeout,
NetAddr: confignet.NetAddr{
Endpoint: defaultEndpoint,
},
Expand Down
6 changes: 2 additions & 4 deletions receiver/mongodbreceiver/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,8 @@ func NewFactory() receiver.Factory {

func createDefaultConfig() component.Config {
return &Config{
ScraperControllerSettings: scraperhelper.ScraperControllerSettings{
CollectionInterval: time.Minute,
},
Timeout: time.Minute,
ScraperControllerSettings: scraperhelper.NewDefaultScraperControllerSettings(metadata.Type),
Timeout: time.Minute,
Hosts: []confignet.NetAddr{
{
Endpoint: "localhost:27017",
Expand Down
10 changes: 5 additions & 5 deletions receiver/mysqlreceiver/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ func NewFactory() receiver.Factory {
}

func createDefaultConfig() component.Config {
cfg := scraperhelper.NewDefaultScraperControllerSettings(metadata.Type)
cfg.CollectionInterval = 10 * time.Second
return &Config{
ScraperControllerSettings: scraperhelper.ScraperControllerSettings{
CollectionInterval: 10 * time.Second,
},
AllowNativePasswords: true,
Username: "root",
ScraperControllerSettings: cfg,
AllowNativePasswords: true,
Username: "root",
NetAddr: confignet.NetAddr{
Endpoint: "localhost:3306",
Transport: "tcp",
Expand Down
7 changes: 4 additions & 3 deletions receiver/nginxreceiver/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,11 @@ func NewFactory() receiver.Factory {
}

func createDefaultConfig() component.Config {
cfg := scraperhelper.NewDefaultScraperControllerSettings(metadata.Type)
cfg.CollectionInterval = 10 * time.Second

return &Config{
ScraperControllerSettings: scraperhelper.ScraperControllerSettings{
CollectionInterval: 10 * time.Second,
},
ScraperControllerSettings: cfg,
HTTPClientSettings: confighttp.HTTPClientSettings{
Endpoint: "http://localhost:80/status",
Timeout: 10 * time.Second,
Expand Down
7 changes: 2 additions & 5 deletions receiver/nsxtreceiver/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ package nsxtreceiver // import "github.com/open-telemetry/opentelemetry-collecto
import (
"context"
"errors"
"time"

"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/consumer"
Expand All @@ -29,10 +28,8 @@ func NewFactory() receiver.Factory {

func createDefaultConfig() component.Config {
return &Config{
ScraperControllerSettings: scraperhelper.ScraperControllerSettings{
CollectionInterval: time.Minute,
},
MetricsBuilderConfig: metadata.DefaultMetricsBuilderConfig(),
ScraperControllerSettings: scraperhelper.NewDefaultScraperControllerSettings(metadata.Type),
MetricsBuilderConfig: metadata.DefaultMetricsBuilderConfig(),
}
}

Expand Down
9 changes: 5 additions & 4 deletions receiver/oracledbreceiver/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,12 @@ func NewFactory() receiver.Factory {
}

func createDefaultConfig() component.Config {
cfg := scraperhelper.NewDefaultScraperControllerSettings(metadata.Type)
cfg.CollectionInterval = 10 * time.Second

return &Config{
ScraperControllerSettings: scraperhelper.ScraperControllerSettings{
CollectionInterval: 10 * time.Second,
},
MetricsBuilderConfig: metadata.DefaultMetricsBuilderConfig(),
ScraperControllerSettings: cfg,
MetricsBuilderConfig: metadata.DefaultMetricsBuilderConfig(),
}
}

Expand Down
13 changes: 7 additions & 6 deletions receiver/podmanreceiver/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,14 @@ func NewFactory() rcvr.Factory {
}

func createDefaultConfig() *Config {
cfg := scraperhelper.NewDefaultScraperControllerSettings(metadata.Type)
cfg.CollectionInterval = 10 * time.Second

return &Config{
ScraperControllerSettings: scraperhelper.ScraperControllerSettings{
CollectionInterval: 10 * time.Second,
},
Endpoint: "unix:///run/podman/podman.sock",
Timeout: 5 * time.Second,
APIVersion: defaultAPIVersion,
ScraperControllerSettings: cfg,
Endpoint: "unix:///run/podman/podman.sock",
Timeout: 5 * time.Second,
APIVersion: defaultAPIVersion,
}
}

Expand Down
7 changes: 4 additions & 3 deletions receiver/postgresqlreceiver/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@ func NewFactory() receiver.Factory {
}

func createDefaultConfig() component.Config {
cfg := scraperhelper.NewDefaultScraperControllerSettings(metadata.Type)
cfg.CollectionInterval = 10 * time.Second

return &Config{
ScraperControllerSettings: scraperhelper.ScraperControllerSettings{
CollectionInterval: 10 * time.Second,
},
ScraperControllerSettings: cfg,
NetAddr: confignet.NetAddr{
Endpoint: "localhost:5432",
Transport: "tcp",
Expand Down
7 changes: 4 additions & 3 deletions receiver/rabbitmqreceiver/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,11 @@ func NewFactory() receiver.Factory {
}

func createDefaultConfig() component.Config {
cfg := scraperhelper.NewDefaultScraperControllerSettings(metadata.Type)
cfg.CollectionInterval = 10 * time.Second

return &Config{
ScraperControllerSettings: scraperhelper.ScraperControllerSettings{
CollectionInterval: 10 * time.Second,
},
ScraperControllerSettings: cfg,
HTTPClientSettings: confighttp.HTTPClientSettings{
Endpoint: defaultEndpoint,
Timeout: 10 * time.Second,
Expand Down
Loading