Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fix if you only need custom metrics

  • Loading branch information...
commit 7d20d4da15dca3aff9a9f71c7ba21f1a2d665855 1 parent 7a298eb
Gabriel Eisbruch authored
Showing with 37 additions and 39 deletions.
  1. +1 −0  .gitignore
  2. +36 −39 newrelic/src/MonitorHandler.java
1  .gitignore
View
@@ -1,2 +1,3 @@
npm-debug.log
.log
+*.class
75 newrelic/src/MonitorHandler.java
View
@@ -61,46 +61,44 @@ public void messageReceived(IoSession session, Object msg) throws Exception {
JSONObject timespent = (JSONObject) json.get("timespent");
-
- for (Object key : timespent.keySet()) {
- Object timeObj = timespent.get(key);
- Long time = 0L;
-
- if (timeObj instanceof Double) {
- time = (long) (((Double) timeObj)*1000);
- } else if (timeObj instanceof Long) {
- time = (Long)timeObj;
- } else if (timeObj instanceof String) {
- try {
- synchronized (sdf) {
- Date requestTime = sdf.parse((String) timeObj);
- time = begin - requestTime.getTime();
- }
- } catch (ParseException e) {
- reportParserError(msg.toString(), e);
- return;
- }
+ if(timespent != null){
+ for (Object key : timespent.keySet()) {
+ Object timeObj = timespent.get(key);
+ Long time = 0L;
+
+ if (timeObj instanceof Double) {
+ time = (long) (((Double) timeObj)*1000);
+ } else if (timeObj instanceof Long) {
+ time = (Long)timeObj;
+ } else if (timeObj instanceof String) {
+ try {
+ synchronized (sdf) {
+ Date requestTime = sdf.parse((String) timeObj);
+ time = begin - requestTime.getTime();
+ }
+ } catch (ParseException e) {
+ reportParserError(msg.toString(), e);
+ return;
+ }
+ }
+
+ totaltime += time;
+ if ("WEB_TRANSACTION_EXTERNAL_ALL".equals(key) || "External/allWeb".equals(key)) {
+ StatsEngine.getResponseTimeStats("External/allWeb").recordResponseTime(time);
+ } else if ("URI_WEB_TRANSACTION".equals(key) || "WebTransaction/Uri".equals(key)) {
+ StatsEngine.getResponseTimeStats("WebTransaction/Uri"+ '/' + path).recordResponseTime(time);
+ StatsEngine.getApdexStats(MetricSpec.lookup(MetricNames.APDEX + "/Uri/" + path)).recordApdexResponseTime(time);
+ } else if ("QUEUE_TIME".equals(key) || "WebFrontend/QueueTime".equals(key)) {
+ StatsEngine.getResponseTimeStats("WebFrontend/QueueTime").recordResponseTime(time);
+ } else if ("Database/allWeb".equals(key)) {
+ StatsEngine.getResponseTimeStats("Database/allWeb").recordResponseTime(time);
+ } if ("Solr/allWeb".equals(key)) {
+ StatsEngine.getResponseTimeStats("Solr/allWeb").recordResponseTime(time);
+ }
}
-
- totaltime += time;
-
- if ("WEB_TRANSACTION_EXTERNAL_ALL".equals(key) || "External/allWeb".equals(key)) {
- StatsEngine.getResponseTimeStats("External/allWeb").recordResponseTime(time);
- } else if ("URI_WEB_TRANSACTION".equals(key) || "WebTransaction/Uri".equals(key)) {
- StatsEngine.getResponseTimeStats("WebTransaction/Uri"+ '/' + path).recordResponseTime(time);
- StatsEngine.getApdexStats(MetricSpec.lookup(MetricNames.APDEX + "/Uri/" + path)).recordApdexResponseTime(time);
- } else if ("QUEUE_TIME".equals(key) || "WebFrontend/QueueTime".equals(key)) {
- StatsEngine.getResponseTimeStats("WebFrontend/QueueTime").recordResponseTime(time);
- } else if ("Database/allWeb".equals(key)) {
- StatsEngine.getResponseTimeStats("Database/allWeb").recordResponseTime(time);
- } if ("Solr/allWeb".equals(key)) {
- StatsEngine.getResponseTimeStats("Solr/allWeb").recordResponseTime(time);
- }
+ StatsEngine.getResponseTimeStats(MetricSpec.DISPATCHER).recordResponseTime(totaltime);
+ StatsEngine.getApdexStats(MetricSpec.APDEX).recordApdexResponseTime(totaltime);
}
-
- StatsEngine.getResponseTimeStats(MetricSpec.DISPATCHER).recordResponseTime(totaltime);
- StatsEngine.getApdexStats(MetricSpec.APDEX).recordApdexResponseTime(totaltime);
-
JSONArray customMetrics = (JSONArray) json.get("custom_metric");
if (customMetrics != null) {
@@ -217,6 +215,5 @@ public void run() {
System.out.println(sb.toString());
}
}
-
}
Please sign in to comment.
Something went wrong with that request. Please try again.