klyna
Official Klyna SDK for Python. Automatically captures HTTP request metrics and sends them to the Klyna platform. Zero external dependencies — pure Python stdlib.
Installation
pip install klyna
Quick Start
FastAPI / Starlette (ASGI)
from fastapi import FastAPI
from klyna import KlynaASGIMiddleware, KlynaConfig
app = FastAPI()
config = KlynaConfig(api_key='sk_live_...')
# Wraps FastAPI, Starlette, or Django ASGI
app = KlynaASGIMiddleware(app, config)
Flask
from flask import Flask
from klyna import KlynaFlask, KlynaConfig
app = Flask(__name__)
config = KlynaConfig(api_key='sk_live_...')
klyna = KlynaFlask(app, config)
Application factory pattern:
from klyna import KlynaFlask, KlynaConfig
klyna = KlynaFlask()
def create_app():
app = Flask(__name__)
klyna.init_app(app, KlynaConfig(api_key='sk_live_...'))
return app
Django
Add to settings.py:
MIDDLEWARE = [
'klyna.middleware.django.KlynaDjangoMiddleware',
# ... your other middleware
]
KLYNA_API_KEY = 'sk_live_...'
Or configure programmatically in wsgi.py:
from klyna import KlynaConfig
from klyna.middleware.django import KlynaDjangoMiddleware
application = get_wsgi_application()
application = KlynaDjangoMiddleware(application, KlynaConfig(api_key='sk_live_...'))
Starlette
from starlette.applications import Starlette
from klyna import KlynaASGIMiddleware, KlynaConfig
app = Starlette(routes=[...])
app = KlynaASGIMiddleware(app, KlynaConfig(api_key='sk_live_...'))
Configuration Reference
| Option | Type | Default | Description |
|---|---|---|---|
api_key |
str |
required | Your Klyna API key (sk_live_...) |
base_url |
str |
https://app.klyna.io |
Override for self-hosted deployments |
batch_size |
int |
50 |
Flush when queue reaches this size |
flush_interval |
float |
5.0 |
Flush interval in seconds |
sample_rate |
float |
1.0 |
Fraction of requests to capture (0.0–1.0) |
ignored_paths |
List[str] |
['/health', '/healthz', '/readyz', '/metrics', '/favicon.ico'] |
Paths to skip |
timeout |
float |
10.0 |
HTTP request timeout in seconds |
debug |
bool |
False |
Log SDK activity to stderr |
Graceful Shutdown
The SDK registers an atexit handler automatically. For explicit control:
import signal
from klyna import KlynaClient, KlynaConfig
client = KlynaClient(KlynaConfig(api_key='sk_live_...'))
def handler(sig, frame):
client.shutdown()
raise SystemExit(0)
signal.signal(signal.SIGTERM, handler)
License
MIT
Metadata
Release files for klyna 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| klyna-1.0.0.tar.gz | 9.6 kB | Without provenance | Details for klyna-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| klyna-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for klyna-1.0.0-py3-none-any.whl |
Total release size: 18.9 kB
Release files / klyna-1.0.0.tar.gz
| Download URL | klyna-1.0.0.tar.gz |
|---|---|
| Size | 9.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e279e451a3071fa5b470a1e298116a969414fdf7a97b08c9e284b4bc725033df
|
|
BLAKE2b-256 checksum How to use checksums |
a38b56ea5cdd2a29b71ecfddd0dd401b1bb24a13f2c97ee1d5486579a93c2e42
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.4
|
Release files / klyna-1.0.0-py3-none-any.whl
| Download URL | klyna-1.0.0-py3-none-any.whl |
|---|---|
| Size | 9.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
756b6e2097674c74f61264d8615695b9b57a27e63857476eaa3a252a093e4829
|
|
BLAKE2b-256 checksum How to use checksums |
d7e5b5d651acf5b99780e1ebae6581230cb1f75e9044578b98ce0590215eedf4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.4
|
Security for klyna 1.0.0
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.