Skip to main content

Structured logging and metrics for Python services

Project description

Banner

flexinfer-observability

Header

pipeline status coverage report

Standardized observability library for Python services in the FlexInfer ecosystem.

Features

  • Structured Logging: JsonFormatter with automatic OpenTelemetry trace ID injection.
  • Metrics: BaseMetrics abstraction 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


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

If you're not sure about the file name format, learn more about wheel file names.

flexinfer_observability-0.2.2-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

Details for the file flexinfer_observability-0.2.2-py3-none-any.whl.

File metadata

File hashes

Hashes for flexinfer_observability-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 58613aa460b432db858bfc77e45c662fd5e4fa7c9e48ced9e55903f0801bb928
MD5 3e9214867dcc26e460340eddd10e6eaf
BLAKE2b-256 2da8828448d8bcbc7112a6ef7bda8ece81f1f5936e32d85e2f029d2a956d3836

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page