blob: 144d498e290fb7cd3c22cbe2b9dd319b5be0fd5e (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.logserver.filter;
import com.yahoo.log.LogLevel;
import com.yahoo.log.event.Count;
import com.yahoo.log.event.CountGroup;
import com.yahoo.log.event.Event;
import com.yahoo.log.event.Histogram;
import com.yahoo.log.event.MalformedEventException;
import com.yahoo.log.event.Value;
import com.yahoo.log.event.ValueGroup;
import com.yahoo.log.LogMessage;
/**
* This filter matches events that are used for monitoring, specificly
* the Count and Value events.
*
* @author Bjorn Borud
*/
public class MetricsFilter implements LogFilter {
public boolean isLoggable (LogMessage msg) {
if (msg.getLevel() != LogLevel.EVENT) {
return false;
}
Event event;
try {
event = msg.getEvent();
}
catch (MalformedEventException e) {
return false;
}
// if it is not Count, Value or something which will generate
// Count or Value we don't care
if (! ((event instanceof Count)
|| (event instanceof Value)
|| (event instanceof Histogram)
|| (event instanceof CountGroup)
|| (event instanceof ValueGroup))) {
return false;
}
return true;
}
public String description () {
return "Match all events representing system metrics (Counts, Values, etc).";
}
}
|