use of com.shulie.instrument.simulator.api.reflect.ReflectException in project LinkAgent by shulieTech.
the class SpringBlockingQueueConsumerDeliveryInterceptorV2 method beforeTrace.
@Override
public SpanRecord beforeTrace(Advice advice) {
Object[] args = advice.getParameterArray();
if (args == null || args[0] == null) {
return null;
}
initReflectionProps(advice.getTarget());
Object deliveryObj = args[0];
SpanRecord record = new SpanRecord();
try {
Envelope envelope = Reflect.on(deliveryObj).get(envelopeField);
record.setService(envelope.getExchange());
record.setMethod(envelope.getRoutingKey());
} catch (ReflectException e) {
}
try {
AMQP.BasicProperties properties = Reflect.on(deliveryObj).get(propertiesField);
final Map<String, Object> headers = properties.getHeaders();
if (headers != null) {
Map<String, String> rpcContext = new HashMap<String, String>();
for (String key : Pradar.getInvokeContextTransformKeys()) {
String value = (String) headers.get(key);
if (!StringUtil.isEmpty(value)) {
rpcContext.put(key, value);
}
}
record.setContext(rpcContext);
}
} catch (ReflectException e) {
}
try {
byte[] body = Reflect.on(deliveryObj).get(bodyField);
record.setRequestSize(body.length);
record.setRequest(body);
} catch (ReflectException e) {
}
return record;
}
use of com.shulie.instrument.simulator.api.reflect.ReflectException in project LinkAgent by shulieTech.
the class SpringBlockingQueueConsumerDeliveryInterceptorV2 method initEnvelopeField.
private void initEnvelopeField(Class deliveryClass) {
if (propertiesField != null) {
return;
}
try {
envelopeField = deliveryClass.getDeclaredField("envelope");
envelopeField.setAccessible(true);
} catch (NoSuchFieldException e) {
throw new ReflectException(e);
}
}
use of com.shulie.instrument.simulator.api.reflect.ReflectException in project LinkAgent by shulieTech.
the class SpringBlockingQueueConsumerDeliveryInterceptorV2 method initBodyField.
private void initBodyField(Class deliveryClass) {
if (propertiesField != null) {
return;
}
try {
bodyField = deliveryClass.getDeclaredField("body");
bodyField.setAccessible(true);
} catch (NoSuchFieldException e) {
throw new ReflectException(e);
}
}
use of com.shulie.instrument.simulator.api.reflect.ReflectException in project LinkAgent by shulieTech.
the class HttpClientv3MethodInterceptor method buildParameters.
private void buildParameters(HttpParams httpParams, Map map) {
if (httpParams == null) {
return;
}
if (!(httpParams instanceof DefaultHttpParams)) {
return;
}
HttpParams defaults = httpParams.getDefaults();
if (defaults != null) {
buildParameters(defaults, map);
}
HashMap hashMap = null;
try {
hashMap = Reflect.on(httpParams).get(HttpClientConstants.DYNAMIC_FIELD_PARAMETERS);
} catch (ReflectException e) {
LOGGER.warn("{} has not field {}", httpParams.getClass().getName(), HttpClientConstants.DYNAMIC_FIELD_PARAMETERS);
}
if (hashMap != null) {
map.putAll(hashMap);
}
}
use of com.shulie.instrument.simulator.api.reflect.ReflectException in project LinkAgent by shulieTech.
the class MappedStatementGetCacheInterceptor method cutoff0.
@Override
public CutOffResult cutoff0(Advice advice) {
if (!Pradar.isClusterTest()) {
return CutOffResult.passed();
}
try {
Object cache = Reflect.on(advice.getTarget()).get(MybatisConstants.DYNAMIC_FIELD_CACHE);
if (cache == null) {
return CutOffResult.passed();
}
} catch (ReflectException e) {
return CutOffResult.passed();
}
String currentNamespace = null;
try {
currentNamespace = Reflect.on(advice.getTarget()).get(MybatisConstants.DYNAMIC_FIELD_CURRENT_NAMESPACE);
} catch (ReflectException e) {
currentNamespace = manager.getDynamicField(advice.getTarget(), MybatisConstants.DYNAMIC_FIELD_CURRENT_NAMESPACE);
}
Cache cache = MybatisConstants.currentName2PtCacheMap.get(currentNamespace);
return CutOffResult.cutoff(cache);
}
Aggregations