Skip to content

Commit 8546eff

Browse files
authored
feat: Badger Storage Extension (#2973)
* badger storage extension * make add-license * include in package * fix race condition in log * make extension-test platform agnostic * align expectations for test * attempt to fix race condition * address PR feedback * rename BindPlane => Bindplane * resolve the blobgarbagecolleciton interval issue * change erorr message :)
1 parent e777fc9 commit 8546eff

22 files changed

Lines changed: 3237 additions & 7 deletions

docs/extensions.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ Below is a list of supported extensions with links to their documentation pages.
99
| Authenticator - OAuth2 Client Credentials | [oauth2clientauthextension](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/v0.140.1/extension/oauth2clientauthextension/README.md) |
1010
| Authenticator - OIDC Extension | [oidcauthextension](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/v0.140.1/extension/oidcauthextension/README.md) |
1111
| Authenticator - Sigv4 Extension | [sigv4authextension](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/v0.140.1/extension/sigv4authextension/README.md) |
12-
| BindPlane Extension | [bindplaneextension](../extension/bindplaneextension/README.md) |
12+
| Badger Storage Extension | [badgerextension](../extension/badgerextension/README.md) |
13+
14+
| Bindplane Extension | [bindplaneextension](../extension/bindplaneextension/README.md) |
1315
| Cgroup Runtime Extension | [cgroupruntimeextension](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/v0.140.1/extension/cgroupruntimeextension) |
1416
| Encoding - AVRO Log Extension | [avrologencodingextension](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/v0.140.1/extension/encoding/avrologencodingextension/README.md) |
1517
| Encoding - Google Cloud Log Entry Extension | [googlecloudlogentryencodingextension](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/v0.140.1/extension/encoding/googlecloudlogentryencodingextension/README.md) |
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
# Badger Extension
2+
3+
The Badger Extension provides persistent storage for OpenTelemetry Collector components using [BadgerDB](https://github.com/dgraph-io/badger), a fast embeddable key-value database written in Go. Each component receives an isolated BadgerDB instance for data isolation and reliability.
4+
5+
## Configuration
6+
7+
| Field | Type | Default | Required | Description |
8+
| ----------------------------- | -------- | ------- | -------- | ------------------------------------------------------------------------------------------------- |
9+
| directory.path | string | | `true` | Directory path where BadgerDB files will be stored. Each component gets a subdirectory. |
10+
| sync_writes | bool | `false` | `false` | Whether to sync writes to disk immediately. `false` survives process crashes via mmap. |
11+
| memory.table_size | int64 | 67108864 (64MB) | `false` | Size of each memtable in bytes. Larger values improve write performance but use more memory. |
12+
| memory.block_cache_size | int64 | 268435456 (256MB) | `false` | Size of block cache in bytes. Larger values improve read performance but use more memory. |
13+
| blob_garbage_collection.interval | duration | 5m | `false` | Interval at which garbage collection runs on value logs. Set to 0 to disable. |
14+
| blob_garbage_collection.discard_ratio | float | 0.5 | `false` | Fraction of invalid data in a value log file to trigger GC. Must be between 0 and 1. |
15+
16+
## Example Configuration
17+
18+
### Basic Configuration
19+
20+
```yaml
21+
extensions:
22+
badger:
23+
directory:
24+
path: /var/lib/otelcol/badger
25+
26+
processors:
27+
batch:
28+
storage: badger
29+
30+
exporters:
31+
otlp:
32+
endpoint: otelcol:4317
33+
34+
service:
35+
extensions: [badger]
36+
pipelines:
37+
logs:
38+
receivers: [otlp]
39+
processors: [batch]
40+
exporters: [otlp]
41+
```
42+
43+
## Advanced Configuration
44+
45+
This extension uses BadgerDB's defaults, which are optimized for most production workloads. The defaults provide a balance of performance, memory usage, and durability suitable for telemetry storage.
46+
47+
For advanced use cases, the following configuration levers are exposed:
48+
49+
- **memory.table_size** and **memory.block_cache_size**: Control memory allocation. Only adjust if you have specific memory constraints or performance requirements.
50+
- **blob_garbage_collection**: Controls disk space reclamation. The defaults (5m interval, 0.5 discard ratio) work well for most scenarios.
51+
- **sync_writes**: Controls write durability. The default (`false`) provides good performance while surviving process crashes via memory-mapped writes.
52+
53+
Refer to the [BadgerDB documentation](https://dgraph.io/docs/badger/) for detailed information about these settings.
54+
55+
Full configuration example:
56+
57+
```yaml
58+
extensions:
59+
badger:
60+
directory:
61+
path: /var/lib/otelcol/badger
62+
sync_writes: true
63+
memory:
64+
table_size: 134217728 # 128MB
65+
block_cache_size: 536870912 # 512MB
66+
blob_garbage_collection:
67+
interval: 10m
68+
discard_ratio: 0.6
69+
70+
processors:
71+
batch:
72+
storage: badger
73+
74+
exporters:
75+
otlp:
76+
endpoint: otelcol:4317
77+
78+
service:
79+
extensions: [badger]
80+
pipelines:
81+
logs:
82+
receivers: [otlp]
83+
processors: [batch]
84+
exporters: [otlp]
85+
86+
```
87+
88+
## Component Isolation
89+
90+
Each component that uses the badger extension gets an isolated database instance at:
91+
92+
```
93+
{directory.path}/{kind}_{type}_{component_name}_{name}/
94+
```
95+
96+
For example, with `directory.path: $OIQ_OTEL_COLLECTOR_STORAGE`:
97+
98+
```
99+
$OIQ_OTEL_COLLECTOR_STORAGE/processor_batch_default/
100+
$OIQ_OTEL_COLLECTOR_STORAGE/exporter_otlp_backup/
101+
```
102+
103+
This ensures components cannot interfere with each other's data.

0 commit comments

Comments
 (0)