Production observability via OTLP export to Plain Cloud.
Project description
plain.cloud
Production observability via OTLP export to Plain Cloud.
Overview
You can use plain.cloud to export traces, metrics, and logs from your Plain app to Plain Cloud. The framework already instruments itself with OpenTelemetry spans and histograms — plain.cloud activates them by providing the OTLP exporters and bridges Python's logging module into OTLP log records.
Set one environment variable and your app starts pushing telemetry:
PLAIN_CLOUD_EXPORT_TOKEN=your-token
If CLOUD_EXPORT_TOKEN is not set, the package is a no-op — safe to install without configuration.
Settings
| Setting | Default | Description |
|---|---|---|
CLOUD_EXPORT_URL |
"https://ingest.plainframework.com" |
OTLP ingest endpoint (override to use a custom endpoint) |
CLOUD_EXPORT_TOKEN |
"" |
Auth token for the export endpoint |
CLOUD_TRACE_SAMPLE_RATE |
1.0 |
Probability of exporting a trace (0.0–1.0) |
CLOUD_EXPORT_LOGS |
True |
Set to False to disable OTLP log export |
CLOUD_LOG_LEVEL |
"INFO" |
Minimum severity exported via OTLP logs (level name or int) |
All settings can be set via PLAIN_-prefixed environment variables or in app/settings.py.
Sampling
By default, all traces are exported. To reduce volume, set a sample rate:
CLOUD_TRACE_SAMPLE_RATE = 0.1 # Export 10% of traces
Metrics are not affected by sampling — histograms aggregate in-process and export periodically regardless of the trace sample rate.
What gets exported
Traces — HTTP request spans and database query spans instrumented by the framework.
Metrics — OTel histograms like db.client.query.duration, aggregated and pushed every 60 seconds.
Logs — Records from the plain and app loggers, plus anything propagating to the root logger, are bridged into OTLP log records and exported with trace_id / span_id set from the active span. The minimum severity is controlled by CLOUD_LOG_LEVEL (default INFO); the root logger's level is widened to that floor when needed so libraries using getLogger(__name__) reach the exporter. To prevent feedback loops, two sources are skipped on the export path: the opentelemetry namespace, and any record emitted from inside the OTLP exporter's background thread (e.g. urllib3 connection errors raised by the exporter's own HTTP call). Your application's urllib3 logs are exported normally.
Observer coexistence
If plain.observer is also installed, both work simultaneously. plain.cloud handles production export while observer provides the local dev toolbar and admin trace viewer. Observer detects the existing TracerProvider and layers its sampler and span processor on top.
FAQs
Do I need plain.observer to use plain.cloud?
No. plain.cloud works independently. Observer is for local dev tooling; plain.cloud is for production export.
What happens if the export endpoint is unreachable?
The OTLP exporters batch and retry automatically. If the endpoint is down, telemetry is dropped after retries — it does not block your application.
Does this add latency to requests?
No. Trace spans are exported in a background thread via BatchSpanProcessor. Metrics are flushed periodically by a background thread. Neither blocks request handling.
Installation
# app/settings.py
INSTALLED_PACKAGES = [
"plain.cloud",
# ...
]
Place plain.cloud before plain.observer in INSTALLED_PACKAGES so it sets up the TracerProvider first.
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 plain_cloud-0.3.0.tar.gz.
File metadata
- Download URL: plain_cloud-0.3.0.tar.gz
- Upload date:
- Size: 7.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.8 {"installer":{"name":"uv","version":"0.11.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
af0bc5640ee65e3edcbb5360ad30494cfcb024c7e8b78ce25d2f3d5a49278b65
|
|
| MD5 |
3ace4092dd7bf4557659c06c43f97900
|
|
| BLAKE2b-256 |
a244a4c973f5748c22b475ad212f73b5fd4874e96f0eab749ea2bed81fa9a04c
|
File details
Details for the file plain_cloud-0.3.0-py3-none-any.whl.
File metadata
- Download URL: plain_cloud-0.3.0-py3-none-any.whl
- Upload date:
- Size: 11.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.8 {"installer":{"name":"uv","version":"0.11.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8e7172b1889aac0f8da950721f2b7d88580592c41e4bbf6f3b72d4a4b079d956
|
|
| MD5 |
077c5e10018a68122fe8c26b1a477911
|
|
| BLAKE2b-256 |
ec4a2a2d13c044239dc4c77db45539cf64dc0aaea053e999387d79c566bb916e
|