Skip to content

Commit

Permalink
Refactor: Use context in Fetch method
Browse files Browse the repository at this point in the history
  • Loading branch information
manuelsaks committed Dec 10, 2024
1 parent 79260f5 commit aba1559
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 6 deletions.
3 changes: 1 addition & 2 deletions metricbeat/module/pgbouncer/lists/lists.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ func New(base mb.BaseMetricSet) (mb.MetricSet, error) {

// Fetch methods implements the data gathering and data conversion to the right format
// It publishes the event which is then forwarded to the output. In case of an error, an error is reported.
func (m *MetricSet) Fetch(reporter mb.ReporterV2) error {
ctx := context.Background()
func (m *MetricSet) Fetch(ctx context.Context, reporter mb.ReporterV2) error {
results, err := m.QueryStats(ctx, "SHOW LISTS;")
if err != nil {
return fmt.Errorf("error in QueryStats: %w", err)
Expand Down
3 changes: 1 addition & 2 deletions metricbeat/module/pgbouncer/pools/pools.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ func New(base mb.BaseMetricSet) (mb.MetricSet, error) {

// Fetch methods implements the data gathering and data conversion to the right format
// It publishes the event which is then forwarded to the output. In case of an error, an error is reported.
func (m *MetricSet) Fetch(reporter mb.ReporterV2) error {
ctx := context.Background()
func (m *MetricSet) Fetch(ctx context.Context, reporter mb.ReporterV2) error {
results, err := m.QueryStats(ctx, "SHOW POOLS;")
if err != nil {
return fmt.Errorf("error in QueryStats: %w", err)
Expand Down
3 changes: 1 addition & 2 deletions metricbeat/module/pgbouncer/stats/stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ func New(base mb.BaseMetricSet) (mb.MetricSet, error) {

// Fetch methods implements the data gathering and data conversion to the right format
// It publishes the event which is then forwarded to the output. In case of an error, an error is reported.
func (m *MetricSet) Fetch(reporter mb.ReporterV2) error {
ctx := context.Background()
func (m *MetricSet) Fetch(ctx context.Context, reporter mb.ReporterV2) error {
results, err := m.QueryStats(ctx, "SHOW STATS;")
if err != nil {
return fmt.Errorf("error in QueryStats: %w", err)
Expand Down

0 comments on commit aba1559

Please sign in to comment.