| 1 | # Debug Exporter |
| 2 | |
| 3 | <!-- status autogenerated section --> |
| 4 | | Status | | |
| 5 | | ------------- |-----------| |
| 6 | | Stability | [development]: profiles | |
| 7 | | | [alpha]: traces, metrics, logs | |
| 8 | | Distributions | [core], [contrib], [k8s] | |
| 9 | | Warnings | [Unstable Output Format](#warnings) | |
| 10 | | Issues | [](https://github.com/open-telemetry/opentelemetry-collector/issues?q=is%3Aopen+is%3Aissue+label%3Aexporter%2Fdebug) [](https://github.com/open-telemetry/opentelemetry-collector/issues?q=is%3Aclosed+is%3Aissue+label%3Aexporter%2Fdebug) | |
| 11 | | [Code Owners](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/CONTRIBUTING.md#becoming-a-code-owner) | [@andrzej-stencel](https://www.github.com/andrzej-stencel) | |
| 12 | |
| 13 | [development]: https://github.com/open-telemetry/opentelemetry-collector/blob/main/docs/component-stability.md#development |
| 14 | [alpha]: https://github.com/open-telemetry/opentelemetry-collector/blob/main/docs/component-stability.md#alpha |
| 15 | [core]: https://github.com/open-telemetry/opentelemetry-collector-releases/tree/main/distributions/otelcol |
| 16 | [contrib]: https://github.com/open-telemetry/opentelemetry-collector-releases/tree/main/distributions/otelcol-contrib |
| 17 | [k8s]: https://github.com/open-telemetry/opentelemetry-collector-releases/tree/main/distributions/otelcol-k8s |
| 18 | <!-- end autogenerated section --> |
| 19 | |
| 20 | Outputs telemetry data to the console for debugging purposes. |
| 21 | |
| 22 | See also the [Troubleshooting][troubleshooting_docs] document for examples on using this exporter. |
| 23 | |
| 24 | [troubleshooting_docs]: https://opentelemetry.io/docs/collector/troubleshooting/#local-exporters |
| 25 | |
| 26 | ## Getting Started |
| 27 | |
| 28 | The following settings are optional: |
| 29 | |
| 30 | - `verbosity` (default = `basic`): the verbosity of the debug exporter: `basic`, `normal` or `detailed`. |
| 31 | See [Verbosity levels](#verbosity-levels) below for more information. |
| 32 | - `sampling_initial` (default = `2`): number of messages initially logged each |
| 33 | second. |
| 34 | - `sampling_thereafter` (default = `1`): sampling rate after the initial |
| 35 | messages are logged (every Mth message is logged). |
| 36 | The default value of `1` means that sampling is disabled. |
| 37 | To enable sampling, change `sampling_thereafter` to a value higher than `1`. |
| 38 | Refer to [Zap docs](https://godoc.org/go.uber.org/zap/zapcore#NewSampler) for more details |
| 39 | on how sampling parameters impact number of messages. |
| 40 | - `use_internal_logger` (default = `true`): uses the collector's internal logger for output. See [below](#using-the-collectors-internal-logger) for description. |
| 41 | - `sending_queue` (disabled by default): see [Sending Queue](../exporterhelper/README.md#sending-queue) for the full set of available options. |
| 42 | |
| 43 | Example configuration: |
| 44 | |
| 45 | ```yaml |
| 46 | exporters: |
| 47 | debug: |
| 48 | verbosity: detailed |
| 49 | sampling_initial: 5 |
| 50 | sampling_thereafter: 200 |
| 51 | ``` |
| 52 | |
| 53 | ## Verbosity levels |
| 54 | |
| 55 | The following subsections describe the output from the exporter depending on the configured verbosity level - `basic`, `normal` and `detailed`. |
| 56 | The default verbosity level is `basic`. |
| 57 | |
| 58 | To understand how the below example output was generated, see [Generating example output](./generating-example-output.md). |
| 59 | |
| 60 | ### Basic verbosity |
| 61 | |
| 62 | With `verbosity: basic`, the exporter outputs a single-line summary of received data with a total count of telemetry records for every batch of received logs, metrics or traces. |
| 63 | |
| 64 | Here's an example output: |
| 65 | |
| 66 | ```console |
| 67 | 2025-04-17T10:40:44.559+0200 info Traces {"otelcol.component.id": "debug/basic", "otelcol.component.kind": "Exporter", "otelcol.signal": "traces", "resource spans": 1, "spans": 2} |
| 68 | ``` |
| 69 | |
| 70 | ### Normal verbosity |
| 71 | |
| 72 | With `verbosity: normal`, the exporter outputs about one line for each telemetry record. |
| 73 | The "one line per telemetry record" is not a strict rule. |
| 74 | For example, logs with multiline body will be output as multiple lines. |
| 75 | |
| 76 | Here's an example output: |
| 77 | |
| 78 | ```console |
| 79 | 2025-05-09T19:57:16.332+0200 info Traces {"resource": {}, "otelcol.component.id": "debug/normal", "otelcol.component.kind": "exporter", "otelcol.signal": "traces", "resource spans": 1, "spans": 2} |
| 80 | 2025-05-09T19:57:16.332+0200 info ResourceTraces #0 [https://opentelemetry.io/schemas/1.25.0] service.name=telemetrygen |
| 81 | ScopeTraces #0 telemetrygen |
| 82 | okey-dokey-0 ab1030bd4ee554af936542b01d7b4807 1d8c93663d043aa8 net.sock.peer.addr=1.2.3.4 peer.service=telemetrygen-client |
| 83 | lets-go ab1030bd4ee554af936542b01d7b4807 0d238e8a2f97733f net.sock.peer.addr=1.2.3.4 peer.service=telemetrygen-server |
| 84 | {"resource": {}, "otelcol.component.id": "debug/normal", "otelcol.component.kind": "exporter", "otelcol.signal": "traces"} |
| 85 | ``` |
| 86 | |
| 87 | ### Detailed verbosity |
| 88 | |
| 89 | With `verbosity: detailed`, the exporter outputs all details of every telemetry record, typically writing multiple lines for every telemetry record. |
| 90 | |
| 91 | Here's an example output: |
| 92 | |
| 93 | ```console |
| 94 | 2025-04-17T10:40:44.560+0200 info Traces {"otelcol.component.id": "debug/detailed", "otelcol.component.kind": "Exporter", "otelcol.signal": "traces", "resource spans": 1, "spans": 2} |
| 95 | 2025-04-17T10:40:44.560+0200 info ResourceSpans #0 |
| 96 | Resource SchemaURL: https://opentelemetry.io/schemas/1.25.0 |
| 97 | Resource attributes: |
| 98 | -> service.name: Str(telemetrygen) |
| 99 | ScopeSpans #0 |
| 100 | ScopeSpans SchemaURL: |
| 101 | InstrumentationScope telemetrygen |
| 102 | Span #0 |
| 103 | Trace ID : fafdac970271dd2ce89de2442c0518c7 |
| 104 | Parent ID : d98de4cb8e2a0ad6 |
| 105 | ID : 3875f436d989d0e5 |
| 106 | Name : okey-dokey-0 |
| 107 | Kind : Server |
| 108 | Start time : 2025-04-17 08:40:44.555461596 +0000 UTC |
| 109 | End time : 2025-04-17 08:40:44.555584596 +0000 UTC |
| 110 | Status code : Unset |
| 111 | Status message : |
| 112 | Attributes: |
| 113 | -> net.sock.peer.addr: Str(1.2.3.4) |
| 114 | -> peer.service: Str(telemetrygen-client) |
| 115 | Span #1 |
| 116 | Trace ID : fafdac970271dd2ce89de2442c0518c7 |
| 117 | Parent ID : |
| 118 | ID : d98de4cb8e2a0ad6 |
| 119 | Name : lets-go |
| 120 | Kind : Client |
| 121 | Start time : 2025-04-17 08:40:44.555461596 +0000 UTC |
| 122 | End time : 2025-04-17 08:40:44.555584596 +0000 UTC |
| 123 | Status code : Unset |
| 124 | Status message : |
| 125 | Attributes: |
| 126 | -> net.sock.peer.addr: Str(1.2.3.4) |
| 127 | -> peer.service: Str(telemetrygen-server) |
| 128 | {"otelcol.component.id": "debug/detailed", "otelcol.component.kind": "Exporter", "otelcol.signal": "traces"} |
| 129 | ``` |
| 130 | |
| 131 | ## Using the collector's internal logger |
| 132 | |
| 133 | When `use_internal_logger` is set to `true` (the default), the exporter uses the collector's [internal logger][internal_telemetry] for output. |
| 134 | This comes with the following consequences: |
| 135 | |
| 136 | - The output from the exporter may be annotated by additional output from the collector's logger. |
| 137 | - The output from the exporter is affected by the collector's [logging configuration][internal_logs_config] specified in `service::telemetry::logs`. |
| 138 | |
| 139 | When `use_internal_logger` is set to `false`, the exporter does not use the collector's internal logger. |
| 140 | Changing the values in `service::telemetry::logs` has no effect on the exporter's output. |
| 141 | The exporter's output is sent to `stdout`. |
| 142 | |
| 143 | [internal_telemetry]: https://opentelemetry.io/docs/collector/internal-telemetry/ |
| 144 | [internal_logs_config]: https://opentelemetry.io/docs/collector/internal-telemetry/#configure-internal-logs |
| 145 | |
| 146 | ## Warnings |
| 147 | |
| 148 | - Unstable Output Format: The output formats for all verbosity levels is not guaranteed and may be changed at any time without a breaking change. |