Payload Collection Instrumentation Rule
The “Payload Collection” Rule can be used to add span attributes containing payload data to traces.
In many cases, the payload data can provide valuable context for understanding the behavior of your application.
Considerations
Before enabling payload collection, please note the following:
- PII (Personally Identifiable Information) and other potentially sensitive data may be present in the payload. Evaluate the risk of collecting this data, and consider using the PII Masking Action to mask sensitive data.
- Payload data can be large and may increase the size of your traces. This can impact the performance of your application and the cost of processing, storing and analyzing traces.
- The support for payload collection varies between instrumentation libraries and languages. Not all libraries support payload collection, and the supported payload types and formats may differ. Consult the documentation of the instrumentation library you are using for more information.
Basic Example
The following example demonstrates how to enable payload collection for all supported workloads and instrumentation libraries in the cluster.
Create a file named payloadcollection.yaml
with the following content:
Apply the action to the cluster:
Full Example
The following example is a demonstration of all the options available in the “Payload Collection” Rule. It is not meant to be used “as is”, but rather as a reference to customize the rule to your needs.
Create a file named full-payload-collection-example.yaml
with the following content:
Apply the action to the cluster:
Configuration Options
The full list of configuration options for the “Payload Collection” Rule are:
-
httpRequest
(optional): Collect HTTP request payload data when available. Can be a client (outgoing) request or a server (incoming) request, depending on the instrumentation librarymimeTypes
(optional, default is nil - all mime types): Limit payload collection to specific mime types based on the content type header. When not specified, all mime types payloads will be collected. empty array will make the rule ineffective.maxPayloadLength
(optional): Maximum length of the payload to collect. If the payload is longer than this value, it will be truncated or dropped, based on the value ofdropPartialPayloads
config option. When not specified (recommended), the instrumentation library will use any reasonable default value.dropPartialPayloads
(optional, default is false): If the payload is larger than the MaxPayloadLength, this parameter will determine if the payload should be partially collected up to the allowed length, or not collected at all. This is useful if you require some decoding of the payload (like json) and having it partially is not useful.
-
httpResponse
(optional): Collect HTTP response payload data when available. Can be a client (incoming) response or a server (outgoing) response, depending on the instrumentation librarymimeTypes
(optional, default is nil - all mime types): Limit payload collection to specific mime types based on the content type header. When not specified, all mime types payloads will be collected. empty array will make the rule ineffective.maxPayloadLength
(optional): Maximum length of the payload to collect. If the payload is longer than this value, it will be truncated or dropped, based on the value ofdropPartialPayloads
config option. When not specified (recommended), the instrumentation library will use any reasonable default valuedropPartialPayloads
(optional, default is false): If the payload is larger than the MaxPayloadLength, this parameter will determine if the payload should be partially collected up to the allowed length, or not collected at all. This is useful if you require some decoding of the payload (like json) and having it partially is not useful.
-
dbQuery
(optional): Collect database query payload info when available.maxPayloadLength
(optional): Maximum length of the payload to collect. If the payload is longer than this value, it will be truncated or dropped, based on the value ofdropPartialPayloads
config option. When not specified (recommended), the instrumentation library will use any reasonable default valuedropPartialPayloads
(optional, default is false): If the payload is larger than the MaxPayloadLength, this parameter will determine if the payload should be partially collected up to the allowed length, or not collected at all. This is useful if you require some decoding of the payload (like json) and having it partially is not useful.
-
messaging
(optional): Collect messaging system operation payload info when available.maxPayloadLength
(optional): Maximum length of the payload to collect. If the payload is longer than this value, it will be truncated or dropped, based on the value ofdropPartialPayloads
config option. When not specified (recommended), the instrumentation library will use any reasonable default valuedropPartialPayloads
(optional, default is false): If the payload is larger than the MaxPayloadLength, this parameter will determine if the payload should be partially collected up to the allowed length, or not collected at all. This is useful if you require some decoding of the payload (like json) and having it partially is not useful.
Merging Rules
- Any payload collection rule for a specific instrumentation library will take precedence over a rule that does not specify a library.
- If multiple rules are defined for the same source, the rules will be merged together. Any conflicting options will be resolved by taking the “safest” option.
- Any unspecified options will fallback to a reasonable default value provided by the instrumentation library (recommended).