Skip to content
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
16 changes: 8 additions & 8 deletions metricbeat/module/php_fpm/pool/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ package pool
import (
"encoding/json"

"github.com/pkg/errors"

"github.com/elastic/beats/metricbeat/helper"
"github.com/elastic/beats/metricbeat/mb"
"github.com/elastic/beats/metricbeat/module/php_fpm"
Expand Down Expand Up @@ -53,24 +55,22 @@ func New(base mb.BaseMetricSet) (mb.MetricSet, error) {
}

// Fetch gathers data for the pool metricset
func (m *MetricSet) Fetch(report mb.ReporterV2) {
func (m *MetricSet) Fetch(reporter mb.ReporterV2) error {
content, err := m.HTTP.FetchContent()
if err != nil {
report.Error(err)
return
return errors.Wrap(err, "error in http fetch")
}
var stats map[string]interface{}
err = json.Unmarshal(content, &stats)
if err != nil {
report.Error(err)
return
return errors.Wrap(err, "error unmarshalling json")
}
event, err := schema.Apply(stats)
if err != nil {
report.Error(err)
return
return errors.Wrap(err, "error in event mapping")
}
report.Event(mb.Event{
reporter.Event(mb.Event{
MetricSetFields: event,
})
return nil
}
4 changes: 2 additions & 2 deletions metricbeat/module/php_fpm/pool/pool_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ import (
func TestFetch(t *testing.T) {
compose.EnsureUp(t, "phpfpm")

f := mbtest.NewReportingMetricSetV2(t, getConfig())
events, errs := mbtest.ReportingFetchV2(f)
f := mbtest.NewReportingMetricSetV2Error(t, getConfig())
events, errs := mbtest.ReportingFetchV2Error(f)

assert.Empty(t, errs)
if !assert.NotEmpty(t, events) {
Expand Down