Skip to main content

Production-grade logging SDK for VedaTrace

Project description

VedaTrace Python SDK

Production-grade logging SDK for VedaTrace (Python 3.10+).

Table of Contents

Features

  • Log levels aligned to parity: debug, info, warning, error, fatal
  • Structured log records with UTC ISO-8601 timestamps
  • Default transports: Console (optional) + HTTP ingest
  • Custom transport support via config.transports
  • Opt-in batching with threshold + interval flush
  • HTTP-only fixed-delay retries
  • Child loggers with metadata precedence support
  • Safe public API: logger methods do not raise user-facing exceptions

Stability

Version 0.1.0 introduces a stable public API for:

  • Logger
  • Config
  • Transports
  • Batching
  • Retry
  • Child loggers

Breaking changes may still occur before 1.0.

Installation

python -m pip install vedatrace

For local development:

python -m pip install -e .

Quickstart

from vedatrace import VedaTrace

logger = VedaTrace(api_key="YOUR_API_KEY", service="my-service")
logger.info("hello from vedatrace")

Configuration

from vedatrace import BatchingConfig, RetryConfig, VedaTrace, VedaTraceConfig

config = VedaTraceConfig(
    api_key="YOUR_API_KEY",
    service="my-service",
    console_enabled=True,
    batching=BatchingConfig(enabled=False, batch_size=10, flush_interval_seconds=5.0),
    retry=RetryConfig(max_retries=0, retry_delay_seconds=0.0),
)

logger = VedaTrace(api_key="YOUR_API_KEY", service="my-service", config=config)

Transports

Default behavior:

  • Console transport is enabled when config.console_enabled is True
  • HTTP transport is enabled by default

Custom transports:

  • Provide config.transports to fully override default transport creation

Batching (Opt-in)

Batching is disabled by default and must be enabled in BatchingConfig.

from vedatrace import BatchingConfig, VedaTrace, VedaTraceConfig

config = VedaTraceConfig(
    api_key="YOUR_API_KEY",
    service="my-service",
    batching=BatchingConfig(enabled=True, batch_size=10, flush_interval_seconds=5.0),
)

logger = VedaTrace(api_key="YOUR_API_KEY", service="my-service", config=config)
logger.info("batched log")
logger.flush()

Retry (HTTP only)

Retries are fixed-delay and apply only to the default HTTP transport.

from vedatrace import RetryConfig, VedaTrace, VedaTraceConfig

config = VedaTraceConfig(
    api_key="YOUR_API_KEY",
    service="my-service",
    retry=RetryConfig(max_retries=3, retry_delay_seconds=1.0),
    console_enabled=False,
)

logger = VedaTrace(api_key="YOUR_API_KEY", service="my-service", config=config)

If retries are exhausted, on_error receives the final failure.

Child Loggers

from vedatrace import VedaTrace

parent = VedaTrace(api_key="YOUR_API_KEY", service="my-service")
api_logger = parent.child({"module": "api"})
api_logger.info("request handled", {"request_id": "123"})

Metadata precedence:

  • parent defaults < child defaults < per-call metadata

child.close() does not tear down shared engine resources.

Error Handling & Safety

  • Public logger methods are non-throwing (debug/info/warning/error/fatal/flush/close)
  • Internal failures are routed to on_error(Exception) when configured
  • SDK avoids exposing API keys in logs/errors

Resource Management (flush/close)

  • flush() forces pending batches to be sent
  • close() flushes and then closes owned resources
  • Child loggers share engine resources; parent logger owns teardown

API Reference

Factory:

  • VedaTrace(api_key: str, service: str, *, config: VedaTraceConfig | None = None) -> Logger

Logger:

  • debug(message: str, metadata: Metadata | None = None) -> None
  • info(message: str, metadata: Metadata | None = None) -> None
  • warning(message: str, metadata: Metadata | None = None) -> None
  • error(message: str, metadata: Metadata | None = None) -> None
  • fatal(message: str, metadata: Metadata | None = None) -> None
  • child(default_metadata: Metadata | None = None, *, service: str | None = None) -> Logger
  • flush() -> None
  • close() -> None

Config classes:

  • VedaTraceConfig(api_key, service, console_enabled=True, batching=BatchingConfig(...), retry=RetryConfig(...), transports=None, on_error=None)
  • BatchingConfig(enabled=False, batch_size=10, flush_interval_seconds=5.0)
  • RetryConfig(max_retries=0, retry_delay_seconds=0.0)

Transport types:

  • Transport protocol:
    • emit(records: list[LogRecord]) -> None
    • close() -> None
  • Included transports:
    • ConsoleTransport
    • HttpTransport

Behavior notes:

  • Public log methods never raise.
  • Internal failures route to on_error(Exception) when configured.
  • Batching is opt-in.
  • Retry applies to HTTP transport only.
  • child.close() does not tear down the shared engine.

Release Process (Maintainers)

  1. Bump version in:
  • src/vedatrace/__init__.py
  • pyproject.toml
  • CHANGELOG.md
  1. Run:
  • python -m unittest -v
  • python -m compileall src
  1. Build:
  • python -m build
  1. Validate:
  • twine check dist/*
  1. Publish (when ready):
  • python -m pip install twine
  • twine upload dist/*

Notes:

  • Never force push release commits.
  • Tag releases using:
  • git tag v0.1.0
  • git push origin v0.1.0

License

MIT

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

vedatrace-0.1.0.tar.gz (21.4 kB view details)

Uploaded Source

Built Distribution

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

vedatrace-0.1.0-py3-none-any.whl (14.7 kB view details)

Uploaded Python 3

File details

Details for the file vedatrace-0.1.0.tar.gz.

File metadata

  • Download URL: vedatrace-0.1.0.tar.gz
  • Upload date:
  • Size: 21.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for vedatrace-0.1.0.tar.gz
Algorithm Hash digest
SHA256 12d669e7a35340c1d0829b5a012d6b57eb6d3d739e05c61d736dcb0e0d1a3204
MD5 baed9c2da4c6d090bbb729ea7d79e789
BLAKE2b-256 e7f9256ced6ba534bcce8befde484d6e6c166ec376d7bacfc0241f0fd248e2b9

See more details on using hashes here.

Provenance

The following attestation bundles were made for vedatrace-0.1.0.tar.gz:

Publisher: release.yml on neumann007/vedatrace-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file vedatrace-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: vedatrace-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 14.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for vedatrace-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fcc0d89cef53976f60747bf25a285479bd048330e4fdc021be3c7d68ad06dcc4
MD5 db7bffba22eb9969bf3c11489a1f9f81
BLAKE2b-256 02213d04be055130bea47366aaaf04e14338a9995b4efdcd945d1df4c199a1d4

See more details on using hashes here.

Provenance

The following attestation bundles were made for vedatrace-0.1.0-py3-none-any.whl:

Publisher: release.yml on neumann007/vedatrace-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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