Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add batchprocessor support for client metadata #7578

Merged
merged 33 commits into from
May 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
ecc2658
Add batchprocessor support for client metadata
Mar 6, 2023
2551923
typos
Mar 6, 2023
7798332
one more test & comments
Mar 9, 2023
fd9a671
remove explicit use of otel/attribute
Mar 13, 2023
350e726
Update processor/batchprocessor/batch_processor.go
codeboten Mar 24, 2023
51e5092
Update processor/batchprocessor/batch_processor.go
codeboten Mar 27, 2023
01cfea3
Merge branch 'main' of github.com:open-telemetry/opentelemetry-collector
Mar 27, 2023
518ca6d
add detailed validation error, update comment
Mar 27, 2023
49c6c53
ensure uniqueness of empty string/slice
Mar 27, 2023
7cf6a65
add a limit
Mar 27, 2023
ccc94e8
add an otel metric
Mar 27, 2023
0e17348
lint
Mar 27, 2023
c91d95e
Merge branch 'main' of github.com:open-telemetry/opentelemetry-collector
Mar 28, 2023
4c66635
restore file
Mar 28, 2023
aca2df5
detab
Mar 28, 2023
c5d05e8
Apply suggestions from code review
jmacd Mar 29, 2023
0bcd804
add the default const
Mar 29, 2023
12528d1
Merge branch 'main' of github.com:open-telemetry/opentelemetry-collector
Apr 5, 2023
de35032
go back to otel-go attribute.Set
Apr 5, 2023
37805d9
document the cardinality metric
Apr 5, 2023
0f95a85
avoid math/rand in test
Apr 5, 2023
41462c8
document constant
Apr 5, 2023
fa0452c
use errors.New
Apr 5, 2023
1ea50ee
use int, not uint32
Apr 5, 2023
6728d37
fix error string
Apr 5, 2023
8cf701d
make singleBatcher, multiBatcher
Apr 5, 2023
5cfdde8
Update processor/batchprocessor/config.go
jmacd Apr 5, 2023
9ab2157
lint
Apr 5, 2023
23e9849
Merge branch 'main' of github.com:open-telemetry/opentelemetry-collec…
Apr 26, 2023
e7a7919
raise default to 1000
Apr 26, 2023
f48353a
fix test
Apr 26, 2023
66b5fa5
Merge branch 'main' of github.com:open-telemetry/opentelemetry-collec…
May 3, 2023
46fc527
missed file
May 3, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .chloggen/batchprocessor-metadata.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: enhancement

# The name of the component, or a single word describing the area of concern, (e.g. otlpreceiver)
component: batchprocessor

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Add support for batching by metadata keys.

# One or more tracking issues or pull requests related to the change
issues: [4544]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext:
47 changes: 47 additions & 0 deletions processor/batchprocessor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,15 @@ ignored as data will be sent immediately, subject to only `send_batch_max_size`.
`0` means no upper limit of the batch size.
This property ensures that larger batches are split into smaller units.
It must be greater than or equal to `send_batch_size`.
- `metadata_keys` (default = empty): When set, this processor will
create one batcher instance per distinct combination of values in
the `client.Metadata`.
- `metadata_cardinality_limit` (default = 1000): When `metadata_keys` is
not empty, this setting limits the number of unique combinations of
metadata key values that will be processed over the lifetime of the
process.

See notes about metadata batching below.

Examples:

Expand Down Expand Up @@ -60,6 +69,44 @@ processors:
Refer to [config.yaml](./testdata/config.yaml) for detailed
examples on using the processor.

## Batching and client metadata

Batching by metadata enables support for multi-tenant OpenTelemetry
Collector pipelines with batching over groups of data having the same
authorization metadata. For example:

```yaml
processors:
batch:
# batch data by tenant-id
metadata_keys:
- tenant_id

# limit to 10 batcher processes before raising errors
metadata_cardinality_limit: 10
```

Receivers should be configured with `include_metadata: true` so that
metadata keys are available to the processor.

Note that each distinct combination of metadata triggers the
allocation of a new background task in the Collector that runs for the
lifetime of the process, and each background task holds one pending
batch of up to `send_batch_size` records. Batching by metadata can
therefore substantially increase the amount of memory dedicated to
batching.

The maximum number of distinct combinations is limited to the
configured `metadata_cardinality_limit`, which defaults to 1000 to
limit memory impact.

Users of the batching processor configured with metadata keys should
consider use of an Auth extension to validate the relevant
metadata-key values.

The number of batch processors currently in use is exported as the
`otelcol_processor_batch_metadata_cardinality` metric.

[beta]: https://github.com/open-telemetry/opentelemetry-collector#beta
[contrib]: https://github.com/open-telemetry/opentelemetry-collector-releases/tree/main/distributions/otelcol-contrib
[core]: https://github.com/open-telemetry/opentelemetry-collector-releases/tree/main/distributions/otelcol
Loading