Feature: opt-in output options (marker prefix, base64, gzip, max line bytes) for `opentelemetry-exporter-otlp-json-file`
Maintainer antworten meist innerhalb von 2 Tagen
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Anfängerfreundlichkeit
- 38/100
- Issue-Typ
- Feature
- Klarheit
- Größtenteils klar
- Aktivitätsstatus
- Aktiv
- Tech-Stack
- python
- Bereich
- observability
Rechercherichtung
Start by locating the opentelemetry-exporter-otlp-json-file exporters and their existing OTLP-JSON encoding path. Then trace how constructor options and environment configuration are read, and inspect the exporter tests. Done means all three signals support the requested opt-in framing, byte limits, record splitting, warnings, and environment variables while default JSON Lines output remains unchanged.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Is your feature request related to a problem?
The current compact JSON-Lines output is ideal for the File Exporter spec, but two things are missing when the stream is ingested by a log agent rather than read by a human:
- No way to tell signals apart on a shared stream. When traces, metrics, and logs interleave on one stdout stream, a downstream agent must parse every line to route it — there is no per-line marker to key on.
- No framing/size discipline for line-based transports. There is no built-in guarantee against embedded newlines for arbitrary payloads, no compaction for high-volume output, and no per-line byte cap for transports that limit individual event size (oversized batches are emitted as one long line).
These are opt-in concerns — the current plain JSON-Lines default must remain the default.
Describe the solution you'd like
Add four opt-in, off-by-default options to the existing exporters (constructor keyword args, with env-var equivalents for auto-instrumentation). All default to off, so existing behaviour is unchanged.
| Option (kwarg) | Effect | Default |
|---|---|---|
marker_prefix |
prefix each line with {PREFIX}_{SIGNAL} (TRACE/METRIC/LOG) so an agent can route by signal |
none (plain JSON Lines) |
base64 |
base64-encode the payload (guarantees a single line, no embedded newlines) | off |
gzip |
gzip the payload, then base64 (implies base64) | off |
max_line_bytes |
cap the line's UTF-8 byte length, splitting oversized batches | no cap |
Output destination is unchanged: default sys.stdout, a caller-owned stream, or a
path the exporter opens/owns.
Line shape by option — {SIGNAL} is TRACE / METRIC / LOG:
Default (no options) — unchanged, compact JSON Lines:
<OTLP-JSON ExportTraceServiceRequest>
<OTLP-JSON ExportMetricsServiceRequest>
<OTLP-JSON ExportLogsServiceRequest>
marker_prefix="OTEL_EXPORT", base64=True:
OTEL_EXPORT_TRACE <base64( OTLP-JSON ExportTraceServiceRequest )>
OTEL_EXPORT_METRIC <base64( OTLP-JSON ExportMetricsServiceRequest )>
OTEL_EXPORT_LOG <base64( OTLP-JSON ExportLogsServiceRequest )>
marker_prefix="OTEL_EXPORT", gzip=True (implies base64):
OTEL_EXPORT_TRACE <base64( gzip( OTLP-JSON ExportTraceServiceRequest ) )>
OTEL_EXPORT_METRIC <base64( gzip( OTLP-JSON ExportMetricsServiceRequest ) )>
OTEL_EXPORT_LOG <base64( gzip( OTLP-JSON ExportLogsServiceRequest ) )>
Semantics:
- The cap is enforced on UTF-8 byte length, not character count.
- Spans and log records split at record granularity; metrics descend to individual data points for a single instrument that overflows on its own. A single record/data point that still exceeds the cap is dropped with a warning rather than emitted truncated.
- A
marker_prefixcontaining whitespace or control characters is rejected with a warning (no prefix applied) so it cannot corrupt the line framing. - No new serialization: reuse the package's existing OTLP-JSON encoding path; the options only affect framing/encoding of the already-produced JSON.
I also propose env-var equivalents so the options can be driven entirely by configuration under auto-instrumentation (final names TBD with maintainers). The exporters are already selectable by name as otlp_json_file; this adds the config reading for the new options — the current prototype wires the constructor kwargs only, so the exporters do not read these env vars yet:
| Environment variable | Constructor arg | Example value |
|---|---|---|
OTEL_JSON_FILE_EXPORTER_MARKER_PREFIX |
marker_prefix |
OTEL_EXPORT |
OTEL_JSON_FILE_EXPORTER_ENCODING |
base64=True |
base64 |
OTEL_JSON_FILE_EXPORTER_COMPRESSION |
gzip=True |
gzip |
OTEL_JSON_FILE_EXPORTER_MAX_LINE_BYTES |
max_line_bytes |
245760 |
OTEL_JSON_FILE_EXPORTER_OUTPUT |
path |
/var/log/otel.jsonl |
Example usage
In-code — the same options apply to all three exporters
from opentelemetry.exporter.otlp.json.file.trace_exporter import FileSpanExporter
# default: unchanged, compact JSON Lines to stdout
plain = FileSpanExporter()
# opt-in: marker + base64 + 240 KiB line cap, splitting oversized batches
framed = FileSpanExporter(
marker_prefix="OTEL_EXPORT",
base64=True,
max_line_bytes=240 * 1024,
)
Auto-instrumentation (env-based config, no application code)
Selection by name already works today via the otlp_json_file entry points; the OTEL_JSON_FILE_EXPORTER_* vars are the proposed additions, so the marker + gzip output above is produced purely from configuration:
export OTEL_TRACES_EXPORTER=otlp_json_file
export OTEL_METRICS_EXPORTER=otlp_json_file
export OTEL_LOGS_EXPORTER=otlp_json_file
export OTEL_JSON_FILE_EXPORTER_MARKER_PREFIX=OTEL_EXPORT
export OTEL_JSON_FILE_EXPORTER_ENCODING=base64
export OTEL_JSON_FILE_EXPORTER_COMPRESSION=gzip
export OTEL_JSON_FILE_EXPORTER_MAX_LINE_BYTES=245760
opentelemetry-instrument python app.py
Describe alternatives you've considered
- Post-processing stdout downstream: every consumer re-implements marker routing, base64/gzip, and size splitting, inconsistently.
- Console exporters: emit a human-readable debug dump, not the OTLP envelope — not consumable downstream.
Adding opt-in flags to the exporter that already produces the bytes keeps the default spec-aligned while covering the line-transport case in one place.
Additional Context
The marker/base64/gzip framing and the config key names (the OTEL_JSON_FILE_EXPORTER_* environment variables) are not spec'd today; I'll raise a separate opentelemetry-specification issue to standardize the framing and the configuration names before finalizing them here.
Would you like to implement a fix?
Yes
Tip
React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it. Learn more here.
- Vorherrschende Sprache
- Python
- Sterne
- 2.7k
- Forks
- 1.1k
- Ø Merge
- 3 T. 12 Std.
- Gemergte PRs (30 T.)
- 16
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus open-telemetry/opentelemetry-python
-
References to Archived open-telemetry/otepsEvtl. vergeben @RjyavardhanSingh hat das heute übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
open-telemetry/opentelemetry-python#5984 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 2 Tagen
-
Autoconfiguration rejects OTEL_EXPORTER_OTLP_PROTOCOL=http/jsonEvtl. vergeben @WendeelMarinho hat das vor 2 Tagen übernommen. Offenbug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
open-telemetry/opentelemetry-python#5981 ·
Maintainer antworten meist innerhalb von 2 Tagen
-
MeterProvider raises ValueError on empty or uppercase OTEL_METRICS_EXEMPLAR_FILTEREvtl. vergeben @bishalde hat das vor 8 Tagen übernommen. Offenbug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 83/100
open-telemetry/opentelemetry-python#5948 · 3 Kommentare ·
Maintainer antworten meist innerhalb von 2 Tagen
-
W3CBaggagePropagator drops a list-member over 4096 bytes that W3C Baggage requires it to propagateEvtl. vergeben @codedbyadiiii hat das vor 20 Tagen übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 70/100
open-telemetry/opentelemetry-python#5913 ·
Maintainer antworten meist innerhalb von 2 Tagen
-
otel.sdk.processor.{span,log}.queue.capacity uses synchronous UpDownCounter recorded once in __init__Evtl. wieder frei Ein Pull Request dazu wurde ohne Merge geschlossen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
open-telemetry/opentelemetry-python#5891 ·
Maintainer antworten meist innerhalb von 2 Tagen
Alle Issues in open-telemetry/opentelemetry-python
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
Maintainer antworten meist innerhalb von 1 Tag
-
bug improve content
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 92/100
opensafely/documentation#2102 ·
Maintainer antworten meist innerhalb von 1 Tag
-
difficulty:1 documentation
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
MakazhanAlpamys/Soup#3533 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 74/100
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
onyx-dot-app/onyx#18730 ·
Maintainer antworten meist innerhalb von 1 Tag