Skip to content

Commit

Permalink
Only init metrics if needed (#40703)
Browse files Browse the repository at this point in the history
  • Loading branch information
marc-gr authored Sep 6, 2024
1 parent 7f29f60 commit 8a56ef8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion winlogbeat/eventlog/wineventlog.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,9 @@ func (l *winEventLog) Open(state checkpoint.EventLogState) error {
var err error
// we need to defer metrics initialization since when the event log
// is used from winlog input it would register it twice due to CheckConfig calls
l.metrics = newInputMetrics(l.channelName, l.id)
if l.metrics == nil {
l.metrics = newInputMetrics(l.channelName, l.id)
}
if len(state.Bookmark) > 0 {
bookmark, err = win.CreateBookmarkFromXML(state.Bookmark)
} else if state.RecordNumber > 0 && l.channelName != "" {
Expand Down
4 changes: 3 additions & 1 deletion winlogbeat/eventlog/wineventlog_experimental.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,9 @@ func (l *winEventLogExp) Open(state checkpoint.EventLogState) error {
l.lastRead = state
// we need to defer metrics initialization since when the event log
// is used from winlog input it would register it twice due to CheckConfig calls
l.metrics = newInputMetrics(l.channelName, l.id)
if l.metrics == nil {
l.metrics = newInputMetrics(l.channelName, l.id)
}

var err error
l.iterator, err = win.NewEventIterator(
Expand Down

0 comments on commit 8a56ef8

Please sign in to comment.