From 86b87b65bcc1f385ab12095b763247dfc0d622d9 Mon Sep 17 00:00:00 2001 From: Jonas Kunz Date: Tue, 27 Aug 2024 13:19:26 +0200 Subject: [PATCH 1/2] Make capture_http_client_request_body_size config option public --- .../configuration/WebConfiguration.java | 10 +++-- docs/configuration.asciidoc | 42 +++++++++++++++++++ 2 files changed, 48 insertions(+), 4 deletions(-) diff --git a/apm-agent-tracer/src/main/java/co/elastic/apm/agent/tracer/configuration/WebConfiguration.java b/apm-agent-tracer/src/main/java/co/elastic/apm/agent/tracer/configuration/WebConfiguration.java index 2a35facaf5..d26ba047e1 100644 --- a/apm-agent-tracer/src/main/java/co/elastic/apm/agent/tracer/configuration/WebConfiguration.java +++ b/apm-agent-tracer/src/main/java/co/elastic/apm/agent/tracer/configuration/WebConfiguration.java @@ -129,10 +129,12 @@ public class WebConfiguration extends ConfigurationOptionProvider { .addValidator(isInRange(0, MAX_BODY_CAPTURE_BYTES)) .key("capture_http_client_request_body_size") .configurationCategory(HTTP_CATEGORY) - .tags("added[1.50.0]", "internal") - .description("Configures how many bytes of http-client request bodies shall be captured. " + - "Note that only request bodies will be captured for content types matching the capture_body_content_types configuration. " + - " The maximum allowed value is " + MAX_BODY_CAPTURE_BYTES + " , a value of 0 disables body capturing") + .tags("added[1.52.0]", "experimental") + .description("Configures that the first n bytes of http-client request bodies shall be captured. " + + "Note that only request bodies will be captured for content types matching the <> configuration. " + + "The maximum allowed value is " + MAX_BODY_CAPTURE_BYTES + ", a value of 0 disables body capturing.\n\n" + + "Currently only support for Apache Http Client v4 and v5, HttpUrlConnection, Spring Webflux WebClient and other frameworks building on top of these (e.g. Spring RestTemplate).\n\n" + + "The body will be stored in the `labels.http_request_body_content` field on the span documents.") .dynamic(true) .buildWithDefault(0); diff --git a/docs/configuration.asciidoc b/docs/configuration.asciidoc index 3d124b4b2d..df9bf45204 100644 --- a/docs/configuration.asciidoc +++ b/docs/configuration.asciidoc @@ -147,6 +147,7 @@ Click on a key to get more information. ** <> ** <> ** <> +** <> * <> ** <> ** <> @@ -1829,6 +1830,35 @@ Prepending an element with `(?-i)` makes the matching case sensitive. | `elastic.apm.url_groups` | `url_groups` | `ELASTIC_APM_URL_GROUPS` |============ +// This file is auto generated. Please make your changes in *Configuration.java (for example CoreConfiguration.java) and execute ConfigurationExporter +[float] +[[config-capture-http-client-request-body-size]] +==== `capture_http_client_request_body_size` (added[1.52.0] experimental) + +NOTE: This feature is currently experimental, which means it is disabled by default and it is not guaranteed to be backwards compatible in future releases. + +Configures that the first n bytes of http-client request bodies shall be captured. Note that only request bodies will be captured for content types matching the <> configuration. The maximum allowed value is 1024, a value of 0 disables body capturing. + +Currently only support for Apache Http Client v4 and v5, HttpUrlConnection, Spring Webflux WebClient and other frameworks building on top of these (e.g. Spring RestTemplate). + +The body will be stored in the `labels.http_request_body_content` field on the span documents. + +<> + + +[options="header"] +|============ +| Default | Type | Dynamic +| `0` | Integer | true +|============ + + +[options="header"] +|============ +| Java System Properties | Property file | Environment +| `elastic.apm.capture_http_client_request_body_size` | `capture_http_client_request_body_size` | `ELASTIC_APM_CAPTURE_HTTP_CLIENT_REQUEST_BODY_SIZE` +|============ + [[config-huge-traces]] === Huge Traces configuration options @@ -4331,6 +4361,18 @@ Example: `5ms`. # # url_groups= +# Configures that the first n bytes of http-client request bodies shall be captured. Note that only request bodies will be captured for content types matching the <> configuration. The maximum allowed value is 1024, a value of 0 disables body capturing. +# +# Currently only support for Apache Http Client v4 and v5, HttpUrlConnection, Spring Webflux WebClient and other frameworks building on top of these (e.g. Spring RestTemplate). +# +# The body will be stored in the `labels.http_request_body_content` field on the span documents. +# +# This setting can be changed at runtime +# Type: Integer +# Default value: 0 +# +# capture_http_client_request_body_size=0 + ############################################ # Huge Traces # ############################################ From 3c1e6add79ab129b2928cee0683ad481a0673892 Mon Sep 17 00:00:00 2001 From: Jonas Kunz Date: Tue, 27 Aug 2024 13:24:23 +0200 Subject: [PATCH 2/2] Added changelog --- CHANGELOG.asciidoc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc index 4502be6cea..864acac52b 100644 --- a/CHANGELOG.asciidoc +++ b/CHANGELOG.asciidoc @@ -35,6 +35,10 @@ Use subheadings with the "=====" level for adding notes for unreleased changes: ===== Bug fixes * Fix log4j2 log correlation with shaded application jar - {pull}3764[#3764] +[float] +===== Features +* Added experimental option to capture HTTP client request bodies for Apache Http Client v4 and v5, HttpUrlConnection and Spring WebClient - {pull}3776[#3776], {pull}3962[#3962], {pull}3724[#3724], {pull}3754[#3754], {pull}3767[#3767] + [[release-notes-1.x]] === Java Agent version 1.x