use of com.megaease.easeagent.plugin.tools.trace.HttpRequest in project easeagent by megaease.
the class OkHttpTracingInterceptor method getRequest.
@Override
protected HttpRequest getRequest(MethodInfo methodInfo, Context context) {
Object realCall = methodInfo.getInvoker();
Request originalRequest = AgentFieldReflectAccessor.getFieldValue(realCall, "originalRequest");
if (originalRequest == null) {
return null;
}
context.put(METHOD_KEY, originalRequest.method());
Request.Builder requestBuilder = originalRequest.newBuilder();
context.put(REQUEST_BUILDER_KEY, requestBuilder);
return new InternalRequest(originalRequest, requestBuilder);
}
use of com.megaease.easeagent.plugin.tools.trace.HttpRequest in project easeagent by megaease.
the class DoFilterForwardedInterceptor method doBefore.
@Override
public void doBefore(MethodInfo methodInfo, Context context) {
HttpServletRequest httpServletRequest = (HttpServletRequest) methodInfo.getArgs()[0];
HttpRequest httpRequest = new HttpServerRequest(httpServletRequest);
Cleaner cleaner = context.importForwardedHeaders(httpRequest);
context.put(FORWARDED_KEY, cleaner);
}
use of com.megaease.easeagent.plugin.tools.trace.HttpRequest 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());
}
use of com.megaease.easeagent.plugin.tools.trace.HttpRequest in project easeagent by megaease.
the class ClientHttpRequestInterceptorTest method getRequest.
@Test
public void getRequest() throws URISyntaxException, IOException {
ClientHttpRequestFactory requestFactory = new SimpleClientHttpRequestFactory();
ClientHttpRequest request = requestFactory.createRequest(new URI("http://127.0.0.1:8080/test"), HttpMethod.GET);
MethodInfo methodInfo = MethodInfo.builder().invoker(request).build();
Context context = EaseAgent.getContext();
ClientHttpRequestInterceptor clientHttpRequestInterceptor = new ClientHttpRequestInterceptor();
HttpRequest httpRequest = clientHttpRequestInterceptor.getRequest(methodInfo, context);
assertEquals(com.megaease.easeagent.plugin.api.trace.Span.Kind.CLIENT, httpRequest.kind());
assertEquals("GET", httpRequest.method());
assertEquals("/test", httpRequest.path());
}
use of com.megaease.easeagent.plugin.tools.trace.HttpRequest in project easeagent by megaease.
the class WebClientFilterTracingInterceptorTest method getRequest.
@Test
public void getRequest() throws URISyntaxException {
URI uri = new URI(url);
ClientRequest clientRequest = MockClientRequest.build(uri);
MethodInfo methodInfo = MethodInfo.builder().args(new Object[] { clientRequest }).build();
WebClientFilterTracingInterceptor interceptor = new WebClientFilterTracingInterceptor();
HttpRequest httpRequest = interceptor.getRequest(methodInfo);
check(httpRequest);
String key = "testKey";
String value = "testValue";
httpRequest.setHeader(key, value);
assertNull(httpRequest.header(key));
assertEquals(value, Objects.requireNonNull(((ClientRequest) methodInfo.getArgs()[0]).headers().get(key)).get(0));
}
Aggregations