Skip to main content

No project description provided

Project description

akmi-utils

A utility package for various functionalities including converting TOML files to YAML format, logging, and OpenTelemetry integration.

Prerequisites

  • Python 3.12 or higher
  • Poetry

Installation

  1. Clone the repository:

    git clone https://github.com/yourusername/akmi-utils.git
    cd akmi-utils
    
  2. Install dependencies using Poetry:

    poetry install
    

Usage

Converting TOML to YAML

To use the convert_toml_to_yaml function, follow these steps:

  1. Import the function in your script:

    from akmi_utils.convert_toml_yaml import convert_toml_to_yaml
    
  2. Call the function with the input TOML file path and output YAML file path:

    convert_toml_to_yaml('path/to/input.toml', 'path/to/output.yaml')
    

Logging Requests

To log requests in a FastAPI application, use the log_requests middleware:

  1. Import and add the middleware to your FastAPI app:
    from akmi_utils.logging import log_requests
    
    app = FastAPI()
    app.middleware('http')(log_requests)
    

OpenTelemetry Integration

To set up OpenTelemetry with FastAPI, use the setting_otlp function and PrometheusMiddleware:

  1. Import and configure OpenTelemetry in your FastAPI app:
    from akmi_utils.otel import setting_otlp, PrometheusMiddleware, metrics
    
    app = FastAPI()
    setting_otlp(app, app_name='your_app_name', endpoint='your_otlp_endpoint')
    app.add_middleware(PrometheusMiddleware, app_name='your_app_name')
    app.add_route('/metrics', metrics)
    

Running Tests

To run the tests, use the following command:

poetry run pytest

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

akmi_utils-0.1.6.2.tar.gz (6.5 kB view details)

Uploaded Source

Built Distribution

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

akmi_utils-0.1.6.2-py3-none-any.whl (8.5 kB view details)

Uploaded Python 3

File details

Details for the file akmi_utils-0.1.6.2.tar.gz.

File metadata

  • Download URL: akmi_utils-0.1.6.2.tar.gz
  • Upload date:
  • Size: 6.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.1 CPython/3.12.8 Darwin/23.6.0

File hashes

Hashes for akmi_utils-0.1.6.2.tar.gz
Algorithm Hash digest
SHA256 0a7d1f0b834180ff9982824e238ccf2c5db905bae0975e13893746060eea32a9
MD5 98c0a5b6a43be07f4e0a6c88878f2b89
BLAKE2b-256 6da4da0073232a480a746766a0fc66a22b40fad33ff38a61749c0b0c345f7c0e

See more details on using hashes here.

File details

Details for the file akmi_utils-0.1.6.2-py3-none-any.whl.

File metadata

  • Download URL: akmi_utils-0.1.6.2-py3-none-any.whl
  • Upload date:
  • Size: 8.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.1 CPython/3.12.8 Darwin/23.6.0

File hashes

Hashes for akmi_utils-0.1.6.2-py3-none-any.whl
Algorithm Hash digest
SHA256 8be87743b6fbecd04322254c9a8a2043a86e9d6bd30040521c0abfd7d93c53bd
MD5 020976a57d95a4ac88d90197dfcc2a13
BLAKE2b-256 480af3b84f1060bb196e4960db9663c75385e0b8694a54b47276b5e7f8c50575

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