Skip to content

Commit

Permalink
Merge pull request uavorg#19 from uavorg/master
Browse files Browse the repository at this point in the history
2018.0727
  • Loading branch information
fyb007 committed Jul 27, 2018
2 parents 62c88cf + 321b2b1 commit a954592
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public void preCap(InvokeChainContext context) {
/**
* store span in thread local for DoCap
*/
String storeKey = url + "@" + span.getSpanId();
String storeKey = url + "@" + span.getSpanId() + "@" + Thread.currentThread().getName();

this.spanFactory.setSpanToContext(storeKey, span);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@

package com.creditease.uav.apm.invokechain.span;

import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicLong;

import com.alibaba.ttl.TransmittableThreadLocal;
Expand Down Expand Up @@ -99,7 +99,7 @@ public String id() {
@Override
protected Map<String, Span> initialValue() {

return new HashMap<String, Span>();
return new ConcurrentHashMap<String, Span>();
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
*/
public class CaptureConstants {

// 1 day ttl for tmax, tmin
public final static long MEI_INST_TTL = 24 * 3600 * 1000;
// 1 hour ttl for tmax, tmin
public final static long MEI_INST_TTL = 1 * 3600 * 1000;

// default monitor id
public final static String MONITOR_SERVER = "server";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,14 @@ protected void recordCounters(CaptureContext context, MonitorElementInstance ins
/**
* NOTE: for no-http
*/
if (rtCode==-1) {
if (rtCode == -1) {
inst.increValue(CaptureConstants.MEI_ERROR);
respCode="Err";
respCode = "Err";
}
else if (rtCode==1) {
respCode="OK";
else if (rtCode == 1) {
respCode = "OK";
}

inst.increValue(CaptureConstants.MEI_RC + respCode);
}
}
Expand Down Expand Up @@ -103,14 +103,18 @@ protected void doCommonCounters(CaptureContext context, MonitorElementInstance i
MonitorElementInstance.CompareSetOperation.MAX);

/**
* NOTE: tmax, tmin, 每24小时会自动RESET,避免一个巨大的tmax或一个很小的tmin
* NOTE: tmax, tmin, 每1小时会自动RESET,避免一个巨大的tmax或一个很小的tmin
*/
if (isMax == true) {

inst.setValue(CaptureConstants.MEI_RESP_MAXTIME_ST, end);
}
else {
long tmax_st = (Long) inst.getValue(CaptureConstants.MEI_RESP_MAXTIME_ST);
Object tmaxSt = inst.getValue(CaptureConstants.MEI_RESP_MAXTIME_ST);
if (tmaxSt == null) {
return;
}
long tmax_st = (Long) tmaxSt;

if (end - tmax_st > CaptureConstants.MEI_INST_TTL) {
inst.setValue(CaptureConstants.MEI_RESP_MAXTIME, new AtomicLong(respTime));
Expand All @@ -126,9 +130,13 @@ protected void doCommonCounters(CaptureContext context, MonitorElementInstance i
inst.setValue(CaptureConstants.MEI_RESP_MINTIME_ST, end);
}
else {
long tmax_st = (Long) inst.getValue(CaptureConstants.MEI_RESP_MINTIME_ST);
Object tminSt = inst.getValue(CaptureConstants.MEI_RESP_MINTIME_ST);
if (tminSt == null) {
return;
}
long tmin_st = (Long) tminSt;

if (end - tmax_st > CaptureConstants.MEI_INST_TTL) {
if (end - tmin_st > CaptureConstants.MEI_INST_TTL) {
inst.setValue(CaptureConstants.MEI_RESP_MINTIME, new AtomicLong(respTime));
inst.setValue(CaptureConstants.MEI_RESP_MINTIME_ST, end);
}
Expand Down

0 comments on commit a954592

Please sign in to comment.