Skip to content
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -149,13 +149,15 @@ public Collection<Record<Event>> doExecute(final Collection<Record<Event>> recor

final Instant endTime = Instant.now();

Long totalEventTimeInGrok = (Long) event.getMetadata().getAttribute(TOTAL_TIME_SPENT_IN_GROK_METADATA_KEY);
if (totalEventTimeInGrok == null) {
totalEventTimeInGrok = 0L;
}
if (grokProcessorConfig.getIncludePerformanceMetadata()) {
Long totalEventTimeInGrok = (Long) event.getMetadata().getAttribute(TOTAL_TIME_SPENT_IN_GROK_METADATA_KEY);
if (totalEventTimeInGrok == null) {
totalEventTimeInGrok = 0L;
}

final long timeSpentInThisGrok = endTime.toEpochMilli() - startTime.toEpochMilli();
event.getMetadata().setAttribute(TOTAL_TIME_SPENT_IN_GROK_METADATA_KEY, totalEventTimeInGrok + timeSpentInThisGrok);
final long timeSpentInThisGrok = endTime.toEpochMilli() - startTime.toEpochMilli();
event.getMetadata().setAttribute(TOTAL_TIME_SPENT_IN_GROK_METADATA_KEY, totalEventTimeInGrok + timeSpentInThisGrok);
}
}
return records;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ public void testMatchMerge() throws JsonProcessingException, ExecutionException,
assertThat(grokkedRecords.get(0).getData(), notNullValue());
assertThat(grokkedRecords.get(0).getData().getMetadata(), notNullValue());
assertThat(grokkedRecords.get(0).getData().getMetadata().getAttribute(TOTAL_PATTERNS_ATTEMPTED_METADATA_KEY), equalTo(null));
assertThat(grokkedRecords.get(0).getData().getMetadata().getAttribute(TOTAL_TIME_SPENT_IN_GROK_METADATA_KEY), equalTo(null));
assertRecordsAreEqual(grokkedRecords.get(0), resultRecord);

verify(grokProcessingMatchCounter, times(1)).increment();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ dependencies {
implementation 'com.fasterxml.jackson.core:jackson-databind'
implementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-yaml'
implementation 'com.github.ben-manes.caffeine:caffeine:3.1.8'
testImplementation 'org.assertj:assertj-core:3.25.2'
testImplementation 'org.assertj:assertj-core:3.25.3'
testImplementation testLibs.mockito.inline
}

Expand Down