Skip to main content

simple_otel_py

A simple library for setting up OpenTelemetry logging, tracing, and metrics in Python applications.

Features

  • 🔹 Easy integration with OpenTelemetry
  • 📊 Logs, traces, and metrics sent to an existing (open) OTLP collector
  • 🖥️ Console logging for debugging
  • 📡 Support for OpenTelemetry instrumentation

Installation

pip install simple_otel_py

Usage

Initialize OpenTelemetry Components

from simple_otel_py import OtelSetup

# Create an instance with service name and OTLP collector endpoint
otel = OtelSetup(name="my_service", otlp_collector_endpoint="http://localhost:4317")

# Initialize logging
logger = otel.get_logger()
logger.info("This is a test log!")

## If needed, you can pass a scope_name to create multiple logger
acme_logger = otel.get_logger("acme")

# You can provide your own formatter to the logger
import logging
formatter = logging.Formatter('%(asctime)s | %(name)s | %(levelname)s | %(message)s')
logger = otel.get_logger(formatter)


# Initialize tracing
trace, tracer = otel.init_tracing()
with tracer.start_as_current_span("test_span"):
    logger.info("Tracing this operation!")

# you can add attributes to the trace
current_span = trace.get_current_span()
current_span.set_attribute("my.custom.attr", "something")

## or add tracing via decorator
@tracer.start_as_current_span("Tracing this operation!")

# Initialize metrics
meter = otel.init_metrics()
counter = meter.create_counter("my_counter")
counter.add(1)

# Enable auto-instrumentation for requests
request_inst = otel.get_request_instrumentor()
request_inst().instrument()

# Make a request (will be traced automatically)
import requests
response = requests.get("https://example.com")
print(response.status_code)

Configuration

Ensure you have an OpenTelemetry collector running, such as:

docker run --rm -p 4317:4317 -p 4318:4318 \
  otel/opentelemetry-collector-contrib:latest

License

This project is licensed under the MIT License.

Metadata

Release files for simple-otel-py 0.0.9

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for simple-otel-py 0.0.9
File Size Uploaded Provenance Actions
simple_otel_py-0.0.9.tar.gz 4.2 kB Without provenance Details for simple_otel_py-0.0.9.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for simple-otel-py 0.0.9
File Interpreter ABI Platform Actions
simple_otel_py-0.0.9-py3-none-any.whl Python 3 none any Details for simple_otel_py-0.0.9-py3-none-any.whl

Total release size: 8.8 kB

Release files / simple_otel_py-0.0.9.tar.gz

Download URL simple_otel_py-0.0.9.tar.gz
Size 4.2 kB
Tags Source
SHA-256 checksum
How to use checksums
f0bd86a8d13302e7e40a36b409b222a2ddd3c7031b4f3e8a0c04e8c8114fa8eb
BLAKE2b-256 checksum
How to use checksums
c28ff4eba4cb24ab4517774a6306755d677f8cd8c7d6bd310a8993319810470c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.11

Release files / simple_otel_py-0.0.9-py3-none-any.whl

Download URL simple_otel_py-0.0.9-py3-none-any.whl
Size 4.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4e7ea7f9936d108e117a5762a53812fccae6fc8470ba644694cefe495f03e981
BLAKE2b-256 checksum
How to use checksums
54ce4d40f685af1e69a6e68080f8157e1ab899dbe59608c8ca0c1fe0669ea4bf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.11

Security for simple-otel-py 0.0.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page