Skip to content

feat: add file exporter implementation#5207

Open
herin049 wants to merge 21 commits into
open-telemetry:mainfrom
herin049:feat/file-exporter
Open

feat: add file exporter implementation#5207
herin049 wants to merge 21 commits into
open-telemetry:mainfrom
herin049:feat/file-exporter

Conversation

@herin049
Copy link
Copy Markdown
Contributor

@herin049 herin049 commented May 14, 2026

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.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

uv run tox -e py314-test-opentelemetry-exporter-otlp-json-file

Does This PR Require a Contrib Repo Change?

  • Yes. - Link to PR:
  • No.

Checklist:

  • Followed the style guidelines of this project
  • Changelogs have been updated
  • Unit tests have been added
  • Documentation has been updated

@herin049 herin049 marked this pull request as ready for review May 16, 2026 04:27
@herin049 herin049 requested a review from a team as a code owner May 16, 2026 04:27
@herin049 herin049 added exporters Approve Public API check This label shows that the public symbols added or changed in a PR are strictly necessary labels May 16, 2026
@xrmx xrmx moved this to Ready for review in Python PR digest May 18, 2026
Copy link
Copy Markdown
Contributor

@ocelotl ocelotl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lookiing good! Left some comments but in general I am ok ✌️

Comment thread .changelog/5207.added
Comment thread exporter/opentelemetry-exporter-otlp-json-file/tests/test_log_exporter.py Outdated
@herin049 herin049 requested a review from ocelotl May 20, 2026 03:45
@pmcollins
Copy link
Copy Markdown
Member

Nice addition. I ran this code locally to see the output and got {"resource": {}} JSON lines, whereas the spec examples embed this in a little bit of additional structure: {"resourceSpans": [{"resource": {}}]} {"resourceMetrics": [{"resource": {}}]} {"resourceLogs": [{"resource": {}}]}.

@herin049
Copy link
Copy Markdown
Contributor Author

https://opentelemetry.io/docs/specs/otel/protocol/file-exporter/

@pmcollins Good catch, I should be writing a single line for each TracesData object not each ResourceSpans object. Will update the PR shortly.

@herin049
Copy link
Copy Markdown
Contributor Author

@pmcollins Updated.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-file with FileExporter core (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.yml adds Ubuntu+Windows jobs for 3.10–3.14, 3.14t, PyPy 3.10; lint.yml adds 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Approve Public API check This label shows that the public symbols added or changed in a PR are strictly necessary exporters

Projects

Status: Ready for review

Development

Successfully merging this pull request may close these issues.

5 participants