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, sink, 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",
  "sink": "newrelic",
  "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.1.tar.gz (3.1 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.1-py3-none-any.whl (3.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: otel_logger-1.0.1.tar.gz
  • Upload date:
  • Size: 3.1 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.1.tar.gz
Algorithm Hash digest
SHA256 3e6ded2837caaed7da73f90b2501b3c3e135b6e42dc7d1713d825261c3bce34c
MD5 b925623a1731cc335d98e33693bd7de7
BLAKE2b-256 5eb6047cf836aea1afa24012dab8f828c36a155622050e18a740499eb639e522

See more details on using hashes here.

File details

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

File metadata

  • Download URL: otel_logger-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 3.5 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c174eea821c4be00de094e26d68a3a9afff693e752fec9d0bc4a0e8462b641c2
MD5 315314801280b3a2f116cedf05d38508
BLAKE2b-256 b00219d806fbafd77292f26bb8566f9e3f1b897fb13076187bdd30c937150050

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