🐍Lightweight OTEL span to JSON converter, no dependencies, pure Python🐍
Project description
otlp-json
otpl-json is an OTLP serialisation library.
It's written in pure Python, without dependencies.
It serialises a bunch of spans into OTLP 1.5 JSON format.
Motivation
Tracing should be on by default.
OTLP is the standard data format and API, and the standard Python package is opentelemetry-exporter-otlp-proto-http. It brings in a total of 18 packages and adds 9MB to the project virtual environment.
A typical Python application, that's being instrumented, only generates own tracing data and needs to send it out. It doesn't need that much complexity.
Usage
from otlp_json import CONTENT_TYPE, encode_spans
class SomeExporter:
def export(self.spans: Sequece[ReadableSpan]) -> None:
requests.post(
"http://localhost:4318/v1/traces",
data=encode_spans(spans),
headers={"Content-Type": CONTENT_TYPE},
)
Library size
- 3KB whl, containing:
- 4KB Python source
- ?? metadata
Testing
uv sync
uv run pytest
Links
- Test data generator: https://pypi.org/project/otlp-test-data/
- Python stdlib-only exporter: https://github.com/canonical/operator/blob/main/tracing/ops_tracing/_export.py#L141-L160
- Tiny (compiled) extension written in Rust: https://pypi.org/project/otlp-proto
Features
- Events
- Links
- Baggage
- Schemata, when https://github.com/open-telemetry/opentelemetry-python/pull/4359 lands
TODO(fixes)
- Status fields
- validate what fields are in fact optional
- ???
Limitations
This library is meant to marshal tracing data that's collected in the same Python process.
It is not meant to be used for data received and forwarded.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file otlp_json-1.0.1.tar.gz.
File metadata
- Download URL: otlp_json-1.0.1.tar.gz
- Upload date:
- Size: 47.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1f51dd53f71ba7effc94e383e59f58aea5f257a591dcc3ec05d4d0ffa6921e24
|
|
| MD5 |
0e82aae1e681b0c56e1c802205a0dbd7
|
|
| BLAKE2b-256 |
03fd8c19154b754182747d96bda8e142295c91af3c6681d9daf42fe67afc4d88
|
Provenance
The following attestation bundles were made for otlp_json-1.0.1.tar.gz:
Publisher:
ci.yaml on dimaqq/otlp-json
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
otlp_json-1.0.1.tar.gz -
Subject digest:
1f51dd53f71ba7effc94e383e59f58aea5f257a591dcc3ec05d4d0ffa6921e24 - Sigstore transparency entry: 919091342
- Sigstore integration time:
-
Permalink:
dimaqq/otlp-json@0b513c64375f5cb48c6d55d463bb3de976c58256 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/dimaqq
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yaml@0b513c64375f5cb48c6d55d463bb3de976c58256 -
Trigger Event:
push
-
Statement type:
File details
Details for the file otlp_json-1.0.1-py3-none-any.whl.
File metadata
- Download URL: otlp_json-1.0.1-py3-none-any.whl
- Upload date:
- Size: 4.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a25e7c1453aa5c197eac5abd657b1a0d453c0b94ef6663d7776f4d25a9715a30
|
|
| MD5 |
e73aa67df0a4bb49207b5af85d3d4d65
|
|
| BLAKE2b-256 |
87fc8abbbf8f7718da0e547f640fc1e0726f49a5560d69730e43590469361d54
|
Provenance
The following attestation bundles were made for otlp_json-1.0.1-py3-none-any.whl:
Publisher:
ci.yaml on dimaqq/otlp-json
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
otlp_json-1.0.1-py3-none-any.whl -
Subject digest:
a25e7c1453aa5c197eac5abd657b1a0d453c0b94ef6663d7776f4d25a9715a30 - Sigstore transparency entry: 919091354
- Sigstore integration time:
-
Permalink:
dimaqq/otlp-json@0b513c64375f5cb48c6d55d463bb3de976c58256 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/dimaqq
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yaml@0b513c64375f5cb48c6d55d463bb3de976c58256 -
Trigger Event:
push
-
Statement type: