Skip to main content

Core utilities for UnifyOps Python projects

Project description

UnifyOps Core

Core utilities for UnifyOps Python projects. This package provides shared functionality that can be used across all UnifyOps Python applications.

Features

  • Logging: Standardized logging configuration with JSON support and OpenTelemetry integration
  • Exceptions: Common exception classes with proper HTTP status code mapping
  • OpenTelemetry: Centralized observability setup for tracing and logging

Installation

Basic Installation

pip install unifyops-core

With OpenTelemetry Support

For observability and monitoring with Signoz:

# Basic OpenTelemetry support
pip install unifyops-core[otel]

# Full FastAPI + OpenTelemetry support (recommended for APIs)
pip install unifyops-core[fastapi-otel]

# All optional dependencies
pip install unifyops-core[all]

Using Pipenv

# In your Pipfile
[packages]
unifyops-core = {extras = ["fastapi-otel"], version = "*"}

Then install with:

pipenv install

Usage

OpenTelemetry Setup (New!)

Replace complex OpenTelemetry setup in your service with a single function call:

from unifyops_core.logging import setup_otel_for_service

# Simple setup - replaces 40+ lines of boilerplate
otel_success = setup_otel_for_service(
    service_name="my-api",
    service_version="1.0.0",
    environment="production",
    additional_resource_attributes={
        "team": "backend",
        "domain": "user-management"
    }
)

Logging

from unifyops_core.logging import get_logger

# Create a standard logger
logger = get_logger("my_app")
logger.info("This is a log message")

# Create a JSON logger
json_logger = get_logger("my_app.json", json_format=True)
json_logger.info("This is a structured log", extra={"props": {"user_id": "123", "action": "login"}})

# Log with context
from unifyops_core.logging import log_with_context
log_with_context(logger, logger.INFO, "User logged in", user_id="123", action="login")

Exceptions

from unifyops_core.exceptions import NotFoundError, ValidationError

# Raise standard exceptions
raise NotFoundError("User not found")
raise ValidationError("Invalid email format", details={"email": "Invalid format"})

# Custom exception with details
from unifyops_core.exceptions import UnifyOpsException
raise UnifyOpsException(
    message="Payment processing failed",
    code="PAYMENT_ERROR",
    status_code=400,
    details={"payment_id": "123", "reason": "Insufficient funds"}
)

Installation Options

Extra Description Use Case
otel Basic OpenTelemetry support Services needing observability
fastapi-otel FastAPI + OpenTelemetry instrumentation FastAPI applications
all All optional dependencies Development or full-featured deployments

License

This project is licensed under the MIT License.

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

unifyops_core-1.4.1.tar.gz (46.3 kB view details)

Uploaded Source

Built Distribution

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

unifyops_core-1.4.1-py3-none-any.whl (54.3 kB view details)

Uploaded Python 3

File details

Details for the file unifyops_core-1.4.1.tar.gz.

File metadata

  • Download URL: unifyops_core-1.4.1.tar.gz
  • Upload date:
  • Size: 46.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.4

File hashes

Hashes for unifyops_core-1.4.1.tar.gz
Algorithm Hash digest
SHA256 41164c8afbe8a82f7f3381a32304523d1eec554b96698e703ecdb8e7cfdd823b
MD5 95584b354fc39cfdc8aa32ae079887ba
BLAKE2b-256 c6d5188bfe6fc0b44f099b02168a7e9db90c2c5448c607264658d2eb74a066d8

See more details on using hashes here.

File details

Details for the file unifyops_core-1.4.1-py3-none-any.whl.

File metadata

  • Download URL: unifyops_core-1.4.1-py3-none-any.whl
  • Upload date:
  • Size: 54.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.4

File hashes

Hashes for unifyops_core-1.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 bc9823a08a652613c3c1dd3f04b25c42957f96b5fbd236da54a99c1a4bbb7c35
MD5 bef1c0aa76a316228cc27ac88c1425d4
BLAKE2b-256 2fe52752e1695d85d0707e5df5e0d3b6c468a450a5ff1d67438ad722b9ae9c40

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