Issue #1305 updated ProcessEvent with quantitative statistics. removed duplicate processStats.properties.
Amend: removed groupBy attribute "fileName" added LogLevel enum and attribute to Event.java. Default level is DEBUG. Change-Id: I13c155b1fae19cf5a3c82fbb633bf6c7fb217c07 Former-commit-id:cbce70fd0b
[formerly6ddd1cbdb3
] [formerlycbce70fd0b
[formerly6ddd1cbdb3
] [formerlya4bc175653
[formerly 51802e671ac15d451fec19262dfa7a352f0e4c09]]] Former-commit-id:a4bc175653
Former-commit-id:5257f9a81a
[formerlyce47edb905
] Former-commit-id:d226ca28c4
This commit is contained in:
parent
3bf08b29e5
commit
803ac115ff
6 changed files with 164 additions and 17 deletions
|
@ -9,10 +9,29 @@ import javax.persistence.Column;
|
|||
import com.raytheon.uf.common.serialization.ISerializableObject;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
||||
|
||||
/**
|
||||
* Provides logging and deletion services for camel
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Nov 5, 2012 #1305 bgonzale Added LogLevel enum and transient attribute.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author jsanchez
|
||||
* @version 1.0
|
||||
*/
|
||||
public abstract class Event implements Serializable, ISerializableObject {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public enum LogLevel {
|
||||
DEBUG, INFO, WARN, ERROR, FATAL, ALL, OFF, TRACE
|
||||
}
|
||||
|
||||
@Column
|
||||
@DynamicSerializeElement
|
||||
protected Calendar date;
|
||||
|
@ -21,8 +40,16 @@ public abstract class Event implements Serializable, ISerializableObject {
|
|||
@DynamicSerializeElement
|
||||
protected String id;
|
||||
|
||||
@DynamicSerializeElement
|
||||
protected LogLevel logLevel;
|
||||
|
||||
public Event() {
|
||||
this(LogLevel.DEBUG);
|
||||
}
|
||||
|
||||
public Event(LogLevel logLevel) {
|
||||
date = Calendar.getInstance();
|
||||
this.logLevel = logLevel;
|
||||
}
|
||||
|
||||
public Calendar getDate() {
|
||||
|
@ -46,4 +73,19 @@ public abstract class Event implements Serializable, ISerializableObject {
|
|||
return formatter.format(date.getTime()) + " Id: " + id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the logLevel
|
||||
*/
|
||||
public LogLevel getLogLevel() {
|
||||
return logLevel;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param logLevel
|
||||
* the logLevel to set
|
||||
*/
|
||||
public void setLogLevel(LogLevel logLevel) {
|
||||
this.logLevel = logLevel;
|
||||
}
|
||||
|
||||
}
|
|
@ -25,7 +25,7 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
|
|||
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
||||
|
||||
/**
|
||||
* TODO Add Description
|
||||
* Event for file ingest statistics (processing time and processing latency.)
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
|
@ -46,11 +46,21 @@ public class ProcessEvent extends Event {
|
|||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@DynamicSerializeElement
|
||||
private final String message;
|
||||
private String message;
|
||||
|
||||
public ProcessEvent(String message) {
|
||||
super();
|
||||
this.message = message;
|
||||
@DynamicSerializeElement
|
||||
private String pluginName;
|
||||
|
||||
@DynamicSerializeElement
|
||||
private String fileName;
|
||||
|
||||
@DynamicSerializeElement
|
||||
private double processingTimeMilliseconds;
|
||||
|
||||
@DynamicSerializeElement
|
||||
private double processingLatencyMilliseconds;
|
||||
|
||||
public ProcessEvent() {
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -65,4 +75,73 @@ public class ProcessEvent extends Event {
|
|||
return message;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param message
|
||||
* the message to set
|
||||
*/
|
||||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the pluginName
|
||||
*/
|
||||
public String getPluginName() {
|
||||
return pluginName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param pluginName
|
||||
* the pluginName to set
|
||||
*/
|
||||
public void setPluginName(String pluginName) {
|
||||
this.pluginName = pluginName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the fileName
|
||||
*/
|
||||
public String getFileName() {
|
||||
return fileName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param fileName
|
||||
* the fileName to set
|
||||
*/
|
||||
public void setFileName(String fileName) {
|
||||
this.fileName = fileName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the processingTimeMilliseconds
|
||||
*/
|
||||
public double getProcessingTimeMilliseconds() {
|
||||
return processingTimeMilliseconds;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param processingTimeMilliseconds
|
||||
* the processingTimeMilliseconds to set
|
||||
*/
|
||||
public void setProcessingTimeMilliseconds(double processingTimeMilliseconds) {
|
||||
this.processingTimeMilliseconds = processingTimeMilliseconds;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the processingLatencyMilliseconds
|
||||
*/
|
||||
public double getProcessingLatencyMilliseconds() {
|
||||
return processingLatencyMilliseconds;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param processingLatencyMilliseconds
|
||||
* the processingLatencyMilliseconds to set
|
||||
*/
|
||||
public void setProcessingLatencyMilliseconds(
|
||||
double processingLatencyMilliseconds) {
|
||||
this.processingLatencyMilliseconds = processingLatencyMilliseconds;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -90,35 +90,42 @@ public class ProcessUtil {
|
|||
|
||||
StringBuilder sb = new StringBuilder(128);
|
||||
|
||||
ProcessEvent processEvent = new ProcessEvent();
|
||||
String pluginName = getHeaderProperty(headers, "pluginName");
|
||||
if (pluginName != null) {
|
||||
sb.append(pluginName);
|
||||
processEvent.setPluginName(pluginName);
|
||||
}
|
||||
|
||||
String fileName = getHeaderProperty(headers, "ingestFileName");
|
||||
if (fileName != null) {
|
||||
sb.append(":: ");
|
||||
sb.append(fileName);
|
||||
processEvent.setFileName(fileName);
|
||||
}
|
||||
|
||||
Long dequeueTime = getHeaderProperty(headers, "dequeueTime");
|
||||
DecimalFormat df = FORMAT.get();
|
||||
if (dequeueTime != null) {
|
||||
double elapsed = (curTime - dequeueTime) / 1000.0;
|
||||
double elapsedMilliseconds = curTime - dequeueTime;
|
||||
double elapsed = (elapsedMilliseconds) / 1000.0;
|
||||
sb.append(" processed in: ");
|
||||
sb.append(df.format(elapsed));
|
||||
sb.append(" (sec)");
|
||||
processEvent.setProcessingTimeMilliseconds(elapsedMilliseconds);
|
||||
}
|
||||
|
||||
Long enqueueTime = getHeaderProperty(headers, "enqueueTime");
|
||||
if (enqueueTime != null) {
|
||||
double latency = (curTime - enqueueTime) / 1000.0;
|
||||
double latencyMilliseconds = curTime - enqueueTime;
|
||||
double latency = (latencyMilliseconds) / 1000.0;
|
||||
sb.append(" Latency: ");
|
||||
sb.append(df.format(latency));
|
||||
sb.append(" (sec)");
|
||||
processEvent.setProcessingLatencyMilliseconds(latencyMilliseconds);
|
||||
}
|
||||
|
||||
EventBus.getInstance().publish(new ProcessEvent(sb.toString()));
|
||||
EventBus.getInstance().publish(processEvent);
|
||||
|
||||
// Make sure we have something to log.
|
||||
if (sb.length() > 0) {
|
||||
|
|
|
@ -19,6 +19,7 @@ import com.raytheon.uf.edex.event.EventBus;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Mar 1, 2012 jsanchez Initial creation
|
||||
* Nov 5, 2012 #1305 bgonzale Added log level Event logging.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -47,6 +48,29 @@ public class LogHandler {
|
|||
@Subscribe
|
||||
@AllowConcurrentEvents
|
||||
public void eventListener(Event event) {
|
||||
logger.info(event.toString());
|
||||
switch (event.getLogLevel()) {
|
||||
case DEBUG:
|
||||
logger.debug(event.toString());
|
||||
break;
|
||||
case INFO:
|
||||
logger.info(event.toString());
|
||||
break;
|
||||
case WARN:
|
||||
logger.warn(event.toString());
|
||||
break;
|
||||
case ERROR:
|
||||
logger.error(event.toString());
|
||||
break;
|
||||
case FATAL:
|
||||
logger.fatal(event.toString());
|
||||
break;
|
||||
case TRACE:
|
||||
logger.trace(event.toString());
|
||||
break;
|
||||
default:
|
||||
// ALL
|
||||
// logger.(event.toString());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
# scan interval of stats table in minutes
|
||||
stats.scanInterval=15
|
||||
# bucket interval or period of when to aggregate in minutes
|
||||
stats.period=2
|
|
@ -2,9 +2,8 @@
|
|||
<!-- Event Type should be fully qualified name of stat event -->
|
||||
<eventType>com.raytheon.uf.common.event.ProcessEvent</eventType>
|
||||
<groupBy>
|
||||
<attribute name="plugin"/>
|
||||
<attribute name="owner"/>
|
||||
<attribute name="pluginName"/>
|
||||
</groupBy>
|
||||
<aggregate field="numFailed"/>
|
||||
<aggregate field="numComplete"/>
|
||||
<aggregate field="processingTimeMilliseconds"/>
|
||||
<aggregate field="processingLatencyMilliseconds"/>
|
||||
</statsConfig>
|
||||
|
|
Loading…
Add table
Reference in a new issue