Metadata-Version: 2.4
Name: aethel-telemetry
Version: 0.4.0
Summary: Zero-allocation structured log formatting, distributed trace propagation, and OpenTelemetry-compatible metrics instrumentation for cloud-native Python services
Author-email: Aethel Infrastructure Engineering <oss@aethel.dev>
License-Expression: Apache-2.0
Project-URL: Homepage, https://aethel.dev
Project-URL: Documentation, https://docs.aethel.dev/telemetry
Project-URL: Repository, https://github.com/aethel-infra/aethel-telemetry
Project-URL: Tracker, https://github.com/aethel-infra/aethel-telemetry/issues
Project-URL: Changelog, https://github.com/aethel-infra/aethel-telemetry/blob/main/CHANGELOG.md
Keywords: telemetry,tracing,structured-logging,opentelemetry,observability,metrics,microservices,cloud-native,sre
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Information Technology
Classifier: Intended Audience :: System Administrators
Classifier: Topic :: System :: Monitoring
Classifier: Topic :: System :: Logging
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Operating System :: OS Independent
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Provides-Extra: dev
Requires-Dist: pytest>=7.0.0; extra == "dev"
Requires-Dist: build; extra == "dev"
Requires-Dist: twine; extra == "dev"
Dynamic: license-file

# Aethel Telemetry (`aethel-telemetry`)

[![PyPI version](https://img.shields.io/pypi/v/aethel-telemetry.svg)](https://pypi.org/project/aethel-telemetry/)
[![License: Apache-2.0](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
[![Python Version](https://img.shields.io/badge/python-3.9+-brightgreen.svg)](https://www.python.org/downloads/)
[![OpenTelemetry Compatible](https://img.shields.io/badge/OpenTelemetry-Compliant-blueviolet.svg)](https://aethel.dev)
[![Build Status](https://img.shields.io/badge/build-passing-brightgreen.svg)](https://aethel.dev)

A zero-allocation, high-throughput observability framework for Python. Provides structured JSON log formatting, distributed trace propagation (W3C TraceContext), and in-memory metric aggregation for cloud-native microservices.

---

## Features

- **Structured JSON Logging**: Single-line JSON emission with automatic `trace_id` and `span_id` injection. Compatible with Datadog, Grafana Loki, AWS CloudWatch, and Elasticsearch.
- **Distributed Trace Propagation**: Seamless propagation across async boundaries using standard `contextvars` and W3C `traceparent` headers.
- **Microsecond Function Profiling**: `@traced` decorator measuring wall-clock latency with contextual correlation.
- **Thread-Safe Metrics Registry**: In-memory `Counter` and `Gauge` primitives with lock-free snapshot capabilities.
- **Zero Heavy Dependencies**: Pure standard library implementation with zero external runtime packages.

---

## Installation

```bash
pip install aethel-telemetry
```

---

## Quickstart

### 1. Structured JSON Logging with Trace Correlation

```python
from aethel import StructuredLogger, TraceContext

logger = StructuredLogger(service_name="billing-engine", environment="production")

with TraceContext():
    logger.info("Payment initiated", customer_id="cust_9410", amount_usd=129.50)
```

**Output:**
```json
{
  "timestamp": "2026-11-25T04:50:12.894102+00:00",
  "level": "INFO",
  "service": "billing-engine",
  "env": "production",
  "trace_id": "4bf92f3577b34da6a3ce929d0e0e4736",
  "span_id": "00f067aa0ba902b7",
  "message": "Payment initiated",
  "extra": {
    "customer_id": "cust_9410",
    "amount_usd": 129.5
  }
}
```

### 2. Distributed Tracing Decorator

```python
from aethel import traced

@traced(name="query_account_ledger")
def query_account_ledger(account_id: str):
    # Function execution time is measured and correlated with the active trace
    return {"balance": 5420.00}
```

### 3. Application Metrics

```python
from aethel import MetricsRegistry

metrics = MetricsRegistry()
req_counter = metrics.counter("http_requests_total", "Total incoming HTTP requests")
active_gauge = metrics.gauge("db_connections_active", "Current active database pool connections")

req_counter.inc()
active_gauge.set(12.0)

print(metrics.snapshot())
```

---

## License

Aethel Telemetry is distributed under the **Apache License 2.0**.
Copyright 2026 Aethel Infrastructure Ltd.
