Debian Codegraph @

processor/batchprocessor/README.md

raw
1 # Batch Processor
2
3 <!-- status autogenerated section -->
4 | Status | |
5 | ------------- |-----------|
6 | Stability | [beta]: traces, metrics, logs |
7 | Distributions | [core], [contrib], [k8s] |
8 | Issues | [![Open issues](https://img.shields.io/github/issues-search/open-telemetry/opentelemetry-collector?query=is%3Aissue%20is%3Aopen%20label%3Aprocessor%2Fbatch%20&label=open&color=orange&logo=opentelemetry)](https://github.com/open-telemetry/opentelemetry-collector/issues?q=is%3Aopen+is%3Aissue+label%3Aprocessor%2Fbatch) [![Closed issues](https://img.shields.io/github/issues-search/open-telemetry/opentelemetry-collector?query=is%3Aissue%20is%3Aclosed%20label%3Aprocessor%2Fbatch%20&label=closed&color=blue&logo=opentelemetry)](https://github.com/open-telemetry/opentelemetry-collector/issues?q=is%3Aclosed+is%3Aissue+label%3Aprocessor%2Fbatch) |
9
10 [beta]: https://github.com/open-telemetry/opentelemetry-collector/blob/main/docs/component-stability.md#beta
11 [core]: https://github.com/open-telemetry/opentelemetry-collector-releases/tree/main/distributions/otelcol
12 [contrib]: https://github.com/open-telemetry/opentelemetry-collector-releases/tree/main/distributions/otelcol-contrib
13 [k8s]: https://github.com/open-telemetry/opentelemetry-collector-releases/tree/main/distributions/otelcol-k8s
14 <!-- end autogenerated section -->
15
16 The batch processor accepts spans, metrics, or logs and places them into
17 batches. Batching helps better compress the data and reduce the number of
18 outgoing connections required to transmit the data. This processor supports
19 both size and time based batching.
20
21 The batch processor should be defined in the pipeline after the `memory_limiter`
22 as well as any sampling processors. This is because batching should happen after
23 any data drops such as sampling.
24
25 Please refer to [config.go](./config.go) for the config spec.
26
27 The following configuration options can be modified:
28 - `send_batch_size` (default = 8192): Number of spans, metric data points, or log
29 records after which a batch will be sent regardless of the timeout. `send_batch_size`
30 acts as a trigger and does not affect the size of the batch. If you need to
31 enforce batch size limits sent to the next component in the pipeline
32 see `send_batch_max_size`.
33 - `timeout` (default = 200ms): Time duration after which a batch will
34 be sent regardless of size. If set to zero, `send_batch_size` is
35 ignored as data will be sent immediately, subject to only `send_batch_max_size`.
36 - `send_batch_max_size` (default = 0): The upper limit of the batch size.
37 `0` means no upper limit of the batch size.
38 This property ensures that larger batches are split into smaller units.
39 It must be greater than or equal to `send_batch_size`.
40 - `metadata_keys` (default = empty): When set, this processor will
41 create one batcher instance per distinct combination of values in
42 the `client.Metadata`.
43 - `metadata_cardinality_limit` (default = 1000): When `metadata_keys` is
44 not empty, this setting limits the number of unique combinations of
45 metadata key values that will be processed over the lifetime of the
46 process.
47
48 See notes about metadata batching below.
49
50 Examples:
51
52 This configuration contains one default batch processor and a second
53 with custom settings. The `batch/2` processor will buffer up to 10000
54 spans, metric data points, or log records for up to 10 seconds without
55 splitting data items to enforce a maximum batch size.
56
57 ```yaml
58 processors:
59 batch:
60 batch/2:
61 send_batch_size: 10000
62 timeout: 10s
63 ```
64
65 This configuration will enforce a maximum batch size limit of 10000
66 spans, metric data points, or log records without introducing any
67 artificial delays.
68
69 ```yaml
70 processors:
71 batch:
72 send_batch_max_size: 10000
73 timeout: 0s
74 ```
75
76 Refer to [config.yaml](./testdata/config.yaml) for detailed
77 examples on using the processor.
78
79 ## Batching and client metadata
80
81 Batching by metadata enables support for multi-tenant OpenTelemetry
82 Collector pipelines with batching over groups of data having the same
83 authorization metadata. For example:
84
85 ```yaml
86 processors:
87 batch:
88 # batch data by tenant-id
89 metadata_keys:
90 - tenant_id
91
92 # limit to 10 batcher processes before raising errors
93 metadata_cardinality_limit: 10
94 ```
95
96 Receivers should be configured with `include_metadata: true` so that
97 metadata keys are available to the processor.
98
99 Note that each distinct combination of metadata triggers the
100 allocation of a new background task in the Collector that runs for the
101 lifetime of the process, and each background task holds one pending
102 batch of up to `send_batch_size` records. Batching by metadata can
103 therefore substantially increase the amount of memory dedicated to
104 batching.
105
106 The maximum number of distinct combinations is limited to the
107 configured `metadata_cardinality_limit`, which defaults to 1000 to
108 limit memory impact.
109
110 Users of the batching processor configured with metadata keys should
111 consider use of an Auth extension to validate the relevant
112 metadata-key values.
113
114 The number of batch processors currently in use is exported as the
115 `otelcol_processor_batch_metadata_cardinality` metric.