You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by "daguimu (via GitHub)" <gi...@apache.org> on 2026/03/26 01:59:17 UTC
[PR] fix: add PROPAGATION_EXCLUDE_PORTS to httpclient-4.x plugin [skywalking-java]
daguimu opened a new pull request, #800:
URL: https://github.com/apache/skywalking-java/pull/800
## Problem
When the SkyWalking Java agent enhances an application that uses ClickHouse JDBC via HTTP (port 8123), the httpclient-4.x plugin unconditionally injects `sw8`, `sw8-correlation`, and `sw8-x` propagation headers into every outbound HTTP request. ClickHouse rejects requests containing unknown headers, returning HTTP 400 Bad Request, which breaks all JDBC queries.
## Root Cause
`HttpClientExecuteInterceptor.beforeMethod()` iterates over all `ContextCarrier` items and calls `httpRequest.setHeader()` without checking whether the target server can tolerate extra headers. The httpclient-5.x plugin already solved this with a `PROPAGATION_EXCLUDE_PORTS` config, but httpclient-4.x was missing this feature.
## Fix
- Add `PROPAGATION_EXCLUDE_PORTS` config to `HttpClientPluginConfig.Plugin.HttpClient` (default: `"8123"`)
- Add `skipIntercept()` logic to `HttpClientExecuteInterceptor` that checks the destination port against the exclusion list before creating spans or injecting headers
- When the port is excluded, `beforeMethod`, `afterMethod`, and `handleMethodException` all return early, leaving the HTTP request completely untouched
- Port parsing is lazy and cached (double-checked locking) for zero overhead on the hot path
- Add the config entry to `agent.config`
## Tests Added
- `requestToExcludedPort_noSpanAndNoHeaderInjected` - verifies port 8123 produces no trace segment and no header injection
- `requestToRegularPort_spanCreatedAndHeadersInjected` - verifies port 8080 is still traced normally
- `whenExcludePortsEmpty_allPortsAreTraced` - verifies empty config traces everything including 8123
- `multipleExcludedPorts_allSkippedAndNonExcludedStillTraced` - verifies multi-port config (8123,9200) works correctly
- `excludedPort_handleMethodExceptionSkipped` - verifies exception handling is also skipped for excluded ports
All existing httpclient-4.x tests continue to pass.
## Impact
- Only affects httpclient-4.x plugin users whose target servers reject unknown HTTP headers (e.g. ClickHouse)
- Default config (`8123`) matches the httpclient-5.x plugin behavior
- No behavioral change for non-excluded ports
- Configurable via `plugin.httpclient.propagation_exclude_ports` or env var `SW_PLUGIN_HTTPCLIENT_PROPAGATION_EXCLUDE_PORTS`
Fixes https://github.com/apache/skywalking/issues/13700
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix: add PROPAGATION_EXCLUDE_PORTS to httpclient-4.x plugin [skywalking-java]
Posted by "daguimu (via GitHub)" <gi...@apache.org>.
daguimu commented on code in PR #800:
URL: https://github.com/apache/skywalking-java/pull/800#discussion_r2992972929
##########
apm-sniffer/config/agent.config:
##########
@@ -218,8 +218,10 @@ plugin.jdkthreading.threading_class_prefixes=${SW_PLUGIN_JDKTHREADING_THREADING_
plugin.tomcat.collect_http_params=${SW_PLUGIN_TOMCAT_COLLECT_HTTP_PARAMS:false}
# This config item controls that whether the SpringMVC plugin should collect the parameters of the request, when your Spring application is based on Tomcat, consider only setting either `plugin.tomcat.collect_http_params` or `plugin.springmvc.collect_http_params`. Also, activate implicitly in the profiled trace.
plugin.springmvc.collect_http_params=${SW_PLUGIN_SPRINGMVC_COLLECT_HTTP_PARAMS:false}
-# This config item controls that whether the HttpClient plugin should collect the parameters of the request
+# This config item controls that whether the HttpClient plugin should collect the parameters of the request
plugin.httpclient.collect_http_params=${SW_PLUGIN_HTTPCLIENT_COLLECT_HTTP_PARAMS:false}
+# Comma-separated list of destination ports whose outbound HTTP requests will be completely skipped by the httpclient-4.x interceptor (no exit span created, no sw8 headers injected). Default: 8123 (ClickHouse HTTP interface).
+plugin.httpclient.propagation_exclude_ports=${SW_PLUGIN_HTTPCLIENT_PROPAGATION_EXCLUDE_PORTS:8123}
Review Comment:
Done. Removed the default from `agent.config` and moved `SW_PLUGIN_HTTPCLIENT_PROPAGATION_EXCLUDE_PORTS=8123` to the clickhouse-0.3.1 E2E test scenario only.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix: add PROPAGATION_EXCLUDE_PORTS to httpclient-4.x plugin [skywalking-java]
Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #800:
URL: https://github.com/apache/skywalking-java/pull/800#discussion_r2992326042
##########
apm-sniffer/apm-sdk-plugin/httpclient-commons/src/main/java/org/apache/skywalking/apm/plugin/httpclient/HttpClientPluginConfig.java:
##########
@@ -28,6 +28,24 @@ public static class HttpClient {
* This config item controls that whether the HttpClient plugin should collect the parameters of the request.
*/
public static boolean COLLECT_HTTP_PARAMS = false;
+
+ /**
+ * Comma-separated list of destination ports whose outbound HTTP requests
+ * will be completely skipped by the httpclient-4.x interceptor: no exit
+ * span is created and no SkyWalking propagation headers are injected.
+ *
+ * <p>Some HTTP-based database protocols (e.g. ClickHouse on port 8123)
+ * reject requests that contain unknown HTTP headers, returning HTTP 400.
+ * Adding such ports here prevents the agent from creating exit spans
+ * and from injecting the {@code sw8} tracing headers into those outbound
+ * requests.
+ *
+ * <p>Default: {@code "8123"} (ClickHouse HTTP interface).
+ *
+ * <p>Example – also exclude port 9200 (Elasticsearch):
+ * {@code plugin.httpclient.PROPAGATION_EXCLUDE_PORTS=8123,9200}
Review Comment:
The Javadoc example uses `plugin.httpclient.PROPAGATION_EXCLUDE_PORTS`, but config keys are lowercased by `ConfigInitializer` (e.g. `COLLECT_HTTP_PARAMS` maps to `plugin.httpclient.collect_http_params`). This example should be updated to `plugin.httpclient.propagation_exclude_ports=8123,9200` (and/or mention the env var) so users don’t set a key that will be ignored.
```suggestion
* {@code plugin.httpclient.propagation_exclude_ports=8123,9200}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix: add PROPAGATION_EXCLUDE_PORTS to httpclient-4.x plugin [skywalking-java]
Posted by "daguimu (via GitHub)" <gi...@apache.org>.
daguimu commented on PR #800:
URL: https://github.com/apache/skywalking-java/pull/800#issuecomment-4132719571
Fixed both issues in the latest commit (6d822b2):
1. **Removed default value**: `PROPAGATION_EXCLUDE_PORTS` default changed from `"8123"` to `""` — no ports excluded by default.
2. **Restored `agent.config` entry** with empty default so the env var `SW_PLUGIN_HTTPCLIENT_PROPAGATION_EXCLUDE_PORTS` works correctly via `ConfigInitializer`:
```
plugin.httpclient.propagation_exclude_ports=${SW_PLUGIN_HTTPCLIENT_PROPAGATION_EXCLUDE_PORTS:}
```
3. The clickhouse-0.3.1 E2E test sets `SW_PLUGIN_HTTPCLIENT_PROPAGATION_EXCLUDE_PORTS=8123` explicitly, which now flows through `agent.config` → `ConfigInitializer` → `HttpClientPluginConfig` as expected.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix: add PROPAGATION_EXCLUDE_PORTS to httpclient-4.x plugin [skywalking-java]
Posted by "wu-sheng (via GitHub)" <gi...@apache.org>.
wu-sheng commented on PR #800:
URL: https://github.com/apache/skywalking-java/pull/800#issuecomment-4131449225
e2e doesn't matter at all. They passed anyway. the point is, is 0.3.1 ck client still used?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix: add PROPAGATION_EXCLUDE_PORTS to httpclient-4.x plugin [skywalking-java]
Posted by "wu-sheng (via GitHub)" <gi...@apache.org>.
wu-sheng commented on code in PR #800:
URL: https://github.com/apache/skywalking-java/pull/800#discussion_r2992926311
##########
apm-sniffer/config/agent.config:
##########
@@ -218,8 +218,10 @@ plugin.jdkthreading.threading_class_prefixes=${SW_PLUGIN_JDKTHREADING_THREADING_
plugin.tomcat.collect_http_params=${SW_PLUGIN_TOMCAT_COLLECT_HTTP_PARAMS:false}
# This config item controls that whether the SpringMVC plugin should collect the parameters of the request, when your Spring application is based on Tomcat, consider only setting either `plugin.tomcat.collect_http_params` or `plugin.springmvc.collect_http_params`. Also, activate implicitly in the profiled trace.
plugin.springmvc.collect_http_params=${SW_PLUGIN_SPRINGMVC_COLLECT_HTTP_PARAMS:false}
-# This config item controls that whether the HttpClient plugin should collect the parameters of the request
+# This config item controls that whether the HttpClient plugin should collect the parameters of the request
plugin.httpclient.collect_http_params=${SW_PLUGIN_HTTPCLIENT_COLLECT_HTTP_PARAMS:false}
+# Comma-separated list of destination ports whose outbound HTTP requests will be completely skipped by the httpclient-4.x interceptor (no exit span created, no sw8 headers injected). Default: 8123 (ClickHouse HTTP interface).
+plugin.httpclient.propagation_exclude_ports=${SW_PLUGIN_HTTPCLIENT_PROPAGATION_EXCLUDE_PORTS:8123}
Review Comment:
This should not be added as a default. This config should only exist in ck test cases.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix: add PROPAGATION_EXCLUDE_PORTS to httpclient-4.x plugin [skywalking-java]
Posted by "wu-sheng (via GitHub)" <gi...@apache.org>.
wu-sheng commented on code in PR #800:
URL: https://github.com/apache/skywalking-java/pull/800#discussion_r2993226371
##########
apm-sniffer/apm-sdk-plugin/httpclient-commons/src/main/java/org/apache/skywalking/apm/plugin/httpclient/HttpClientPluginConfig.java:
##########
@@ -28,6 +28,24 @@ public static class HttpClient {
* This config item controls that whether the HttpClient plugin should collect the parameters of the request.
*/
public static boolean COLLECT_HTTP_PARAMS = false;
+
+ /**
+ * Comma-separated list of destination ports whose outbound HTTP requests
+ * will be completely skipped by the httpclient-4.x interceptor: no exit
+ * span is created and no SkyWalking propagation headers are injected.
+ *
+ * <p>Some HTTP-based database protocols (e.g. ClickHouse on port 8123)
+ * reject requests that contain unknown HTTP headers, returning HTTP 400.
+ * Adding such ports here prevents the agent from creating exit spans
+ * and from injecting the {@code sw8} tracing headers into those outbound
+ * requests.
+ *
+ * <p>Default: {@code "8123"} (ClickHouse HTTP interface).
+ *
+ * <p>Example – also exclude port 9200 (Elasticsearch):
+ * {@code plugin.httpclient.propagation_exclude_ports=8123,9200}
+ */
+ public static String PROPAGATION_EXCLUDE_PORTS = "8123";
Review Comment:
This default value should be removed. No default to exclude. The config item `plugin.httpclient.propagation_exclude_ports` should be a part of config file, but also have an empty value.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix: add PROPAGATION_EXCLUDE_PORTS to httpclient-4.x plugin [skywalking-java]
Posted by "wu-sheng (via GitHub)" <gi...@apache.org>.
wu-sheng commented on PR #800:
URL: https://github.com/apache/skywalking-java/pull/800#issuecomment-4131128527
https://github.com/apache/skywalking-java/pull/797 should have fixed this? Is CK using 4.x and 5.x?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix: add PROPAGATION_EXCLUDE_PORTS to httpclient-4.x plugin [skywalking-java]
Posted by "daguimu (via GitHub)" <gi...@apache.org>.
daguimu commented on PR #800:
URL: https://github.com/apache/skywalking-java/pull/800#issuecomment-4131441444
Thanks for the review! PR #797 added `PROPAGATION_EXCLUDE_PORTS` to the **httpclient-5.x** plugin. However, ClickHouse JDBC v0.3.1 (used in the `clickhouse-0.3.1-scenario` E2E test) uses **Apache HttpClient 4.5.13** (`org.apache.http.impl.client.CloseableHttpClient`) as its HTTP transport, which is intercepted by the **httpclient-4.x** plugin — a separate plugin that doesn't have this feature yet.
This PR adds the same `PROPAGATION_EXCLUDE_PORTS` support to the httpclient-4.x plugin to cover this case.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix: add PROPAGATION_EXCLUDE_PORTS to httpclient-4.x plugin [skywalking-java]
Posted by "daguimu (via GitHub)" <gi...@apache.org>.
daguimu commented on PR #800:
URL: https://github.com/apache/skywalking-java/pull/800#issuecomment-4131464511
The issue reporter in [apache/skywalking#13700](https://github.com/apache/skywalking/issues/13700) confirmed the problem is caused by the httpclient-4.x plugin — their workaround was `SW_EXCLUDE_PLUGINS=httpclient-4.x`.
This fix is not specific to ClickHouse JDBC v0.3.1 — any application using Apache HttpClient 4.x to communicate with a server that rejects unknown headers (e.g., ClickHouse on port 8123) would be affected. Apache HttpClient 4.x (`org.apache.httpcomponents:httpclient`) remains widely used in the Java ecosystem.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix: add PROPAGATION_EXCLUDE_PORTS to httpclient-4.x plugin [skywalking-java]
Posted by "wu-sheng (via GitHub)" <gi...@apache.org>.
wu-sheng commented on code in PR #800:
URL: https://github.com/apache/skywalking-java/pull/800#discussion_r2993252636
##########
test/plugin/scenarios/clickhouse-0.3.1-scenario/configuration.yml:
##########
@@ -20,6 +20,7 @@ healthCheck: http://localhost:8080/clickhouse-scenario/case/healthCheck
startScript: ./bin/startup.sh
environment:
- SW_JDBC_TRACE_SQL_PARAMETERS=true
+ - SW_PLUGIN_HTTPCLIENT_PROPAGATION_EXCLUDE_PORTS=8123
Review Comment:
This never works, if you don't put the config in the agent.config. The plugin test passed just because you hard coded default value.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix: add PROPAGATION_EXCLUDE_PORTS to httpclient-4.x plugin [skywalking-java]
Posted by "wu-sheng (via GitHub)" <gi...@apache.org>.
wu-sheng merged PR #800:
URL: https://github.com/apache/skywalking-java/pull/800
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org