Skip to content

Commit

Permalink
[receiver/postgresql] Bump postgresqlreceiver.preciselagmetrics gate …
Browse files Browse the repository at this point in the history
…to beta (#31220)
  • Loading branch information
djaglowski authored Mar 25, 2024
1 parent 011256c commit 3a8275e
Show file tree
Hide file tree
Showing 20 changed files with 1,580 additions and 1,679 deletions.
28 changes: 28 additions & 0 deletions .chloggen/featuregate-postgresql-lag.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Use this changelog template to create an entry for release notes.

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

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

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Bump postgresqlreceiver.preciselagmetrics gate to beta


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

# (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: []
2 changes: 1 addition & 1 deletion receiver/postgresqlreceiver/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const lagMetricsInSecondsFeatureGateID = "postgresqlreceiver.preciselagmetrics"

var preciseLagMetricsFg = featuregate.GlobalRegistry().MustRegister(
lagMetricsInSecondsFeatureGateID,
featuregate.StageAlpha,
featuregate.StageBeta,
featuregate.WithRegisterDescription("Metric `postgresql.wal.lag` is replaced by more precise `postgresql.wal.delay`."),
featuregate.WithRegisterFromVersion("0.89.0"),
)
Expand Down
1 change: 1 addition & 0 deletions receiver/postgresqlreceiver/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ func integrationTest(name string, databases []string) func(*testing.T) {
rCfg.Username = "otelu"
rCfg.Password = "otelp"
rCfg.Insecure = true
rCfg.Metrics.PostgresqlWalDelay.Enabled = true
rCfg.Metrics.PostgresqlDeadlocks.Enabled = true
rCfg.Metrics.PostgresqlTempFiles.Enabled = true
rCfg.Metrics.PostgresqlSequentialScans.Enabled = true
Expand Down
76 changes: 47 additions & 29 deletions receiver/postgresqlreceiver/scraper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ func TestScraper(t *testing.T) {

cfg := createDefaultConfig().(*Config)
cfg.Databases = []string{"otel"}
cfg.Metrics.PostgresqlWalDelay.Enabled = true
cfg.Metrics.PostgresqlDeadlocks.Enabled = true
cfg.Metrics.PostgresqlTempFiles.Enabled = true
cfg.Metrics.PostgresqlSequentialScans.Enabled = true
Expand Down Expand Up @@ -71,13 +72,17 @@ func TestScraperNoDatabaseSingle(t *testing.T) {
defer testutil.SetFeatureGateForTest(t, separateSchemaAttrGate, separateSchemaAttr)()

cfg := createDefaultConfig().(*Config)
require.True(t, cfg.Metrics.PostgresqlDeadlocks.Enabled == false)

// Validate expected default config values and then enable all metrics
require.False(t, cfg.Metrics.PostgresqlWalDelay.Enabled)
cfg.Metrics.PostgresqlWalDelay.Enabled = true
require.False(t, cfg.Metrics.PostgresqlDeadlocks.Enabled)
cfg.Metrics.PostgresqlDeadlocks.Enabled = true
require.True(t, cfg.Metrics.PostgresqlTempFiles.Enabled == false)
require.False(t, cfg.Metrics.PostgresqlTempFiles.Enabled)
cfg.Metrics.PostgresqlTempFiles.Enabled = true
require.True(t, cfg.Metrics.PostgresqlSequentialScans.Enabled == false)
require.False(t, cfg.Metrics.PostgresqlSequentialScans.Enabled)
cfg.Metrics.PostgresqlSequentialScans.Enabled = true
require.True(t, cfg.Metrics.PostgresqlDatabaseLocks.Enabled == false)
require.False(t, cfg.Metrics.PostgresqlDatabaseLocks.Enabled)
cfg.Metrics.PostgresqlDatabaseLocks.Enabled = true

scraper := newPostgreSQLScraper(receivertest.NewNopCreateSettings(), cfg, factory)
Expand All @@ -91,6 +96,7 @@ func TestScraperNoDatabaseSingle(t *testing.T) {
require.NoError(t, pmetrictest.CompareMetrics(expectedMetrics, actualMetrics, pmetrictest.IgnoreResourceMetricsOrder(),
pmetrictest.IgnoreMetricDataPointsOrder(), pmetrictest.IgnoreStartTimestamp(), pmetrictest.IgnoreTimestamp()))

cfg.Metrics.PostgresqlWalDelay.Enabled = false
cfg.Metrics.PostgresqlDeadlocks.Enabled = false
cfg.Metrics.PostgresqlTempFiles.Enabled = false
cfg.Metrics.PostgresqlSequentialScans.Enabled = false
Expand All @@ -112,21 +118,25 @@ func TestScraperNoDatabaseSingle(t *testing.T) {
runTest(false, "expected.yaml", "expected_default_metrics.yaml")
}

func TestScraperNoDatabaseMultiple(t *testing.T) {
func TestScraperNoDatabaseMultipleWithoutPreciseLag(t *testing.T) {
factory := mockClientFactory{}
factory.initMocks([]string{"otel", "open", "telemetry"})

runTest := func(separateSchemaAttr bool, file string) {
defer testutil.SetFeatureGateForTest(t, separateSchemaAttrGate, separateSchemaAttr)()
defer testutil.SetFeatureGateForTest(t, preciseLagMetricsFg, false)()

cfg := createDefaultConfig().(*Config)
require.True(t, cfg.Metrics.PostgresqlDeadlocks.Enabled == false)

// Validate expected default config values and then enable all metrics except wal delay
require.False(t, cfg.Metrics.PostgresqlWalDelay.Enabled)
require.False(t, cfg.Metrics.PostgresqlDeadlocks.Enabled)
cfg.Metrics.PostgresqlDeadlocks.Enabled = true
require.True(t, cfg.Metrics.PostgresqlTempFiles.Enabled == false)
require.False(t, cfg.Metrics.PostgresqlTempFiles.Enabled)
cfg.Metrics.PostgresqlTempFiles.Enabled = true
require.True(t, cfg.Metrics.PostgresqlSequentialScans.Enabled == false)
require.False(t, cfg.Metrics.PostgresqlSequentialScans.Enabled)
cfg.Metrics.PostgresqlSequentialScans.Enabled = true
require.True(t, cfg.Metrics.PostgresqlDatabaseLocks.Enabled == false)
require.False(t, cfg.Metrics.PostgresqlDatabaseLocks.Enabled)
cfg.Metrics.PostgresqlDatabaseLocks.Enabled = true
scraper := newPostgreSQLScraper(receivertest.NewNopCreateSettings(), cfg, &factory)

Expand All @@ -141,11 +151,11 @@ func TestScraperNoDatabaseMultiple(t *testing.T) {
pmetrictest.IgnoreMetricDataPointsOrder(), pmetrictest.IgnoreStartTimestamp(), pmetrictest.IgnoreTimestamp()))
}

runTest(true, "expected_schemaattr.yaml")
runTest(false, "expected.yaml")
runTest(true, "expected_imprecise_lag_schemaattr.yaml")
runTest(false, "expected_imprecise_lag.yaml")
}

func TestScraperNoDatabaseMultipleWithPreciseLagFeatureGate(t *testing.T) {
func TestScraperNoDatabaseMultiple(t *testing.T) {
factory := mockClientFactory{}
factory.initMocks([]string{"otel", "open", "telemetry"})

Expand All @@ -154,17 +164,16 @@ func TestScraperNoDatabaseMultipleWithPreciseLagFeatureGate(t *testing.T) {

cfg := createDefaultConfig().(*Config)

testutil.SetFeatureGateForTest(t, preciseLagMetricsFg, true)
// Validate expected default config values and then enable all metrics
require.False(t, cfg.Metrics.PostgresqlWalDelay.Enabled)
cfg.Metrics.PostgresqlWalDelay.Enabled = true
defer testutil.SetFeatureGateForTest(t, preciseLagMetricsFg, false)

require.True(t, cfg.Metrics.PostgresqlDeadlocks.Enabled == false)
require.False(t, cfg.Metrics.PostgresqlDeadlocks.Enabled)
cfg.Metrics.PostgresqlDeadlocks.Enabled = true
require.True(t, cfg.Metrics.PostgresqlTempFiles.Enabled == false)
require.False(t, cfg.Metrics.PostgresqlTempFiles.Enabled)
cfg.Metrics.PostgresqlTempFiles.Enabled = true
require.True(t, cfg.Metrics.PostgresqlSequentialScans.Enabled == false)
require.False(t, cfg.Metrics.PostgresqlSequentialScans.Enabled)
cfg.Metrics.PostgresqlSequentialScans.Enabled = true
require.True(t, cfg.Metrics.PostgresqlDatabaseLocks.Enabled == false)
require.False(t, cfg.Metrics.PostgresqlDatabaseLocks.Enabled)
cfg.Metrics.PostgresqlDatabaseLocks.Enabled = true
scraper := newPostgreSQLScraper(receivertest.NewNopCreateSettings(), cfg, &factory)

Expand All @@ -179,8 +188,8 @@ func TestScraperNoDatabaseMultipleWithPreciseLagFeatureGate(t *testing.T) {
pmetrictest.IgnoreMetricDataPointsOrder(), pmetrictest.IgnoreStartTimestamp(), pmetrictest.IgnoreTimestamp()))
}

runTest(true, "expected_precise_lag_schemaattr.yaml")
runTest(false, "expected_precise_lag.yaml")
runTest(true, "expected_schemaattr.yaml")
runTest(false, "expected.yaml")
}

func TestScraperWithResourceAttributeFeatureGate(t *testing.T) {
Expand All @@ -191,14 +200,19 @@ func TestScraperWithResourceAttributeFeatureGate(t *testing.T) {
defer testutil.SetFeatureGateForTest(t, separateSchemaAttrGate, separateSchemaAttr)()

cfg := createDefaultConfig().(*Config)
require.True(t, cfg.Metrics.PostgresqlDeadlocks.Enabled == false)

// Validate expected default config values and then enable all metrics
require.False(t, cfg.Metrics.PostgresqlWalDelay.Enabled)
cfg.Metrics.PostgresqlWalDelay.Enabled = true
require.False(t, cfg.Metrics.PostgresqlDeadlocks.Enabled)
cfg.Metrics.PostgresqlDeadlocks.Enabled = true
require.True(t, cfg.Metrics.PostgresqlTempFiles.Enabled == false)
require.False(t, cfg.Metrics.PostgresqlTempFiles.Enabled)
cfg.Metrics.PostgresqlTempFiles.Enabled = true
require.True(t, cfg.Metrics.PostgresqlSequentialScans.Enabled == false)
require.False(t, cfg.Metrics.PostgresqlSequentialScans.Enabled)
cfg.Metrics.PostgresqlSequentialScans.Enabled = true
require.True(t, cfg.Metrics.PostgresqlDatabaseLocks.Enabled == false)
require.False(t, cfg.Metrics.PostgresqlDatabaseLocks.Enabled)
cfg.Metrics.PostgresqlDatabaseLocks.Enabled = true

scraper := newPostgreSQLScraper(receivertest.NewNopCreateSettings(), cfg, &factory)

actualMetrics, err := scraper.scrape(context.Background())
Expand All @@ -224,13 +238,17 @@ func TestScraperWithResourceAttributeFeatureGateSingle(t *testing.T) {
defer testutil.SetFeatureGateForTest(t, separateSchemaAttrGate, separateSchemaAttr)()

cfg := createDefaultConfig().(*Config)
require.True(t, cfg.Metrics.PostgresqlDeadlocks.Enabled == false)

// Validate expected default config values and then enable all metrics
require.False(t, cfg.Metrics.PostgresqlWalDelay.Enabled)
cfg.Metrics.PostgresqlWalDelay.Enabled = true
require.False(t, cfg.Metrics.PostgresqlDeadlocks.Enabled)
cfg.Metrics.PostgresqlDeadlocks.Enabled = true
require.True(t, cfg.Metrics.PostgresqlTempFiles.Enabled == false)
require.False(t, cfg.Metrics.PostgresqlTempFiles.Enabled)
cfg.Metrics.PostgresqlTempFiles.Enabled = true
require.True(t, cfg.Metrics.PostgresqlSequentialScans.Enabled == false)
require.False(t, cfg.Metrics.PostgresqlSequentialScans.Enabled)
cfg.Metrics.PostgresqlSequentialScans.Enabled = true
require.True(t, cfg.Metrics.PostgresqlDatabaseLocks.Enabled == false)
require.False(t, cfg.Metrics.PostgresqlDatabaseLocks.Enabled)
cfg.Metrics.PostgresqlDatabaseLocks.Enabled = true
scraper := newPostgreSQLScraper(receivertest.NewNopCreateSettings(), cfg, &factory)

Expand Down
Loading

0 comments on commit 3a8275e

Please sign in to comment.