Skip to main content

This repository provides utility tools and common functions for FK projects, including helpers for configuration, logging, middleware, AWS integration, and OpenTelemetry instrumentation for Python web frameworks.

Project description

fk-util-tools

Utility tools and shared functions for FK projects: centralized configuration, logging, middlewares, AWS integration, and OpenTelemetry tracing for Python web frameworks.

Installation

pip install fk-util-tools

Main Features

  • Centralized Configuration: Config class for global settings management.
  • Cache: Redis integration.
  • Environment Variables & AWS: Access to AWS Parameter Store and Secrets Manager.
  • Custom Exceptions: HTTP error handling with custom codes.
  • Structured Logging: Logging for FastAPI and other frameworks.
  • Middlewares: SQL Printer, error handling, internationalization, and language support for Flask, Django, and FastAPI.
  • OpenTelemetry Tracing: Instrumentation for Flask, Django, FastAPI, and AWS Lambda.
  • Type Hints: PEP 561 support.

Usage Examples

Configuration

from fk_utils import SETTINGS
print(SETTINGS.ENV)

Structured Logging in FastAPI

from fastapi import FastAPI
from fk_utils.logging.fastapi.logging import setup_logging

app = FastAPI()
setup_logging(app)

SQL Printer Middleware

Flask

from flask import Flask
from fk_utils.middlewares.flask.sql_middleware import SqlPrintingMiddleware

app = Flask(__name__)
app.config['DEBUG'] = True
SqlPrintingMiddleware(app)

Django

from fk_utils.middlewares.django.sql_middleware import SqlPrintingMiddleware

SqlPrintingMiddleware()

FastAPI

from fk_utils.middlewares.fastapi.sql_middleware import SqlPrintingMiddleware

app = FastAPI()
SqlPrintingMiddleware(app)

OpenTelemetry Instrumentation

from fk_utils.traces.opentelemetry.fastapi.trace import instrument_app

app = FastAPI()
instrument_app(app)

AWS Lambda Instrumentation

from fk_utils.traces.opentelemetry.fastapi.aws_lambda.trace import instrument_app

app = FastAPI()
is_lambda = instrument_app(app, instrument_lambda=True)
print("Lambda instrumented:", is_lambda)

License

MIT

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

fk_util_tools-0.2.0.tar.gz (9.8 kB view details)

Uploaded Source

Built Distribution

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

fk_util_tools-0.2.0-py3-none-any.whl (20.8 kB view details)

Uploaded Python 3

File details

Details for the file fk_util_tools-0.2.0.tar.gz.

File metadata

  • Download URL: fk_util_tools-0.2.0.tar.gz
  • Upload date:
  • Size: 9.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.4 CPython/3.13.7 Linux/6.11.0-1018-azure

File hashes

Hashes for fk_util_tools-0.2.0.tar.gz
Algorithm Hash digest
SHA256 920e41761016a144d5227b887333236f1a035777e49ce4b17647f6e8d4cd3791
MD5 b132519df8c09917bfc82c5bb6a82b54
BLAKE2b-256 23a67ee8e87ab2d988c0a714d24b1baa4aa6e1197554441523eaa0f06438a315

See more details on using hashes here.

File details

Details for the file fk_util_tools-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: fk_util_tools-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 20.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.4 CPython/3.13.7 Linux/6.11.0-1018-azure

File hashes

Hashes for fk_util_tools-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cc65778f47f6af01cd6816afcfd88eac891ecd30bbc10b5f66076688d4456b25
MD5 c87cf7c5a235ad520d76bc2c44e0deeb
BLAKE2b-256 8ee137be92e55b9978253baded4732aa55ca86bfd5c6de62157d84e4dfda14b3

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