feat: add file exporter implementation#5207
Conversation
ocelotl
left a comment
There was a problem hiding this comment.
Lookiing good! Left some comments but in general I am ok ✌️
|
Nice addition. I ran this code locally to see the output and got |
@pmcollins Good catch, I should be writing a single line for each |
|
@pmcollins Updated. |
There was a problem hiding this comment.
Pull request overview
Adds a new opentelemetry-exporter-otlp-json-file distribution implementing the OTLP JSON File exporter spec. Provides FileSpanExporter, FileMetricExporter, and FileLogExporter that write newline-delimited OTLP JSON either to stdout (default), a provided text stream, or a file path. The shared writing logic and metric temporality/aggregation env handling live in a _internal.py module mirroring the existing proto-common metrics encoder helpers.
Changes:
- New package
exporter/opentelemetry-exporter-otlp-json-filewithFileExportercore (lock-protected JSON Lines writer), three signal exporters, and entry points (otlp_json_file). - Wiring into workspace config (
pyproject.toml,uv.lock,eachdist.ini,tox.ini) and CI matrices (test.ymladds Ubuntu+Windows jobs for 3.10–3.14, 3.14t, PyPy 3.10;lint.ymladds a lint job). - Comprehensive tests for formatting, env-driven temporality/aggregation, per-signal export/shutdown/path/stream behavior, and round-trip equivalence with
encode_*().to_dict().
Reviewed changes
Copilot reviewed 22 out of 24 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
exporter/opentelemetry-exporter-otlp-json-file/src/.../_internal.py |
Generic FileExporter writing JSON Lines under a lock; metric temporality/aggregation env helpers duplicated from proto-common mixin. |
exporter/.../trace_exporter.py, metric_exporter.py, _log_exporter.py |
Per-signal exporters wrapping FileExporter and mapping its bool result to SDK enums. |
exporter/.../tests/test_*.py |
Unit tests for formatting, env helpers, export/shutdown/path/stream paths, and encoder round-trip equivalence. |
exporter/.../pyproject.toml, README.rst, LICENSE, version/__init__.py, test-requirements.txt |
Package metadata, entry points, dependencies, license, and test deps. |
pyproject.toml, uv.lock, eachdist.ini, tox.ini |
Workspace registration, deps, and tox envs/commands for the new package. |
.github/workflows/test.yml, lint.yml |
CI test jobs across Python versions on Ubuntu/Windows and a lint job. |
.changelog/5207.added |
Changelog entry. |
exporter/opentelemetry-exporter-otlp-json-common/README.rst |
Tightens README wording (drops empty "used by" list). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Description
Adds support for the OTLP JSON File exporter as outlined in OTel spec: https://opentelemetry.io/docs/specs/otel/protocol/file-exporter/
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Does This PR Require a Contrib Repo Change?
Checklist: