Structured logging and metrics for Python services
Project description
flexinfer-observability
Standardized observability library for Python services in the FlexInfer ecosystem.
Features
- Structured Logging:
JsonFormatterwith automatic OpenTelemetry trace ID injection. - Metrics:
BaseMetricsabstraction for Prometheus counters/gauges with Pushgateway support. - Timing: Context managers for operation latency measurement.
Usage
Logging
from observability.logging import setup_logging
logger = setup_logging(level="INFO", log_format="json")
logger.info("Service started", extra={"service_id": "api-1"})
Metrics
from observability.metrics import BaseMetrics
from prometheus_client import Counter
class ServiceMetrics(BaseMetrics):
def __init__(self):
super().__init__(job_name="my_service")
self.requests = Counter("requests_total", "Total requests")
metrics = ServiceMetrics()
metrics.requests.inc()
metrics.push()
Configuration
| Environment Variable | Description | Default |
|---|---|---|
LOG_LEVEL |
Log level (DEBUG, INFO, ...) | INFO |
LOG_FORMAT |
logging format (json, plain) | plain |
METRICS_PUSHGATEWAY_URL |
Prometheus Pushgateway URL | None |
METRICS_JOB_NAME |
Job name for metrics | default_job |
Installation
pip install flexinfer-observability
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
No source distribution files available for this release.See tutorial on generating distribution archives.
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 flexinfer_observability-0.2.2-py3-none-any.whl.
File metadata
- Download URL: flexinfer_observability-0.2.2-py3-none-any.whl
- Upload date:
- Size: 6.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
58613aa460b432db858bfc77e45c662fd5e4fa7c9e48ced9e55903f0801bb928
|
|
| MD5 |
3e9214867dcc26e460340eddd10e6eaf
|
|
| BLAKE2b-256 |
2da8828448d8bcbc7112a6ef7bda8ece81f1f5936e32d85e2f029d2a956d3836
|