use of com.pamirs.attach.plugin.es.common.RequestIndexRename in project LinkAgent by shulieTech.
the class RestClientTraceInterceptor method beforeTrace.
@Override
public SpanRecord beforeTrace(Advice advice) {
Object[] args = advice.getParameterArray();
Object target = advice.getTarget();
SpanRecord record = new SpanRecord();
RequestIndexRename requestIndexRename = RequestIndexRenameProvider.get(args[0]);
if (requestIndexRename == null) {
LOGGER.error("elasticsearch {} is not supported", args[0].getClass().getName());
return null;
}
final Set<String> indexes = new HashSet<String>(requestIndexRename.getIndex(args[0]));
if (CollectionUtils.isEmpty(indexes)) {
return null;
}
record.setService(toString(indexes));
record.setMethod(advice.getBehaviorName());
String remoteIp = getRemoteIp(target);
record.setRemoteIp(remoteIp);
if (!Pradar.isClusterTest()) {
record.setPassedCheck(true);
}
return record;
}
use of com.pamirs.attach.plugin.es.common.RequestIndexRename in project LinkAgent by shulieTech.
the class RestHighLevelClientInterceptor method beforeFirst.
@Override
public void beforeFirst(Advice advice) {
Object[] args = advice.getParameterArray();
ClusterTestUtils.validateClusterTest();
if (!Pradar.isClusterTest()) {
return;
}
if (GlobalConfig.getInstance().isShadowEsServer()) {
return;
}
RequestIndexRename requestIndexRename = RequestIndexRenameProvider.get(args[0]);
if (requestIndexRename == null) {
throw new PressureMeasureError("elasticsearch " + args[0].getClass().getName() + " is not supported!");
}
if (requestIndexRename.supportedDirectReindex(args[0])) {
requestIndexRename.reindex(args[0]);
} else {
Object index = requestIndexRename.indirectIndex(args[0]);
advice.changeParameter(0, index);
}
}
use of com.pamirs.attach.plugin.es.common.RequestIndexRename in project LinkAgent by shulieTech.
the class TransportClientTraceInterceptor method beforeTrace.
@Override
public SpanRecord beforeTrace(Advice advice) {
Object[] args = advice.getParameterArray();
Object target = advice.getTarget();
SpanRecord record = new SpanRecord();
RequestIndexRename requestIndexRename = RequestIndexRenameProvider.get(args[1]);
if (requestIndexRename == null) {
LOGGER.error("elasticsearch {} is not supported", args[1].getClass().getName());
return null;
}
if (!Pradar.isClusterTest()) {
record.setPassedCheck(true);
}
AbstractClient client = (AbstractClient) target;
record.setService(toString(new HashSet<String>(requestIndexRename.getIndex(args[1]))));
record.setMethod(advice.getBehaviorName());
record.setRemoteIp(parseAddressAndPort(client));
return record;
}
use of com.pamirs.attach.plugin.es.common.RequestIndexRename in project LinkAgent by shulieTech.
the class BulkRequestAddInterceptor method beforeFirst.
@Override
public void beforeFirst(Advice advice) {
ClusterTestUtils.validateClusterTest();
if (!Pradar.isClusterTest()) {
return;
}
Object[] args = advice.getParameterArray();
RequestIndexRename requestIndexRename = RequestIndexRenameProvider.get(args[0]);
if (requestIndexRename == null) {
throw new PressureMeasureError("elasticsearch " + args[0].getClass().getName() + " is not supported!");
}
if (requestIndexRename.supportedDirectReindex(args[0])) {
requestIndexRename.reindex(args[0]);
} else {
Object index = requestIndexRename.indirectIndex(args[0]);
advice.changeParameter(0, index);
}
}
use of com.pamirs.attach.plugin.es.common.RequestIndexRename in project LinkAgent by shulieTech.
the class BulkRequestIndexRename method getIndex0.
@Override
public List<String> getIndex0(Object target) {
BulkRequest req = (BulkRequest) target;
List reqs = req.requests();
List<String> list = new ArrayList<String>();
for (Object r : reqs) {
if (r == null) {
continue;
}
RequestIndexRename requestIndexRename = RequestIndexRenameProvider.get(r);
if (requestIndexRename != null) {
list.addAll(requestIndexRename.getIndex(r));
}
}
return list;
}
Aggregations