Elina Python SDK
Python tracing SDK for self-hosted Elina. Licensed under MIT.
Install
python -m pip install elinaobs
For development from this repository:
python -m pip install -e '.[dev]'
pytest -q
Public API
from elinaobs import init, trace, flush, shutdown, diagnose, submit_feedback
init(api_key="...", endpoint="http://localhost:3000/v1/traces", service_name="my-agent")
@trace(name="Agent", as_type="agent")
async def run(question):
return await your_code(question)
# The existing OTel-instrumented operations called inside run() are children.
Application feedback is optional. After a trace has finished, an app with a verdict can send it using the same project key. Inside a decorated function, capture the trace ID and keep it with the result:
from opentelemetry import trace as otel_trace
trace_id = f"{otel_trace.get_current_span().get_span_context().trace_id:032x}"
# Later, after the traced function returns:
submit_feedback(trace_id, "bad", note="Wrong answer") # trace_id is 32 lowercase hex characters
Apps without a feedback signal do not call this function. Feedback is stored separately from the dashboard's human review. Keep the project key in server-side code, not in a browser.
To send a demo trace to the local Elina server, create a project in the dashboard and copy its one-time ingestion key. Then, from this directory in PowerShell:
$env:ELINA_WRITE_KEY = "paste-project-ingestion-key"
$env:ELINA_BASE_URL = "http://127.0.0.1:3000"
python examples/agent.py
The script prints the trace ID and reports whether export succeeded. Open the project’s Traces page and select that ID to inspect the three spans and their captured input/output.
Only operations that are explicitly decorated or already instrumented by a compatible OpenTelemetry instrumentation package create spans. No framework integrations are installed, imported, or configured by Elina.
The Elina receiver lives in the iamrobins/elina repository. Start it before running examples/agent.py. The default tests use in-memory and local HTTP receivers.
To also verify export through a real OpenTelemetry Collector, set OTELCOL_BINARY to the Collector executable path and run python -m pytest -q tests/test_collector.py. This optional test starts a local Collector with a file exporter and checks the received spans.
What it does
- Sync + async function decorator with native OTel parent context.
- 10 span display classifications using
elinaobs.observation.type. - Selective export: only spans starting inside a
@trace()scope. - OTLP/HTTP protobuf, bearer-token auth, background batching.
- Optional bounded input/output capture, disabled by default.
- An optional
redactcallback can remove secrets from captured free text before export. attribute_allowlistandattribute_denylistfilter span, event, and link attributes in Elina exports; the denylist wins when both contain a key.- Exceptions automatically record OTel error status/events.
- Shares an existing OpenTelemetry SDK TracerProvider when present.
flush()reports failed export batches or dropped spans.diagnose()returnsfailed_batches,dropped_spans, andretry_attemptswithout exposing credentials. Drop counts are updated after a successful processor flush; retry attempts count extra HTTP requests made for a batch.
Non-goals for v0.1
- Framework adapters or
integrations=[...]. - Raw threads, multiprocessing, distributed orchestration, or generator tracing.
- Automatic patching of uninstrumented Python libraries.
- Prompt management, evaluations, or server/UI implementation.
Known limitations before production
- SDK processor cannot modify existing OTel provider sampling or resources.
- Capture filtering uses a ContextVar marker; parent spans begun before a decorator scope are not exported to Elina unless also eligible.
as_type="event"is a timed span category, not an OTel instant event.- Incoming external spans from
opentelemetry-instrumentshare global provider and may require controlling initialization order. - Bounded batches can drop data on overload.
dropped_spansis current only afterflush()orshutdown().retry_attemptsisNonewhen an OpenTelemetry credential-provider session is configured. Export failures remain counted even if later batches succeed. - Input/output redaction is best-effort only. Explicitly inspect anything you opt in to collect.
- Attribute lists do not change an application's other OpenTelemetry exporters or resource metadata. Keys are matched exactly.
shutdown()ends only Elina's processor. Do not reinitialize the SDK in the same interpreter after shutdown.
See docs/LLD.md for the finalized architecture and build checklist.
Metadata
Release files for elinaobs 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| elinaobs-0.1.1.tar.gz | 18.8 kB | Without provenance | Details for elinaobs-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| elinaobs-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for elinaobs-0.1.1-py3-none-any.whl |
Total release size: 31.1 kB
Release files / elinaobs-0.1.1.tar.gz
| Download URL | elinaobs-0.1.1.tar.gz |
|---|---|
| Size | 18.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e7cf89bed8325d421111b5580a79ad418120e3d0603eeb93ba876ac5e4ec8b95
|
|
BLAKE2b-256 checksum How to use checksums |
353726078f3762d7b9e34aa3a3d1284c11e7556d4fb2c22c933a7e6e73330d14
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Release files / elinaobs-0.1.1-py3-none-any.whl
| Download URL | elinaobs-0.1.1-py3-none-any.whl |
|---|---|
| Size | 12.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1d950acb2f19e633f83356b30c371b6141017c95fdb4d3453a40decf639f32b6
|
|
BLAKE2b-256 checksum How to use checksums |
80295e936e937cfa015c40070f79dc14bc2ba7e2b125d3008f621644f5dfec83
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Security for elinaobs 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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
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.