From 3cb7fb3cfd58cc5460d587f1282b52bcddb55b20 Mon Sep 17 00:00:00 2001 From: Shashank Patidar Date: Wed, 7 Apr 2021 20:13:09 +0530 Subject: [PATCH 1/2] adding custom data capture endpoint --- ENV_VARS.md | 1 + config.proto | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/ENV_VARS.md b/ENV_VARS.md index 52af912..4a40830 100644 --- a/ENV_VARS.md +++ b/ENV_VARS.md @@ -26,3 +26,4 @@ Agents can be configured using environment variables: | HT_PROPAGATION_FORMATS | List the supported propagation formats e.g. `HT_PROPAGATION_FORMATS="B3,TRACECONTEXT"`. | | HT_ENABLED | When `false`, disables the agent | | HT_JAVAAGENT_FILTER_JAR_PATHS | Is the list of path to filter jars, separated by `,`. | +| HT_CUSTOM_DATA_CAPTURE_ENDPOINTS | List the custom endpoints with respective data capture rules. | diff --git a/config.proto b/config.proto index 7987462..a642900 100644 --- a/config.proto +++ b/config.proto @@ -33,6 +33,9 @@ message AgentConfig { // resource_attributes map define the static list of resources which is configured on the tracer map resource_attributes = 7; + + // custom_data_capture_endpoints list the custom endpoints with respective data capture rules + repeated CustomDataCaptureEndpoint custom_data_capture_endpoints = 8; } // Reporting covers the options related to the mechanics for sending data to the @@ -127,3 +130,17 @@ message JavaAgent { // filter_jar_paths is the list of path to filter jars, separated by `,` repeated google.protobuf.StringValue filter_jar_paths = 1; } + +// CustomDataCaptureEndpoint represents a custom data capture rule for an endpoint that matches +// the given url pattern and host header +message CustomDataCaptureEndpoint { + + // data_capture describes the data being captured by instrumentation for this endpoint + DataCapture data_capture = 1; + + // url_pattern describes the url pattern to match for this endpoint + google.protobuf.StringValue url_pattern = 2; + + // host_header describes the host header to match for this endpoint + google.protobuf.StringValue host_header = 3; +} From 6a5d700a4121c8ff81adf8fc727bd582d83f0cda Mon Sep 17 00:00:00 2001 From: Shashank Patidar Date: Fri, 9 Apr 2021 10:42:00 +0530 Subject: [PATCH 2/2] using existing DataCapture by making it repeated and adding path_pattern to it --- ENV_VARS.md | 11 +---------- config.proto | 30 ++++++++++-------------------- 2 files changed, 11 insertions(+), 30 deletions(-) diff --git a/ENV_VARS.md b/ENV_VARS.md index 4a40830..1291f92 100644 --- a/ENV_VARS.md +++ b/ENV_VARS.md @@ -14,16 +14,7 @@ Agents can be configured using environment variables: | HT_REPORTING_OPA_ENDPOINT | Represents the endpoint for polling OPA config file e.g. http://opa.traceableai:8181/ | | HT_REPORTING_OPA_POLL_PERIOD_SECONDS | Poll period in seconds to query OPA service | | HT_REPORTING_OPA_ENABLED | When `true` Open Policy Agent evaluation is enabled to block request | -| HT_DATA_CAPTURE_HTTP_HEADERS_REQUEST | When `false` it disables the capture for the request in a client/request operation | -| HT_DATA_CAPTURE_HTTP_HEADERS_RESPONSE | When `false` it disables the capture for the response in a client/request operation | -| HT_DATA_CAPTURE_HTTP_BODY_REQUEST | When `false` it disables the capture for the request in a client/request operation | -| HT_DATA_CAPTURE_HTTP_BODY_RESPONSE | When `false` it disables the capture for the response in a client/request operation | -| HT_DATA_CAPTURE_RPC_METADATA_REQUEST | When `false` it disables the capture for the request in a client/request operation | -| HT_DATA_CAPTURE_RPC_METADATA_RESPONSE | When `false` it disables the capture for the response in a client/request operation | -| HT_DATA_CAPTURE_RPC_BODY_REQUEST | When `false` it disables the capture for the request in a client/request operation | -| HT_DATA_CAPTURE_RPC_BODY_RESPONSE | When `false` it disables the capture for the response in a client/request operation | -| HT_DATA_CAPTURE_BODY_MAX_SIZE_BYTES | Maximum size of captured body in bytes. Default should be 131_072 (128 KiB). | +| HT_DATA_CAPTURE | Lists the rules for data being captured by instrumentation. The first rule in config that matches for a path should be used if multiple rules match. Therefore the default rule (if present) should be the last rule. If no default rule is given, the default behaviour should be to allow data capture for all elements. | | HT_PROPAGATION_FORMATS | List the supported propagation formats e.g. `HT_PROPAGATION_FORMATS="B3,TRACECONTEXT"`. | | HT_ENABLED | When `false`, disables the agent | | HT_JAVAAGENT_FILTER_JAR_PATHS | Is the list of path to filter jars, separated by `,`. | -| HT_CUSTOM_DATA_CAPTURE_ENDPOINTS | List the custom endpoints with respective data capture rules. | diff --git a/config.proto b/config.proto index a642900..82bcb1a 100644 --- a/config.proto +++ b/config.proto @@ -19,8 +19,11 @@ message AgentConfig { // reporting holds the reporting settings for the agent Reporting reporting = 2; - // data_capture describes the data being captured by instrumentation - DataCapture data_capture = 3; + // data_capture lists the rules for data being captured by instrumentation. + // The first rule in config that matches for a path should be used if multiple rules match. + // Therefore the default rule (if present) should be the last rule. + // If no default rule is given, the default behaviour should be to allow data capture for all elements + repeated DataCapture data_capture = 3; // propagation_formats list the supported propagation formats repeated PropagationFormat propagation_formats = 4; @@ -33,9 +36,6 @@ message AgentConfig { // resource_attributes map define the static list of resources which is configured on the tracer map resource_attributes = 7; - - // custom_data_capture_endpoints list the custom endpoints with respective data capture rules - repeated CustomDataCaptureEndpoint custom_data_capture_endpoints = 8; } // Reporting covers the options related to the mechanics for sending data to the @@ -81,7 +81,7 @@ message Message { google.protobuf.BoolValue response = 2; } -// DataCapture describes the elements to be captured by the agent instrumentation +// DataCapture describes the elements to be captured by the agent instrumentation for paths that match this rule. message DataCapture { // http_headers enables/disables the capture of the request/response headers in HTTP Message http_headers = 1; @@ -97,6 +97,10 @@ message DataCapture { // maximum size of captured body in bytes. Default should be 131_072 (128 KiB). google.protobuf.Int32Value body_max_size_bytes = 5; + + // path_pattern is the path to match for this data capture rule. + // If path_pattern is not given, this rule will apply to all paths as the default + google.protobuf.StringValue path_pattern = 6; } // PropagationFormat represents the propagation formats supported by agents @@ -130,17 +134,3 @@ message JavaAgent { // filter_jar_paths is the list of path to filter jars, separated by `,` repeated google.protobuf.StringValue filter_jar_paths = 1; } - -// CustomDataCaptureEndpoint represents a custom data capture rule for an endpoint that matches -// the given url pattern and host header -message CustomDataCaptureEndpoint { - - // data_capture describes the data being captured by instrumentation for this endpoint - DataCapture data_capture = 1; - - // url_pattern describes the url pattern to match for this endpoint - google.protobuf.StringValue url_pattern = 2; - - // host_header describes the host header to match for this endpoint - google.protobuf.StringValue host_header = 3; -}