-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[6.8] Only log error (don't also index it) if xpack is enabled. (#12353) #12379
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -131,13 +131,25 @@ func New(base mb.BaseMetricSet) (mb.MetricSet, error) { | |
func (m *MetricSet) Fetch(r mb.ReporterV2) { | ||
now := time.Now() | ||
|
||
m.fetchStats(r, now) | ||
err := m.fetchStats(r, now) | ||
if err != nil { | ||
if m.XPackEnabled { | ||
m.Log.Error(err) | ||
} else { | ||
elastic.ReportAndLogError(err, r, m.Log) | ||
} | ||
return | ||
} | ||
|
||
if m.XPackEnabled { | ||
m.fetchSettings(r, now) | ||
err = m.fetchSettings(r, now) | ||
if err != nil { | ||
m.Log.Error(err) | ||
} | ||
} | ||
} | ||
|
||
func (m *MetricSet) fetchStats(r mb.ReporterV2, now time.Time) { | ||
func (m *MetricSet) fetchStats(r mb.ReporterV2, now time.Time) error { | ||
// Collect usage stats only once every usageCollectionPeriod | ||
if m.isUsageExcludable { | ||
origURI := m.statsHTTP.GetURI() | ||
|
@@ -152,39 +164,25 @@ func (m *MetricSet) fetchStats(r mb.ReporterV2, now time.Time) { | |
|
||
content, err := m.statsHTTP.FetchContent() | ||
if err != nil { | ||
elastic.ReportAndLogError(err, r, m.Log) | ||
return | ||
return err | ||
} | ||
|
||
if m.XPackEnabled { | ||
intervalMs := m.calculateIntervalMs() | ||
err = eventMappingStatsXPack(r, intervalMs, now, content) | ||
if err != nil { | ||
m.Log.Error(err) | ||
return | ||
} | ||
return eventMappingStatsXPack(r, intervalMs, now, content) | ||
} else { | ||
err = eventMapping(r, content) | ||
if err != nil { | ||
elastic.ReportAndLogError(err, r, m.Log) | ||
return | ||
} | ||
return eventMapping(r, content) | ||
} | ||
} | ||
|
||
func (m *MetricSet) fetchSettings(r mb.ReporterV2, now time.Time) { | ||
func (m *MetricSet) fetchSettings(r mb.ReporterV2, now time.Time) error { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think I'm now confused. Do we already support this in 6.8? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note the name of this function. It's a function that is specific to this metricset, not part of the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤦♂ Got it. |
||
content, err := m.settingsHTTP.FetchContent() | ||
if err != nil { | ||
m.Log.Error(err) | ||
return | ||
return err | ||
} | ||
|
||
intervalMs := m.calculateIntervalMs() | ||
err = eventMappingSettingsXPack(r, intervalMs, now, content) | ||
if err != nil { | ||
m.Log.Error(err) | ||
return | ||
} | ||
return eventMappingSettingsXPack(r, intervalMs, now, content) | ||
} | ||
|
||
func (m *MetricSet) calculateIntervalMs() int64 { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should stay as before as we don't have the new framework in 6.8?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note the name of this function. It's a function that is specific to this metricset, not part of the
mb.MetricSet
interface.