Official Python SDK for JustAnalytics — end-to-end observability (traces, errors, logs, metrics)
Project description
justanalytics-python
Official Python SDK for JustAnalytics — end-to-end observability (traces, errors, logs, metrics).
Installation
pip install justanalytics-python
With framework extras:
pip install justanalytics-python[django]
pip install justanalytics-python[flask]
pip install justanalytics-python[fastapi]
pip install justanalytics-python[requests]
Quick Start
import justanalytics
justanalytics.init(
site_id="site_abc123",
api_key="ja_sk_your_api_key_here",
service_name="api-server",
environment="production",
)
# Traced spans (context manager)
with justanalytics.start_span("process-order") as span:
span.set_attribute("order.id", "12345")
result = process_order()
# Decorator
@justanalytics.span(op="db.query")
def get_user(user_id: str):
return db.query(...)
# Error capture
try:
risky_operation()
except Exception as e:
justanalytics.capture_exception(e, tags={"module": "payments"})
# Message capture
justanalytics.capture_message("Deployment complete", level="info")
# User context
justanalytics.set_user(id="user-123", email="alice@example.com")
# Tags
justanalytics.set_tag("feature", "checkout")
# Structured logging
justanalytics.log("info", "User logged in", {"userId": "u123"})
# Metrics
justanalytics.record_metric("custom.queue_size", 42, {"queue": "emails"})
# Flush before shutdown
justanalytics.flush()
justanalytics.close()
Framework Integrations
Django
# settings.py
MIDDLEWARE = [
"justanalytics.integrations.django.JustAnalyticsMiddleware",
# ... other middleware
]
Flask
from flask import Flask
from justanalytics.integrations.flask import JustAnalyticsMiddleware
app = Flask(__name__)
JustAnalyticsMiddleware(app)
FastAPI
from fastapi import FastAPI
from justanalytics.integrations.fastapi import JustAnalyticsMiddleware
app = FastAPI()
app.add_middleware(JustAnalyticsMiddleware)
requests library
from justanalytics.integrations.requests import RequestsIntegration
integration = RequestsIntegration(service_name="my-service")
integration.enable()
# All requests.get/post calls are now traced
Python logging bridge
import logging
from justanalytics.integrations.logging import JustAnalyticsHandler
handler = JustAnalyticsHandler(level=logging.WARNING)
logging.getLogger().addHandler(handler)
W3C Trace Context
from justanalytics import parse_traceparent, serialize_traceparent
# Parse incoming header
data = parse_traceparent("00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01")
# Serialize outgoing header
header = serialize_traceparent(trace_id, span_id, sampled=True)
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file justanalytics_python-0.1.1.tar.gz.
File metadata
- Download URL: justanalytics_python-0.1.1.tar.gz
- Upload date:
- Size: 33.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2fe44e7a2940602b607c85e977f608164dcaea1243aa46fe0feb8aaeafa7d58c
|
|
| MD5 |
40043f9aa6b1950cee2d290d5be7f798
|
|
| BLAKE2b-256 |
4aef31a03a443b124ad780c299ce44329cea907ed9874f29a13c8d884a5574cc
|
File details
Details for the file justanalytics_python-0.1.1-py3-none-any.whl.
File metadata
- Download URL: justanalytics_python-0.1.1-py3-none-any.whl
- Upload date:
- Size: 34.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2e80b41e9019415615c68f28789862c009e451975642df35655a1b68a97f03b9
|
|
| MD5 |
f6d37a9f6e42ea34ec8f1470a12b27f0
|
|
| BLAKE2b-256 |
9c764e14509319a5aeabe433885a1fa0ec6d4420997550283f9561431f21b7e8
|