Skip to main content

Structured JSON logging for OpenTelemetry and New Relic

Project description

Title:
otel-logger: Structured JSON Logging for OpenTelemetry and New Relic

Summary:
otel-logger is a lightweight Python logging package that outputs structured JSON logs compatible with OpenTelemetry and New Relic observability platforms. It simplifies logging by providing a consistent schema for service name, environment, and custom fields, making it ideal for distributed systems and cloud-native applications.

Features:

  • ✅ Structured JSON logs for easy ingestion by observability tools.
  • ✅ Supports custom fields via extra parameter.
  • ✅ Configurable service.name, log level, and file path.
  • ✅ Default metadata: team, vsn for uniform logging.
  • ✅ Simple integration with Python’s built-in logging module.

Example Usage:

import logging
from otel_logger import get_otel_logger

logger = get_otel_logger(
    log_file="/app/logs/otel.log",
    service_name="Cloud Billing",
    level=logging.INFO
)

logger.info("Billing process started", extra={"extra_fields": {"request_id": "12345"}})

Output:

{
  "timestamp": "2025-11-25T11:30:00Z",
  "level": "INFO",
  "message": "Billing process started",
  "service.name": "Cloud Billing",
  "team": "sse",
  "vsn": "v1.0.0",
  "request_id": "12345"
}

Installation:

pip install otel-logger

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

otel_logger-1.0.2.tar.gz (3.7 kB view details)

Uploaded Source

Built Distribution

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

otel_logger-1.0.2-py3-none-any.whl (4.1 kB view details)

Uploaded Python 3

File details

Details for the file otel_logger-1.0.2.tar.gz.

File metadata

  • Download URL: otel_logger-1.0.2.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for otel_logger-1.0.2.tar.gz
Algorithm Hash digest
SHA256 86fdeb46abdded59143f1625381aac4ca50d37bea0043d109e8aa2087de58cf2
MD5 51f123513882c5d2567970eceb98a274
BLAKE2b-256 6591ba7399ee2a332e20b08f9c220b83a88d7cdd0ceaeda65987a5611410af5c

See more details on using hashes here.

File details

Details for the file otel_logger-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: otel_logger-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 4.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for otel_logger-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 50d3c87776b7d638239bf8f6c98796524905e056330ce2dd67be94aa92f1513e
MD5 439bf6922b5237a2c5937de53c90c38e
BLAKE2b-256 36c6041a9ac6b413b37a336e076de5d28208663db529f4b82307b7a4f54b67e7

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