Class OTLPFileExporter
java.lang.Object
org.bluezoo.gumdrop.telemetry.json.OTLPFileExporter
- All Implemented Interfaces:
TelemetryExporter
Exports telemetry data to OTLP JSON Lines files or stdout.
This exporter implements the
OpenTelemetry Protocol File Exporter specification. Each line written
is a complete OTLP JSON object (ExportTraceServiceRequest,
ExportLogsServiceRequest, or ExportMetricsServiceRequest)
followed by a newline character.
When configured with file paths, separate .jsonl files are
maintained for each signal type (traces, logs, metrics) as required by the
specification. When writing to stdout (the default), all signals share the
same output stream.
Like the OTLP/HTTP exporter, data is queued and flushed by a background thread to avoid blocking the caller.
Configuration
<component id="telemetry" class="org.bluezoo.gumdrop.telemetry.TelemetryConfig">
<property name="service-name">my-service</property>
<property name="exporter-type">file</property>
<property name="file-traces-path">/var/log/otel/traces.jsonl</property>
<property name="file-logs-path">/var/log/otel/logs.jsonl</property>
<property name="file-metrics-path">/var/log/otel/metrics.jsonl</property>
<property name="file-buffer-size">8192</property>
</component>
- Author:
- Chris Burdess
-
Constructor Summary
ConstructorsConstructorDescriptionOTLPFileExporter(TelemetryConfig config) Creates a file exporter that writes all signals to stdout.OTLPFileExporter(TelemetryConfig config, Path tracesPath, Path logsPath, Path metricsPath) Creates a file exporter that writes to the specified file paths. -
Method Summary
Modifier and TypeMethodDescriptionvoidexport(List<MetricData> metrics) Exports a batch of metric data.voidExports a log record.voidExports a completed trace.voidflush()Flushes any buffered telemetry data.voidshutdown()Shuts down the exporter, releasing any resources.
-
Constructor Details
-
OTLPFileExporter
Creates a file exporter that writes all signals to stdout.- Parameters:
config- the telemetry configuration
-
OTLPFileExporter
Creates a file exporter that writes to the specified file paths. Any null path causes that signal to be written to stdout.- Parameters:
config- the telemetry configurationtracesPath- path for traces JSONL file, or null for stdoutlogsPath- path for logs JSONL file, or null for stdoutmetricsPath- path for metrics JSONL file, or null for stdout
-
-
Method Details
-
export
Description copied from interface:TelemetryExporterExports a completed trace.- Specified by:
exportin interfaceTelemetryExporter- Parameters:
trace- the trace to export
-
export
Description copied from interface:TelemetryExporterExports a log record.- Specified by:
exportin interfaceTelemetryExporter- Parameters:
record- the log record to export
-
export
Description copied from interface:TelemetryExporterExports a batch of metric data.- Specified by:
exportin interfaceTelemetryExporter- Parameters:
metrics- the metrics to export
-
flush
public void flush()Description copied from interface:TelemetryExporterFlushes any buffered telemetry data. This method blocks until the flush is complete.- Specified by:
flushin interfaceTelemetryExporter
-
shutdown
public void shutdown()Description copied from interface:TelemetryExporterShuts down the exporter, releasing any resources.- Specified by:
shutdownin interfaceTelemetryExporter
-