Skip to content

Commit ce3ab6b

Browse files
authored
Merge pull request #211 from streamfold/fanout-multi-consumers2
Support multiple exporters for a pipeline
2 parents a366061 + 53d739d commit ce3ab6b

File tree

5 files changed

+554
-487
lines changed

5 files changed

+554
-487
lines changed

README.md

Lines changed: 61 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -57,27 +57,27 @@ To quickly get started with Rotel you can leverage the bundled [Python](https://
5757
follow these steps:
5858

5959
1. **Running Rotel**
60-
- We use the prebuilt docker image for this example, but you can also download a binary from the
61-
[releases](https://github.com/streamfold/rotel/releases) page.
62-
- Execute Rotel with the following arguments. To debug metrics or logs, add
63-
an additional `--debug-log metrics|logs`.
60+
- We use the prebuilt docker image for this example, but you can also download a binary from the
61+
[releases](https://github.com/streamfold/rotel/releases) page.
62+
- Execute Rotel with the following arguments. To debug metrics or logs, add
63+
an additional `--debug-log metrics|logs`.
6464

6565
```bash
6666
docker run -ti -p 4317-4318:4317-4318 streamfold/rotel --debug-log traces --exporter blackhole
6767
```
6868

69-
- Rotel is now listening on localhost:4317 (gRPC) and localhost:4318 (HTTP).
69+
- Rotel is now listening on localhost:4317 (gRPC) and localhost:4318 (HTTP).
7070

7171
2. **Verify**
72-
- Send OTLP traces to Rotel and verify that it is receiving data:
72+
- Send OTLP traces to Rotel and verify that it is receiving data:
7373

7474
```bash
7575
go install github.com/open-telemetry/opentelemetry-collector-contrib/cmd/telemetrygen@latest
7676

7777
telemetrygen traces --otlp-insecure --duration 5s
7878
```
7979

80-
- Check the output from Rotel and you should see several "Received traces" log lines.
80+
- Check the output from Rotel and you should see several "Received traces" log lines.
8181

8282
## Configuration
8383

@@ -95,7 +95,7 @@ variable `ROTEL_OTLP_GRPC_ENDPOINT=localhost:5317`.
9595
Any option above that does not contain a default is considered false or unset by default.
9696

9797
| Option | Default | Options |
98-
|-----------------------------------|----------------------|--------------------------------------------------------------------|
98+
| --------------------------------- | -------------------- | ------------------------------------------------------------------ |
9999
| --daemon | | |
100100
| --log-format | text | json |
101101
| --pid-file | /tmp/rotel-agent.pid | |
@@ -124,7 +124,7 @@ See the section for [Multiple Exporters](#multiple-exporters) for how to configu
124124
The OTLP exporter is the default, or can be explicitly selected with `--exporter otlp`.
125125

126126
| Option | Default | Options |
127-
|----------------------------------------|---------|------------|
127+
| -------------------------------------- | ------- | ---------- |
128128
| --otlp-exporter-endpoint | | |
129129
| --otlp-exporter-protocol | grpc | grpc, http |
130130
| --otlp-exporter-custom-headers | | |
@@ -192,7 +192,7 @@ The Datadog exporter can be selected by passing `--exporter datadog`. The Datado
192192
moment. For more information, see the [Datadog Exporter](src/exporters/datadog/README.md) docs.
193193

194194
| Option | Default | Options |
195-
|------------------------------------|---------|------------------------|
195+
| ---------------------------------- | ------- | ---------------------- |
196196
| --datadog-exporter-region | us1 | us1, us3, us5, eu, ap1 |
197197
| --datadog-exporter-custom-endpoint | | |
198198
| --datadog-exporter-api-key | | |
@@ -206,7 +206,7 @@ logs,
206206
and traces.
207207

208208
| Option | Default | Options |
209-
|---------------------------------------|---------|-------------|
209+
| ------------------------------------- | ------- | ----------- |
210210
| --clickhouse-exporter-endpoint | | |
211211
| --clickhouse-exporter-database | otel | |
212212
| --clickhouse-exporter-table-prefix | otel | |
@@ -259,7 +259,7 @@ are
259259
automatically sourced from Rotel's environment on startup.
260260

261261
| Option | Default | Options |
262-
|------------------------------------|-----------|------------------|
262+
| ---------------------------------- | --------- | ---------------- |
263263
| --awsxray-exporter-region | us-east-1 | aws region codes |
264264
| --awsxray-exporter-custom-endpoint | | |
265265

@@ -277,7 +277,7 @@ AWS Credentials including `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY` and `AWS_
277277
are automatically sourced from Rotel's environment on startup.
278278

279279
| Option | Default | Options |
280-
|--------------------------------------------------------|------------------|------------------|
280+
| ------------------------------------------------------ | ---------------- | ---------------- |
281281
| --awsemf-exporter-region | us-east-1 | aws region codes |
282282
| --awsemf-exporter-custom-endpoint | | |
283283
| --awsemf-exporter-log-group-name | /metrics/default | |
@@ -335,7 +335,7 @@ The Kafka exporter can be selected by passing `--exporter kafka`. The Kafka expo
335335
logs, and traces.
336336

337337
| Option | Default | Options |
338-
|-----------------------------------------------------------|-------------------|-----------------------------------------------------------------------------|
338+
| --------------------------------------------------------- | ----------------- | --------------------------------------------------------------------------- |
339339
| --kafka-exporter-brokers | localhost:9092 | |
340340
| --kafka-exporter-traces-topic | otlp_traces | |
341341
| --kafka-exporter-metrics-topic | otlp_metrics | |
@@ -482,7 +482,7 @@ out as periodic files on the local filesystem. Currently **Parquet** and
482482
**JSON** formats are supported.
483483

484484
| Option | Default | Description |
485-
|-------------------------------------|------------|--------------------------------------------------------------------------------------------------------------|
485+
| ----------------------------------- | ---------- | ------------------------------------------------------------------------------------------------------------ |
486486
| --file-exporter-format | parquet | `parquet` or `json` |
487487
| --file-exporter-output-dir | /tmp/rotel | Directory to place output files |
488488
| --file-exporter-flush-interval | 5s | How often to flush accumulated telemetry to a new file (accepts Go-style durations like `30s`, `2m`, `1h`) |
@@ -509,7 +509,7 @@ To enable the Kafka receiver, you must specify which telemetry types to consume
509509
- `--kafka-receiver-logs` to consume logs
510510

511511
| Option | Default | Options |
512-
|--------------------------------------------|----------------|------------------------------------------------------|
512+
| ------------------------------------------ | -------------- | ---------------------------------------------------- |
513513
| --kafka-receiver-brokers | localhost:9092 | Kafka broker addresses (comma-separated) |
514514
| --kafka-receiver-traces-topic | otlp_traces | Topic name for traces |
515515
| --kafka-receiver-metrics-topic | otlp_metrics | Topic name for metrics |
@@ -557,9 +557,9 @@ The Kafka receiver acts as a consumer and supports standard Kafka consumer confi
557557
**Offset Management:**
558558

559559
- `--kafka-receiver-auto-offset-reset`: Controls behavior when no initial offset exists or the current offset is invalid
560-
- `earliest`: Start consuming from the beginning of the topic
561-
- `latest`: Start consuming from the end of the topic (default)
562-
- `error`: Throw an error if no offset is found
560+
- `earliest`: Start consuming from the beginning of the topic
561+
- `latest`: Start consuming from the end of the topic (default)
562+
- `error`: Throw an error if no offset is found
563563

564564
**Session and Heartbeat Configuration:**
565565

@@ -577,8 +577,8 @@ The Kafka receiver acts as a consumer and supports standard Kafka consumer confi
577577

578578
- `--kafka-receiver-check-crcs`: Enables CRC32 checking of consumed messages for data integrity
579579
- `--kafka-receiver-isolation-level`: Controls which messages are visible to the consumer
580-
- `read-uncommitted`: Read all messages including those from uncommitted transactions
581-
- `read-committed`: Only read messages from committed transactions (default)
580+
- `read-uncommitted`: Read all messages including those from uncommitted transactions
581+
- `read-committed`: Only read messages from committed transactions (default)
582582

583583
#### Security Configuration
584584

@@ -663,7 +663,7 @@ logs,
663663
or traces). For example, `--traces-batch-max-size` will override the batch max size for traces only.
664664

665665
| Option | Default | Options |
666-
|------------------|---------|---------|
666+
| ---------------- | ------- | ------- |
667667
| --batch-max-size | 8192 | |
668668
| --batch-timeout | 200ms | |
669669

@@ -702,8 +702,8 @@ All options should be represented as string time durations.
702702
### Internal telemetry
703703

704704
Rotel records a number of internal metrics that can help observe Rotel behavior during runtime. This telemetry is
705-
opt-in and must be enabled with `--enable-internal-telemetry`. Telemetry is sent to the OTLP exporter metric endpoint
706-
that you have configured.
705+
opt-in and must be enabled with `--enable-internal-telemetry`. Telemetry is sent to the exporters configured
706+
with the `--exporters-internal-metrics` option.
707707

708708
**NOTE**: Internal telemetry is not sent to any outside sources and you are in full control of where this data is
709709
exported to.
@@ -717,7 +717,7 @@ to receive data via OTLP and consume from Kafka topics at the same time.
717717
The following configuration parameters enable multiple receivers:
718718

719719
| Option | Default | Options |
720-
|-------------|---------|-----------------------------------|
720+
| ----------- | ------- | --------------------------------- |
721721
| --receiver | otlp | otlp, kafka |
722722
| --receivers | | comma-separated list (otlp,kafka) |
723723

@@ -798,17 +798,18 @@ rotel start --exporter otlp --otlp-exporter-endpoint localhost:4317
798798

799799
Rotel can be configured to support exporting to multiple destinations across multiple exporter types.
800800

801-
The following additional configuration parameters set up support for multiple exporters. Similar to the options above,
802-
all
803-
CLI arguments can be passed as environment variables as well. It is not possible to set `--exporter` and `--exporters`
804-
at the same time.
801+
The following additional configuration parameters set up support for multiple
802+
exporters. Similar to the options above, all CLI arguments can be passed as
803+
environment variables as well. It is not possible to set `--exporter` and
804+
`--exporters` at the same time.
805805

806-
| Option | Default | Options |
807-
|---------------------|---------|----------------------------------|
808-
| --exporters | | name:type pairs, comma-separated |
809-
| --exporters-traces | | exporter name |
810-
| --exporters-metrics | | exporter name |
811-
| --exporters-logs | | exporter name |
806+
| Option | Default | Options |
807+
| ---------------------------- | ------- | -------------------------------- |
808+
| --exporters | | name:type pairs, comma-separated |
809+
| --exporters-traces | | exporter name |
810+
| --exporters-metrics | | exporter name |
811+
| --exporters-logs | | exporter name |
812+
| --exporters-internal-metrics | | exporter name |
812813

813814
First start by defining the set of exporters that you would like to use, optionally specifying a custom name for them
814815
to differentiate their configuration options. For example, to export logs and metrics to two separate ClickHouse nodes
@@ -818,19 +819,17 @@ while exporting traces to Datadog, we'll use the following `--exporters` argumen
818819
--exporters logging:clickhouse,stats:clickhouse,datadog
819820
```
820821

821-
The argument form of `--exporters` takes `name:type` pairs separated by commas, where the first part is a custom name
822-
and
823-
the second part is the type of exporter. You can exclude the name if there is a single exporter by that name, which
824-
means
825-
the name is the same as the exporter type.
826-
827-
Second, you then must set environment variables of the form `ROTEL_EXPORTER_{NAME}_{PARAMETER}` to configure the
828-
multiple
829-
exporters. These variable names are dynamic and use the custom name to differentiate settings for similar exporter
830-
types.
831-
Therefore, there are no CLI argument alternatives for them at the moment. The `{PARAMETER}` fields match the
832-
configuration
833-
options for the given exporter type.
822+
The argument form of `--exporters` takes `name:type` pairs separated by commas,
823+
where the first part is a custom name and the second part is the type of
824+
exporter. You can exclude the name if there is a single exporter by that name,
825+
which means the name is the same as the exporter type.
826+
827+
Second, you then must set environment variables of the form
828+
`ROTEL_EXPORTER_{NAME}_{PARAMETER}` to configure the multiple exporters. These
829+
variable names are dynamic and use the custom name to differentiate settings for
830+
similar exporter types. Therefore, there are no CLI argument alternatives for
831+
them at the moment. The `{PARAMETER}` fields match the configuration options for
832+
the given exporter type.
834833

835834
Using our example above, the user must set, at a minimum, the following environment variables. (For ClickHouse Cloud you
836835
would need to include a username/password, but we are skipping those for brevity.)
@@ -852,8 +851,19 @@ Alternatively, the following environment variables would do the same:
852851
- `ROTEL_EXPORTERS_METRICS=stats`
853852
- `ROTEL_EXPORTERS_LOGS=logging`
854853

855-
_NOTE: At the moment, only a single exporter can be set for any telemetry type. This constraint will be relaxed in the
856-
future._
854+
You can send telemetry to multiple exporters by listing multiple comma-separated in the exporters configuration. Telemetry
855+
is sent sequentially to the sending queues for each exporter in-order. That means if one exporter is generating back pressure
856+
it may impact the other exporters.
857+
858+
For example, to send logs to both the stats and logging clickhouse exporters,
859+
you would instead set the `ROTEL_EXPORTERS_LOGS` environment variable to:
860+
861+
- `ROTEL_EXPORTERS_LOGS=stats,logging`
862+
863+
>[!NOTE]
864+
> Sending telemetry to multiple exporters at once is currently in alpha. The telemetry is copied between the
865+
> multiple exporter queues which may cause additional memory use under large volumes. This is an area of
866+
> improvement as we expand on this capability.
857867
858868
### Full example
859869

@@ -917,7 +927,7 @@ rotel_python_processor_sdk directory.
917927
Current prebuilt processors include...
918928

919929
| Name | Supported telemetry types |
920-
|----------------------|---------------------------|
930+
| -------------------- | ------------------------- |
921931
| Attributes Processor | logs, metrics, traces, |
922932
| Redaction Processor | logs, metrics, traces |
923933

src/init/activation.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@ impl TelemetryActivation {
2525
let mut activation = TelemetryActivation::default();
2626

2727
// Update based on exporters
28-
if exporter_config.traces.is_none() {
28+
if exporter_config.traces.is_empty() {
2929
activation.traces = TelemetryState::NoListeners;
3030
}
31-
if exporter_config.metrics.is_none() {
31+
if exporter_config.metrics.is_empty() {
3232
activation.metrics = TelemetryState::NoListeners;
3333
}
34-
if exporter_config.logs.is_none() {
34+
if exporter_config.logs.is_empty() {
3535
activation.logs = TelemetryState::NoListeners;
3636
}
3737

0 commit comments

Comments
 (0)