Skip to main content

Shared logging and metrics library for Road24 FastAPI microservices

Project description

road24-sdk

Shared logging and metrics SDK for Road24 microservices. Provides structured JSON logging, Prometheus metrics, and framework-specific integrations following a Sentry SDK-like pattern.

Installation

# Core library
pip install road24-sdk

# With all integrations
pip install road24-sdk[all]

# Development (includes test tools)
pip install road24-sdk[dev]

Quick Start

import road24_sdk
from fastapi import FastAPI
from httpx import AsyncClient, Timeout
from road24_sdk.integrations.fastapi import FastApiLoggingIntegration
from road24_sdk.integrations.httpx import HttpxLoggingIntegration
from road24_sdk.integrations.redis import RedisLoggingIntegration
from road24_sdk.integrations.sqlalchemy import SqlalchemyLoggingIntegration

def setup_road24_sdk():
    road24_sdk.init(
        service_name="my-service",
        log_level="INFO",
        integrations=[
            HttpxLoggingIntegration(),
            SqlalchemyLoggingIntegration(),
            RedisLoggingIntegration(),
        ],
    )

# FastAPI requires .setup(app) since it needs the app instance
app = FastAPI()
setup_road24_sdk()
FastApiLoggingIntegration().setup(app)

Available Integrations

Integration Extra Description
FastApiLoggingIntegration fastapi Inbound HTTP request/response logging and metrics
HttpxLoggingIntegration httpx Outbound HTTP request/response logging and metrics
SqlalchemyLoggingIntegration sqlalchemy Database query logging and metrics
RedisLoggingIntegration redis Redis command logging and metrics

Manual Testing

Standalone scripts to inspect structured JSON logs and metrics (no server needed):

make test-logs-http-input    # Inbound HTTP request log
make test-logs-http-output   # Outbound HTTPX request log
make test-metrics-http       # Prometheus metrics after HTTP calls
make test-logs-redis         # Redis command logs (SET, GET, HSET, etc.)
make test-logs-db            # DB query logs (SELECT, INSERT, UPDATE, DELETE)

Development

make install    # Install all dependencies (requires uv)
make test       # Run tests with coverage
make lint       # Lint with ruff
make format     # Format with ruff
make check      # Lint + test

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

road24_sdk-0.1.4.tar.gz (92.5 kB view details)

Uploaded Source

Built Distribution

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

road24_sdk-0.1.4-py3-none-any.whl (16.9 kB view details)

Uploaded Python 3

File details

Details for the file road24_sdk-0.1.4.tar.gz.

File metadata

  • Download URL: road24_sdk-0.1.4.tar.gz
  • Upload date:
  • Size: 92.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for road24_sdk-0.1.4.tar.gz
Algorithm Hash digest
SHA256 79f6b5b0b48fee8c661e1504d9d3e3758e02d200ab127d7b0ec0f71157ff0670
MD5 596603cf544c81c8f1f56da52b373c12
BLAKE2b-256 abc01724ab3c64bd912ebd46e05a77b9aaaa62f39fd4a1350e554fbb2e21b728

See more details on using hashes here.

File details

Details for the file road24_sdk-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: road24_sdk-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 16.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for road24_sdk-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 a22e9b25784f471416328b9fec7d5782324f8033dcedc815d6dfec53a491e265
MD5 40d98fb9b5f791d3053b4852d20f27c8
BLAKE2b-256 189632f9ec4d09cbf2e700b6b276aac3c65eda945426d47dfa005d43df5971ef

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