Lightweight OpenTelemetry collector
Project description
pyrotel
Python package for the Rotel lightweight OpenTelemetry collector.
Description
This package provides an embedded OpenTelemetry collector, built on the lightweight Rotel collector. When started, it spawns a background daemon that accepts OpenTelemetry metrics, traces, and logs. Designed for minimal overhead, Rotel reduces resource consumption while simplifying telemetry collection and processing in complex Python applications—without requiring additional sidecar containers.
By default, the Rotel agent listens for OpenTelemetry (OTel) data over gRPC (port 4317) and HTTP (port 4318) on localhost. It efficiently batches telemetry signals and forwards them to a configurable OTLP endpoint. Future updates will introduce support for additional filtering, transformations, and exporters.
Getting started
Rotel configuration
Add the rotel Python package to your project's dependencies. There are two approaches to configuring rotel:
- typed config dicts
- environment variables
Typed dicts
In the startup section of your main.py add the following code block. Replace the endpoint with the endpoint of your OpenTelemetry vendor and any required API KEY headers.
from rotel import Rotel, OTLPExporter
rotel = Rotel(
enabled = True,
exporter = OTLPExporter(
endpoint = "https://foo.example.com",
custom_headers=[f"x-api-key={settings.API_KEY}"]
),
)
rotel.start()
Environment variables
You can also configure rotel entirely with environment variables. In your application startup, insert:
import rotel
rotel.start()
In your application deployment configuration, set the following environment variables. These match the typed configuration above:
ROTEL_ENABLED=trueROTEL_OTLP_EXPORTER_ENDPOINT=https://foo.example.comROTEL_OTLP_EXPORTER_CUSTOM_HEADERS=x-api-key={API_KEY}
Any typed configuration options will override environment variables of the same name.
See the Configuration section for the full list of options.
OpenTelemetry SDK configuration
Once the rotel collector agent is running, you may need to configure your application's instrumentation. If you are using the default rotel endpoints of localhost:4317 and localhost:4318, then you should not need to change anything.
To set the endpoint the OpenTelemetry SDK will use, set the following environment variable:
OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4317
Configuration
This is the full list of options and their environment variable alternatives. Any defaults left blank in the table are either False or None.
| Option Name | Type | Environ | Default | Options |
|---|---|---|---|---|
| enabled | bool | ROTEL_ENABLED | ||
| otlp_grpc_endpoint | str | ROTEL_OTLP_GRPC_ENDPOINT | localhost:4317 | |
| otlp_http_endpoint | str | ROTEL_OTLP_HTTP_ENDPOINT | localhost:4318 | |
| pid_file | str | ROTEL_PID_FILE | /tmp/rotel-agent.pid | |
| log_file | str | ROTEL_LOG_FILE | /tmp/rotel-agent.log | |
| debug_log | list[str] | ROTEL_DEBUG_LOG | traces, metrics | |
| exporter | OTLPExporter |
The OTLPExporter can be enabled with the following options.
| Option Name | Type | Environ | Default | Options |
|---|---|---|---|---|
| endpoint | str | ROTEL_OTLP_EXPORTER_ENDPOINT | ||
| protocol | str | ROTEL_OTLP_EXPORTER_PROTOCOL | grpc | grpc or http |
| custom_headers | list[str] | ROTEL_OTLP_EXPORTER_CUSTOM_HEADERS | ||
| compression | str | ROTEL_OTLP_EXPORTER_COMPRESSION | gzip | gzip or none |
| tls_cert_file | str | ROTEL_OTLP_EXPORTER_TLS_CERT_FILE | ||
| tls_key_file | str | ROTEL_OTLP_EXPORTER_TLS_KEY_FILE | ||
| tls_ca_file | str | ROTEL_OTLP_EXPORTER_TLS_CA_FILE | ||
| tls_skip_verify | bool | ROTEL_OTLP_EXPORTER_TLS_SKIP_VERIFY |
Debugging
If you set the option debug_log to ["traces"], or the environment variable ROTEL_DEBUG_LOG=traces, then rotel will log a summary to the log file /tmp/rotel-agent.log each time it processes trace spans. You can add also specify metrics to debug metrics.
Development
Install the latest version of the hatch build tool. We'll use this to manage the environments, run tests and perform builds.
Managing Python versions
Hatch will default to the system's Python version.
If you want to install additional Python versions, you can use hatch to manage those.
The following will install Python 3.9:
hatch python install 3.9
Then you can run tests against version 3.9 with:
hatch run test.py39:pytest
Wheel builds
To build locally using an existing Rotel agent binary, run:
hatch run build:me ../path/to/agent/file
You can always download the latest rotel agent binary from Github. Make sure to create a Github Personal Access Token (PAT) that allows you to pull Github release artifacts. Set that as GITHUB_API_TOKEN for the commands below.
To build using the latest Github built binary:
GITHUB_API_TOKEN=1234 hatch run build:me
Finally, to build for all supported platforms:
GITHUB_API_TOKEN=1234 hatch run build:all
Linting and formatting
hatch run lint:fmt # will fix anything it can, report others
hatch run lint:check # will only report issues
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 Distributions
Built Distributions
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 rotel-0.0.1a3-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.
File metadata
- Download URL: rotel-0.0.1a3-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
- Upload date:
- Size: 3.8 MB
- Tags: Python 3, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
85368d8e46c0bf9b556fd0e87fa39a5ddc70d206d47644ba65417fa397c8f5e4
|
|
| MD5 |
3b936e6f42e735db2fecef7ab956a541
|
|
| BLAKE2b-256 |
50cad0f5e1ad1b0ce4c06baed60b49897663ede2cab7043f184b70835d7fc835
|
Provenance
The following attestation bundles were made for rotel-0.0.1a3-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.whl:
Publisher:
build-release.yml on streamfold/pyrotel
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rotel-0.0.1a3-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.whl -
Subject digest:
85368d8e46c0bf9b556fd0e87fa39a5ddc70d206d47644ba65417fa397c8f5e4 - Sigstore transparency entry: 178263516
- Sigstore integration time:
-
Permalink:
streamfold/pyrotel@a7d7934511a8b3559fb0ddfcbfae33f469eca697 -
Branch / Tag:
refs/tags/v0.0.1a3 - Owner: https://github.com/streamfold
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build-release.yml@a7d7934511a8b3559fb0ddfcbfae33f469eca697 -
Trigger Event:
push
-
Statement type:
File details
Details for the file rotel-0.0.1a3-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.whl.
File metadata
- Download URL: rotel-0.0.1a3-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
- Upload date:
- Size: 3.7 MB
- Tags: Python 3, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1fd17dbfe3415dc0447716b00842aed099a799835e6018b9c6f41b59ae3e7a26
|
|
| MD5 |
e0eae888a1b5199d77a55452c22d9ded
|
|
| BLAKE2b-256 |
2c5b1a009eddefb310bf3339e6f80e90e6b964a197624238ece12bf7ccbfc623
|
Provenance
The following attestation bundles were made for rotel-0.0.1a3-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.whl:
Publisher:
build-release.yml on streamfold/pyrotel
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rotel-0.0.1a3-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.whl -
Subject digest:
1fd17dbfe3415dc0447716b00842aed099a799835e6018b9c6f41b59ae3e7a26 - Sigstore transparency entry: 178263514
- Sigstore integration time:
-
Permalink:
streamfold/pyrotel@a7d7934511a8b3559fb0ddfcbfae33f469eca697 -
Branch / Tag:
refs/tags/v0.0.1a3 - Owner: https://github.com/streamfold
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build-release.yml@a7d7934511a8b3559fb0ddfcbfae33f469eca697 -
Trigger Event:
push
-
Statement type:
File details
Details for the file rotel-0.0.1a3-py3-none-macosx_10_9_universal2.macosx_12_3_arm64.whl.
File metadata
- Download URL: rotel-0.0.1a3-py3-none-macosx_10_9_universal2.macosx_12_3_arm64.whl
- Upload date:
- Size: 3.5 MB
- Tags: Python 3, macOS 10.9+ universal2 (ARM64, x86-64), macOS 12.3+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
566a8219b94022b7c2bf700901053626512474cdc5abec7e349f26c78641c378
|
|
| MD5 |
cd9689d40c8abb6bfc463d320b866bae
|
|
| BLAKE2b-256 |
c0fc674ef9d016f9e31e018dee775f5af09c3602dc404f82302e190a35bf5cf9
|
Provenance
The following attestation bundles were made for rotel-0.0.1a3-py3-none-macosx_10_9_universal2.macosx_12_3_arm64.whl:
Publisher:
build-release.yml on streamfold/pyrotel
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rotel-0.0.1a3-py3-none-macosx_10_9_universal2.macosx_12_3_arm64.whl -
Subject digest:
566a8219b94022b7c2bf700901053626512474cdc5abec7e349f26c78641c378 - Sigstore transparency entry: 178263517
- Sigstore integration time:
-
Permalink:
streamfold/pyrotel@a7d7934511a8b3559fb0ddfcbfae33f469eca697 -
Branch / Tag:
refs/tags/v0.0.1a3 - Owner: https://github.com/streamfold
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build-release.yml@a7d7934511a8b3559fb0ddfcbfae33f469eca697 -
Trigger Event:
push
-
Statement type: