From e2d37fd7bbc076d767909487c01230e5b439cd4c Mon Sep 17 00:00:00 2001 From: naman47vyas Date: Tue, 11 Jun 2024 10:56:39 +0530 Subject: [PATCH] removed dupllicate code --- receiver/postgresqlreceiver/client.go | 9 --------- receiver/postgresqlreceiver/scraper.go | 14 -------------- 2 files changed, 23 deletions(-) diff --git a/receiver/postgresqlreceiver/client.go b/receiver/postgresqlreceiver/client.go index ee73cb0df955..4b0ee12be8f4 100644 --- a/receiver/postgresqlreceiver/client.go +++ b/receiver/postgresqlreceiver/client.go @@ -45,7 +45,6 @@ type client interface { getLatestWalAgeSeconds(ctx context.Context) (int64, error) getMaxConnections(ctx context.Context) (int64, error) getIndexStats(ctx context.Context, database string) (map[indexIdentifer]indexStat, error) - getActiveConnections(ctx context.Context) (int64, error) listDatabases(ctx context.Context) ([]string, error) getRowStats(ctx context.Context) ([]RowStats, error) getQueryStats(ctx context.Context) ([]queryStats, error) @@ -659,14 +658,6 @@ func (c *postgreSQLClient) getBufferHit(ctx context.Context) ([]BufferHit, error return bh, errors } -func (c *postgreSQLClient) getActiveConnections(ctx context.Context) (int64, error) { - query := `SELECT COUNT(*) FROM pg_stat_activity WHERE state = 'active';` - row := c.client.QueryRowContext(ctx, query) - var activeConns int64 - err := row.Scan(&activeConns) - return activeConns, err -} - func (c *postgreSQLClient) getVersionString(ctx context.Context) (string, error) { var version string err := c.client.QueryRowContext(ctx, "SHOW server_version").Scan(&version) diff --git a/receiver/postgresqlreceiver/scraper.go b/receiver/postgresqlreceiver/scraper.go index a3f5dd18362a..3e30b8fc77f5 100644 --- a/receiver/postgresqlreceiver/scraper.go +++ b/receiver/postgresqlreceiver/scraper.go @@ -397,20 +397,6 @@ func (p *postgreSQLScraper) collectQueryPerfStats( } } -func (p *postgreSQLScraper) collectActiveConnections( - ctx context.Context, - now pcommon.Timestamp, - client client, - errs *errsMux, -) { - ac, err := client.getActiveConnections(ctx) - if err != nil { - errs.addPartial(err) - return - } - p.mb.RecordPostgresqlConnectionCountDataPoint(now, ac) -} - func (p *postgreSQLScraper) collectBufferHits( ctx context.Context, now pcommon.Timestamp,