Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#8557] Send caller app name #8570

Open
wants to merge 21 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[#8557] add http client 3 support
  • Loading branch information
yjqg6666 committed Dec 30, 2021
commit 0acf4f47a9c0c87eb840a246762ec73b9d613205
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@
package com.navercorp.pinpoint.plugin.httpclient3.interceptor;

import com.navercorp.pinpoint.bootstrap.config.HttpDumpConfig;
import com.navercorp.pinpoint.bootstrap.plugin.request.ApplicationInfoSender;
import com.navercorp.pinpoint.bootstrap.plugin.request.ClientHeaderAdaptor;
import com.navercorp.pinpoint.bootstrap.plugin.request.ClientRequestAdaptor;
import com.navercorp.pinpoint.bootstrap.plugin.request.ClientRequestRecorder;
import com.navercorp.pinpoint.bootstrap.plugin.request.ClientRequestWrapper;
import com.navercorp.pinpoint.bootstrap.plugin.request.ClientRequestWrapperAdaptor;
import com.navercorp.pinpoint.bootstrap.plugin.request.DefaultApplicationInfoSender;
import com.navercorp.pinpoint.bootstrap.plugin.request.DefaultRequestTraceWriter;
import com.navercorp.pinpoint.bootstrap.plugin.request.RequestTraceWriter;
import com.navercorp.pinpoint.bootstrap.plugin.request.util.CookieExtractor;
Expand Down Expand Up @@ -74,6 +76,7 @@ public class HttpMethodBaseExecuteMethodInterceptor implements AroundInterceptor
private final InterceptorScope interceptorScope;
private final ClientRequestRecorder<ClientRequestWrapper> clientRequestRecorder;
private final RequestTraceWriter<HttpMethod> requestTraceWriter;
private final ApplicationInfoSender<HttpMethod> applicationInfoSender;

private final boolean io;
private final CookieRecorder<HttpMethod> cookieRecorder;
Expand Down Expand Up @@ -102,6 +105,7 @@ public HttpMethodBaseExecuteMethodInterceptor(TraceContext traceContext, MethodD

ClientHeaderAdaptor<HttpMethod> clientHeaderAdaptor = new HttpMethodClientHeaderAdaptor();
this.requestTraceWriter = new DefaultRequestTraceWriter<>(clientHeaderAdaptor, traceContext);
this.applicationInfoSender = new DefaultApplicationInfoSender<>(clientHeaderAdaptor, traceContext);

this.io = config.isIo();
}
Expand All @@ -117,9 +121,11 @@ public void before(Object target, Object[] args) {
return;
}

final HttpMethod httpMethod = getHttpMethod(target);
applicationInfoSender.sendCallerApplicationName(httpMethod);

if (!trace.canSampled()) {
if (target instanceof HttpMethod) {
final HttpMethod httpMethod = (HttpMethod) target;
if (httpMethod != null) {
this.requestTraceWriter.write(httpMethod);
}
return;
Expand All @@ -131,8 +137,7 @@ public void before(Object target, Object[] args) {
recorder.recordNextSpanId(nextId.getSpanId());
recorder.recordServiceType(HttpClient3Constants.HTTP_CLIENT_3);
// set http header for trace.
if (target instanceof HttpMethod) {
final HttpMethod httpMethod = (HttpMethod) target;
if (httpMethod != null) {
final HttpConnection httpConnection = getHttpConnection(args);
final String host = getHost(httpMethod, httpConnection);
this.requestTraceWriter.write(httpMethod, nextId, host);
Expand All @@ -142,6 +147,9 @@ public void before(Object target, Object[] args) {
initAttachment();
}

private HttpMethod getHttpMethod(Object target) {
return target instanceof HttpMethod ? (HttpMethod) target : null;
}

private String getHost(HttpMethod httpMethod, HttpConnection httpConnection) {
try {
Expand Down