> ## Documentation Index
> Fetch the complete documentation index at: https://docs.odigos.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Headers Collection

> The "Headers Collection" rule can be used to add span attributes by collecting HTTP Headers data.

## Considerations

<Warning>
  Before enabling **headers collection**, please note the following:

  * The support for headers collection varies between instrumentation libraries and languages.
  * HTTP headers might contain PII data (like cookies or API keys), thus it is recommended to review each requested header before configuring it to avoid sensitive information.
</Warning>

## Configuration Options

<AccordionGroup>
  <Accordion title="headerKeys">
    **headerKeys** `string[]` : Limit payload collection to specific header keys.

    * This field is *optional*
    * If not specified, no headers will be collected.
    * If set to `["*"]`, all supported headers will be collected.
  </Accordion>
</AccordionGroup>

<Note>
  Any unspecified headers will not be recorded.
</Note>

## Basic Example

The following example demonstrates how to enable headers collection for all supported workloads and instrumentation libraries in the cluster.

<Steps>
  <Step>
    Create a YAML file with the following content:

    ```yaml headers-collection.yaml theme={null}
    apiVersion: odigos.io/v1alpha1
    kind: InstrumentationRule
    metadata:
      name: collect-all-headers
      namespace: odigos-system
    spec:
      ruleName: "collect all supported headers"
      headersCollection:
        headerKeys: ["*"]
    ```
  </Step>

  <Step>
    Apply the action to the cluster:

    ```shell theme={null}
    kubectl apply -f headers-collection.yaml
    ```
  </Step>
</Steps>
