Skip to main content

otel_file_exporter

A lightweight OpenTelemetry file exporter that writes traces, logs and metrics to local JSON Lines files – no external back-ends required.
All traces, logs and metrics are written locally as newline-delimited JSON (*.jsonl) so they can be inspected with your favorite tools or fed into pipelines later.

telemetry/
├─ traces.jsonl   <- Spans
├─ logs.jsonl     <- Structured application logs
└─ metrics.jsonl  <- OTLP metrics exports

Why?

  • Zero-dependency observability for demos, local development and CI
  • Uses the official OpenTelemetry SDK – switch to OTLP / Jaeger / etc. at any time
  • Demonstrates structured logging and custom OpenTelemetry exporters

Requirements

  • Python 3.13 or newer (matches pyproject.toml)
  • Windows, macOS or Linux – no native deps

Quick start

python -m venv .venv
.\.venv\Scripts\activate
pip install -e .
python examples\fastapi_app.py

Then open http://localhost:8000/docs for the interactive Swagger UI.

Example requests

curl http://localhost:8000/health
curl http://localhost:8000/items/123?include_description=true

Watch the telemetry directory fill with JSONL lines while you interact with the API.

Environment variables

Var Default Purpose
SERVICE_NAME fastapi-otel-demo Resource attribute in traces/logs/metrics
SERVICE_VERSION 1.0.0 Resource attribute
ENVIRONMENT development Resource attribute
LOG_LEVEL INFO Console & JSONL log level
TRACE_SAMPLE_RATE 1.0 0.0-1.0 probability sampler
METRICS_EXPORT_INTERVAL 5000 Export interval in ms
OUTPUT_DIR ./telemetry Where JSONL files are written
PORT 8000 HTTP port for the demo app

Set them in the shell, a .env file or your container orchestrator.

Library usage

Import the pre-configured helpers in your own code:

from otel_file_exporter import tracer, logger, app_metrics

with tracer.start_as_current_span("my_work"):
    logger.info("Hello with trace context!")

Project layout

examples/
└─ fastapi_app.py   # Self-contained demo API
src/otel_file_exporter/
    ├─ __init__.py
    └─ otel.py      # Custom exporters & bootstrap helpers
pyproject.toml
README.md

Development

pip install -e ".[dev]"   # add your own dev dependencies extras
pytest -q                 # add tests as you go

Feel free to open issues or PRs – contributions are welcome!

Publishing to PyPI

The workflow in .github/workflows/release.yml uses PyPI’s Trusted Publishing (OIDC) together with
pypa/gh-action-pypi-publish@release/v1.

  1. Enable “Trusted Publishing” for the project on PyPI and link it to this repository.
  2. Create a GitHub Release (or press Run workflow in the Actions tab).
    The build artifacts are uploaded and automatically published to PyPI – no secret required.

2. Classic API-token publishing

The fallback workflow in .github/workflows/publish.yml is triggered whenever you push a git tag that matches v*.*.*.

  1. Create a scoped PyPI API token with publish privileges.
  2. Add it to the repository secrets as PYPI_API_TOKEN.
  3. Tag and push a new version:
git tag v0.2.0
git push --tags

License

This project is licensed under the MIT License. See LICENSE for details.

Metadata

Release files for otel-file-exporter 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for otel-file-exporter 0.1.1
File Size Uploaded Provenance Actions
otel_file_exporter-0.1.1.tar.gz 12.3 kB With provenance Details for otel_file_exporter-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for otel-file-exporter 0.1.1
File Interpreter ABI Platform Actions
otel_file_exporter-0.1.1-py3-none-any.whl Python 3 none any Details for otel_file_exporter-0.1.1-py3-none-any.whl

Total release size: 22.7 kB

Release files / otel_file_exporter-0.1.1.tar.gz

Download URL otel_file_exporter-0.1.1.tar.gz
Size 12.3 kB
Tags Source
SHA-256 checksum
How to use checksums
69102bebd89a7949baa3a15fdbe35099d76da0c41bc20687bd5d3b925aa64fe4
BLAKE2b-256 checksum
How to use checksums
ea602be79dab0929ed620160530df0e81d2904f47c2890f1ff8855ae3bdbc1ec
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 7, 2025.

Transparency log

Release files / otel_file_exporter-0.1.1-py3-none-any.whl

Download URL otel_file_exporter-0.1.1-py3-none-any.whl
Size 10.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1a91abee915cfc9e28df7d9ec8af44e26dec768af9607ee76b5c19eb03d16479
BLAKE2b-256 checksum
How to use checksums
0c6d869faaa5dc4ad8d3ea7c0a097700f7f7b5234aa2dfca8f0c22209c7b34b7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 7, 2025.

Transparency log

Security for otel-file-exporter 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for otel_file_exporter-0.1.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 7, 2025.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page