use of com.megaease.easeagent.plugin.api.Context in project easeagent by megaease.
the class ElasticsearchPerformRequestTraceInterceptorTest method performFail.
@Test
public void performFail() {
MethodInfo methodInfo = MethodInfo.builder().invoker(this).method("perform").args(new Object[] { request }).retValue(this.failResponse).build();
Context context = EaseAgent.getContext();
interceptor.before(methodInfo, context);
interceptor.after(methodInfo, context);
this.assertTrace(false, "500");
}
use of com.megaease.easeagent.plugin.api.Context in project easeagent by megaease.
the class ElasticsearchPerformRequestTraceInterceptorTest method performSuccess.
@Test
public void performSuccess() {
MethodInfo methodInfo = MethodInfo.builder().invoker(this).method("perform").args(new Object[] { request }).retValue(this.successResponse).build();
Context context = EaseAgent.getContext();
interceptor.before(methodInfo, context);
interceptor.after(methodInfo, context);
this.assertTrace(true, null);
}
use of com.megaease.easeagent.plugin.api.Context in project easeagent by megaease.
the class AsyncResponse4MetricsListener method process.
private void process(Response response, Exception exception) {
try (Cleaner ignored = asyncContext.importToCurrent()) {
Context context = EaseAgent.getContext();
Request request = context.get(REQUEST);
long duration = ContextUtils.getDuration(context);
boolean success = ElasticsearchCtxUtils.checkSuccess(response, exception);
this.elasticsearchMetric.collectMetric(ElasticsearchCtxUtils.getIndex(request.getEndpoint()), duration, success);
}
}
use of com.megaease.easeagent.plugin.api.Context in project easeagent by megaease.
the class HttpClient5DoExecuteInterceptorTest method getResponse.
@Test
public void getResponse() {
Context context = EaseAgent.getContext();
HttpGet httpGet = new HttpGet("http://127.0.0.1:8080");
BasicHttpResponse basicHttpResponse = new BasicHttpResponse(200);
basicHttpResponse.setHeader("aa", "bb");
MethodInfo methodInfo = MethodInfo.builder().args(new Object[] { httpGet }).retValue(basicHttpResponse).build();
HttpClient5DoExecuteInterceptor httpClientDoExecuteInterceptor = new HttpClient5DoExecuteInterceptor();
HttpResponse httpResponse = httpClientDoExecuteInterceptor.getResponse(methodInfo, context);
assertEquals(200, httpResponse.statusCode());
}
use of com.megaease.easeagent.plugin.api.Context in project easeagent by megaease.
the class HttpClientDoExecuteInterceptorTest method getRequest.
@Test
public void getRequest() {
Context context = EaseAgent.getContext();
HttpGet httpGet = new HttpGet();
MethodInfo methodInfo = MethodInfo.builder().args(new Object[] { httpGet }).build();
HttpClientDoExecuteInterceptor httpClientDoExecuteInterceptor = new HttpClientDoExecuteInterceptor();
HttpRequest request = httpClientDoExecuteInterceptor.getRequest(methodInfo, context);
assertEquals(com.megaease.easeagent.plugin.api.trace.Span.Kind.CLIENT, request.kind());
assertEquals("GET", request.method());
}
Aggregations