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

[receiver/postgresql] Transition receiver/postgresql to resource attributes by default #13812

Merged
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
10 changes: 6 additions & 4 deletions receiver/postgresqlreceiver/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,11 @@ func TestPostgreSQLIntegration(t *testing.T) {
expectedFile: filepath.Join("testdata", "integration", "expected_all_db.json"),
},
{
name: "with_resource_attributes",
name: "without_resource_attributes",
cfg: func(hostname string) *Config {
require.NoError(t, featuregate.GetRegistry().Apply(map[string]bool{
emitMetricsWithResourceAttributesFeatureGateID: true,
emitMetricsWithResourceAttributesFeatureGateID: false,
emitMetricsWithoutResourceAttributesFeatureGateID: true,
}))
f := NewFactory()
cfg := f.CreateDefaultConfig().(*Config)
Expand All @@ -109,10 +110,11 @@ func TestPostgreSQLIntegration(t *testing.T) {
},
cleanup: func() {
require.NoError(t, featuregate.GetRegistry().Apply(map[string]bool{
emitMetricsWithResourceAttributesFeatureGateID: false,
emitMetricsWithResourceAttributesFeatureGateID: true,
emitMetricsWithoutResourceAttributesFeatureGateID: false,
}))
},
expectedFile: filepath.Join("testdata", "integration", "expected_all_with_resource_attributes.json"),
expectedFile: filepath.Join("testdata", "integration", "expected_all_without_resource_attributes.json"),
},
}

Expand Down
4 changes: 2 additions & 2 deletions receiver/postgresqlreceiver/scraper.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const (
var (
emitMetricsWithoutResourceAttributes = featuregate.Gate{
ID: emitMetricsWithoutResourceAttributesFeatureGateID,
Enabled: true,
Enabled: false,
Description: "Postgresql metrics are transitioning from being reported with identifying metric attributes " +
"to being identified via resource attributes in order to fit the OpenTelemetry specification. This feature " +
"gate controls emitting the old metrics without resource attributes. For more details, see: " +
Expand All @@ -48,7 +48,7 @@ var (

emitMetricsWithResourceAttributes = featuregate.Gate{
ID: emitMetricsWithResourceAttributesFeatureGateID,
Enabled: false,
Enabled: true,
Description: "Postgresql metrics are transitioning from being reported with identifying metric attributes " +
"to being identified via resource attributes in order to fit the OpenTelemetry specification. This feature " +
"gate controls emitting the new metrics with resource attributes. For more details, see: " +
Expand Down
13 changes: 9 additions & 4 deletions receiver/postgresqlreceiver/scraper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ func TestUnsuccessfulScrape(t *testing.T) {
cfg.Endpoint = "fake:11111"

scraper := newPostgreSQLScraper(componenttest.NewNopReceiverCreateSettings(), cfg, &defaultClientFactory{})
scraper.emitMetricsWithResourceAttributes = false
scraper.emitMetricsWithoutResourceAttributes = true

actualMetrics, err := scraper.scrape(context.Background())
require.Error(t, err)

Expand All @@ -48,6 +51,8 @@ func TestScraper(t *testing.T) {
cfg := createDefaultConfig().(*Config)
cfg.Databases = []string{"otel"}
scraper := newPostgreSQLScraper(componenttest.NewNopReceiverCreateSettings(), cfg, factory)
scraper.emitMetricsWithResourceAttributes = false
scraper.emitMetricsWithoutResourceAttributes = true

actualMetrics, err := scraper.scrape(context.Background())
require.NoError(t, err)
Expand All @@ -65,6 +70,8 @@ func TestScraperNoDatabaseSingle(t *testing.T) {

cfg := createDefaultConfig().(*Config)
scraper := newPostgreSQLScraper(componenttest.NewNopReceiverCreateSettings(), cfg, factory)
scraper.emitMetricsWithResourceAttributes = false
scraper.emitMetricsWithoutResourceAttributes = true

actualMetrics, err := scraper.scrape(context.Background())
require.NoError(t, err)
Expand All @@ -82,6 +89,8 @@ func TestScraperNoDatabaseMultiple(t *testing.T) {

cfg := createDefaultConfig().(*Config)
scraper := newPostgreSQLScraper(componenttest.NewNopReceiverCreateSettings(), cfg, &factory)
scraper.emitMetricsWithResourceAttributes = false
scraper.emitMetricsWithoutResourceAttributes = true

actualMetrics, err := scraper.scrape(context.Background())
require.NoError(t, err)
Expand All @@ -99,8 +108,6 @@ func TestScraperWithResourceAttributeFeatureGate(t *testing.T) {

cfg := createDefaultConfig().(*Config)
scraper := newPostgreSQLScraper(componenttest.NewNopReceiverCreateSettings(), cfg, &factory)
scraper.emitMetricsWithResourceAttributes = true
scraper.emitMetricsWithoutResourceAttributes = false

actualMetrics, err := scraper.scrape(context.Background())
require.NoError(t, err)
Expand All @@ -118,8 +125,6 @@ func TestScraperWithResourceAttributeFeatureGateSingle(t *testing.T) {

cfg := createDefaultConfig().(*Config)
scraper := newPostgreSQLScraper(componenttest.NewNopReceiverCreateSettings(), cfg, &factory)
scraper.emitMetricsWithResourceAttributes = true
scraper.emitMetricsWithoutResourceAttributes = false

actualMetrics, err := scraper.scrape(context.Background())
require.NoError(t, err)
Expand Down
Loading