Skip to content

Commit

Permalink
Only initialize service URL once (#16044) (#16073)
Browse files Browse the repository at this point in the history
* Only add vertices param to URL if it doesn't already exist

* Adding CHANGELOG entry

* Use sync.Once instead
  • Loading branch information
ycombinator authored Feb 5, 2020
1 parent ffd6a8e commit 9e7f8eb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d
- Use RFC3339 format for timestamps collected using the SQL module. {pull}15847[15847]
- Avoid parsing errors returned from prometheus endpoints. {pull}15712[15712]
- Add dedot for cloudwatch metric name. {issue}15916[15916] {pull}15917[15917]
- Fixed issue `logstash-xpack` module suddenly ceasing to monitor Logstash. {issue}15974[15974] {pull}16044[16044]

*Packetbeat*

Expand Down
10 changes: 8 additions & 2 deletions metricbeat/module/logstash/node_stats/node_stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
package node_stats

import (
"sync"

"github.com/elastic/beats/metricbeat/mb"
"github.com/elastic/beats/metricbeat/mb/parse"
"github.com/elastic/beats/metricbeat/module/logstash"
Expand Down Expand Up @@ -48,6 +50,7 @@ var (
// MetricSet type defines all fields of the MetricSet
type MetricSet struct {
*logstash.MetricSet
initialized sync.Once
}

// New create a new instance of the MetricSet
Expand All @@ -58,15 +61,18 @@ func New(base mb.BaseMetricSet) (mb.MetricSet, error) {
}

return &MetricSet{
ms,
MetricSet: ms,
}, nil
}

// Fetch methods implements the data gathering and data conversion to the right format
// It returns the event which is then forward to the output. In case of an error, a
// descriptive error must be returned.
func (m *MetricSet) Fetch(r mb.ReporterV2) error {
err := m.init()
var err error
m.initialized.Do(func() {
err = m.init()
})
if err != nil {
if m.XPack {
m.Logger().Error(err)
Expand Down

0 comments on commit 9e7f8eb

Please sign in to comment.