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

perf: 请求GSE等底层系统接口响应非200时打印Header中的关键信息 #3179 #3330

Merged
merged 1 commit into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public BkAIDevClient(MeterRegistry meterRegistry,
meterRegistry,
CommonMetricNames.BK_AI_DEV_API,
getBkAIDevUrlSafely(bkApiGatewayProperties),
HttpHelperFactory.getDefaultHttpHelper(
HttpHelperFactory.createHttpHelper(
httpClientBuilder -> httpClientBuilder.addInterceptorLast(getLogBkApiRequestIdInterceptor())
)
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public EsbIamClient(MeterRegistry meterRegistry,
meterRegistry,
IAM_API,
esbProperties.getService().getUrl(),
HttpHelperFactory.getDefaultHttpHelper(
HttpHelperFactory.createHttpHelper(
httpClientBuilder -> httpClientBuilder.addInterceptorLast(getLogBkApiRequestIdInterceptor())
)
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,28 @@ private static WatchableHttpHelper getWatchableExtHelper(HttpHelper httpHelper)
}

public static WatchableHttpHelper getDefaultHttpHelper() {
return getDefaultHttpHelper(null);
HttpHelper baseHttpHelper = new BaseHttpHelper(DEFAULT_HTTP_CLIENT);
return getWatchableExtHelper(baseHttpHelper);
}

@SuppressWarnings("unused")
public static WatchableHttpHelper getRetryableHttpHelper() {
HttpHelper baseHttpHelper = new BaseHttpHelper(RETRYABLE_HTTP_CLIENT);
return getWatchableExtHelper(baseHttpHelper);
}

public static WatchableHttpHelper getLongRetryableHttpHelper() {
HttpHelper baseHttpHelper = new BaseHttpHelper(LONG_RETRYABLE_HTTP_CLIENT);
return getWatchableExtHelper(baseHttpHelper);
}

public static WatchableHttpHelper getDefaultHttpHelper(JobHttpClientFactory.HttpClientCustomizer customizer) {
/**
* 创建自定义的HttpHelper,每创建一次都会生成一个常驻的连接驱逐线程,请在单例中使用,避免线程泄露
*
* @param customizer 自定义的HttpClient定制器
* @return 自定义的HttpHelper
*/
public static WatchableHttpHelper createHttpHelper(JobHttpClientFactory.HttpClientCustomizer customizer) {
HttpHelper baseHttpHelper = createHttpHelper(
15000,
15000,
Expand All @@ -80,17 +98,20 @@ public static WatchableHttpHelper getDefaultHttpHelper(JobHttpClientFactory.Http
return getWatchableExtHelper(baseHttpHelper);
}

@SuppressWarnings("unused")
public static WatchableHttpHelper getRetryableHttpHelper() {
HttpHelper baseHttpHelper = new BaseHttpHelper(RETRYABLE_HTTP_CLIENT);
return getWatchableExtHelper(baseHttpHelper);
}

public static WatchableHttpHelper getLongRetryableHttpHelper() {
HttpHelper baseHttpHelper = new BaseHttpHelper(LONG_RETRYABLE_HTTP_CLIENT);
return getWatchableExtHelper(baseHttpHelper);
}

/**
* 创建自定义的HttpHelper,每创建一次都会生成一个常驻的连接驱逐线程,请在单例中使用,避免线程泄露
*
* @param connRequestTimeout 连接请求超时时间,单位毫秒
* @param connTimeout 连接超时时间,单位毫秒
* @param socketTimeout socket读写超时时间,单位毫秒
* @param maxConnPerRoute 单个路由最大连接数
* @param maxConnTotal 总的最大连接数
* @param timeToLive 连接驱逐线程存活时间,单位秒
* @param allowRetry 是否允许重试
* @param retryHandler 重试策略
* @param customizer 自定义的HttpClient定制器
* @return 自定义的HttpHelper
*/
public static HttpHelper createHttpHelper(int connRequestTimeout,
int connTimeout,
int socketTimeout,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public BkNoticeClient(MeterRegistry meterRegistry,
meterRegistry,
CommonMetricNames.BK_NOTICE_API,
getBkNoticeUrlSafely(bkApiGatewayProperties),
HttpHelperFactory.getDefaultHttpHelper(
HttpHelperFactory.createHttpHelper(
httpClientBuilder -> httpClientBuilder.addInterceptorLast(getLogBkApiRequestIdInterceptor())
)
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public CmsiApiClient(EsbProperties esbProperties,
meterRegistry,
ESB_CMSI_API,
esbProperties.getService().getUrl(),
HttpHelperFactory.getDefaultHttpHelper(
HttpHelperFactory.createHttpHelper(
httpClientBuilder -> httpClientBuilder.addInterceptorLast(getLogBkApiRequestIdInterceptor())
)
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public StandardLoginClient(EsbProperties esbProperties, AppProperties appPropert
meterRegistry,
ESB_BK_LOGIN_API,
esbProperties.getService().getUrl(),
HttpHelperFactory.getDefaultHttpHelper(
HttpHelperFactory.createHttpHelper(
httpClientBuilder -> httpClientBuilder.addInterceptorLast(getLogBkApiRequestIdInterceptor())
)
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import com.tencent.bk.job.file.worker.config.WorkerConfig;
import com.tencent.bk.job.file.worker.state.event.WorkerEvent;
import com.tencent.bk.job.file.worker.state.event.WorkerEventService;
import com.tencent.bk.job.file.worker.task.heartbeat.HeartBeatTask;
import com.tencent.bk.job.file_gateway.consts.TaskCommandEnum;
import com.tencent.bk.job.file_gateway.model.req.inner.OffLineAndReDispatchReq;
import lombok.extern.slf4j.Slf4j;
Expand Down
Loading