Skip to content

Commit

Permalink
Don't add the modifier for service name if it is not configured (#10832
Browse files Browse the repository at this point in the history
…) (#11024)

Check if service.name is configured, and if not, don't add the modifier
so no additional overhead is added for all events.

(cherry picked from commit 775568d)
  • Loading branch information
jsoriano committed Mar 4, 2019
1 parent 5831462 commit f70a408
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions metricbeat/mb/module/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,17 @@ func WithMetricSetInfo() Option {
// given to the `service.name` setting in the module configuration.
func WithServiceName() Option {
return func(w *Wrapper) {
if w.Module == nil {
return
}
serviceName := w.Module.Config().ServiceName
if serviceName == "" {
return
}
modifier := func(_, _ string, event *mb.Event) {
if event == nil {
return
}
serviceName := w.Module.Config().ServiceName
if serviceName == "" {
return
}
if event.RootFields == nil {
event.RootFields = common.MapStr{}
} else if current, err := event.RootFields.GetValue("service.name"); err == nil && current != "" {
Expand Down

0 comments on commit f70a408

Please sign in to comment.