justanalytics-python 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- justanalytics_python-0.1.0/.gitignore +58 -0
- justanalytics_python-0.1.0/PKG-INFO +173 -0
- justanalytics_python-0.1.0/README.md +134 -0
- justanalytics_python-0.1.0/justanalytics/__init__.py +429 -0
- justanalytics_python-0.1.0/justanalytics/client.py +665 -0
- justanalytics_python-0.1.0/justanalytics/context.py +143 -0
- justanalytics_python-0.1.0/justanalytics/integrations/__init__.py +11 -0
- justanalytics_python-0.1.0/justanalytics/integrations/django.py +157 -0
- justanalytics_python-0.1.0/justanalytics/integrations/fastapi.py +197 -0
- justanalytics_python-0.1.0/justanalytics/integrations/flask.py +203 -0
- justanalytics_python-0.1.0/justanalytics/integrations/logging.py +175 -0
- justanalytics_python-0.1.0/justanalytics/integrations/requests.py +149 -0
- justanalytics_python-0.1.0/justanalytics/integrations/urllib3.py +146 -0
- justanalytics_python-0.1.0/justanalytics/span.py +281 -0
- justanalytics_python-0.1.0/justanalytics/trace_context.py +124 -0
- justanalytics_python-0.1.0/justanalytics/transport.py +430 -0
- justanalytics_python-0.1.0/justanalytics/types.py +214 -0
- justanalytics_python-0.1.0/pyproject.toml +57 -0
- justanalytics_python-0.1.0/tests/__init__.py +1 -0
- justanalytics_python-0.1.0/tests/test_client.py +413 -0
- justanalytics_python-0.1.0/tests/test_context.py +176 -0
- justanalytics_python-0.1.0/tests/test_integrations/__init__.py +1 -0
- justanalytics_python-0.1.0/tests/test_integrations/test_django.py +42 -0
- justanalytics_python-0.1.0/tests/test_integrations/test_fastapi.py +70 -0
- justanalytics_python-0.1.0/tests/test_integrations/test_flask.py +48 -0
- justanalytics_python-0.1.0/tests/test_integrations/test_logging.py +164 -0
- justanalytics_python-0.1.0/tests/test_integrations/test_requests.py +92 -0
- justanalytics_python-0.1.0/tests/test_span.py +290 -0
- justanalytics_python-0.1.0/tests/test_trace_context.py +122 -0
- justanalytics_python-0.1.0/tests/test_transport.py +270 -0
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# Dependencies
|
|
2
|
+
node_modules/
|
|
3
|
+
/.pnp
|
|
4
|
+
.pnp.js
|
|
5
|
+
.yarn/install-state.gz
|
|
6
|
+
|
|
7
|
+
# Testing
|
|
8
|
+
coverage/
|
|
9
|
+
|
|
10
|
+
# Build artifacts
|
|
11
|
+
**/dist/
|
|
12
|
+
|
|
13
|
+
# Package lock files in sub-packages
|
|
14
|
+
packages/*/package-lock.json
|
|
15
|
+
|
|
16
|
+
# Next.js
|
|
17
|
+
.next/
|
|
18
|
+
/out/
|
|
19
|
+
|
|
20
|
+
# Production
|
|
21
|
+
/build
|
|
22
|
+
|
|
23
|
+
# Misc
|
|
24
|
+
.DS_Store
|
|
25
|
+
*.pem
|
|
26
|
+
|
|
27
|
+
# Debug
|
|
28
|
+
npm-debug.log*
|
|
29
|
+
yarn-debug.log*
|
|
30
|
+
yarn-error.log*
|
|
31
|
+
|
|
32
|
+
# Local env files
|
|
33
|
+
.env*.local
|
|
34
|
+
.env
|
|
35
|
+
|
|
36
|
+
# Vercel
|
|
37
|
+
.vercel
|
|
38
|
+
|
|
39
|
+
# TypeScript
|
|
40
|
+
*.tsbuildinfo
|
|
41
|
+
next-env.d.ts
|
|
42
|
+
|
|
43
|
+
# IDE
|
|
44
|
+
.vscode/
|
|
45
|
+
.idea/
|
|
46
|
+
|
|
47
|
+
# Prisma
|
|
48
|
+
/prisma/migrations/**/migration_lock.toml
|
|
49
|
+
|
|
50
|
+
# Test artifacts
|
|
51
|
+
/tests/coverage/
|
|
52
|
+
/tests/reports/
|
|
53
|
+
|
|
54
|
+
# GeoIP database (downloaded during build)
|
|
55
|
+
/data/*.mmdb
|
|
56
|
+
|
|
57
|
+
# Source map uploads (Story 055)
|
|
58
|
+
/data/source-maps/
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: justanalytics-python
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Official Python SDK for JustAnalytics — end-to-end observability (traces, errors, logs, metrics)
|
|
5
|
+
Project-URL: Homepage, https://justanalytics.up.railway.app
|
|
6
|
+
Project-URL: Documentation, https://justanalytics.up.railway.app/docs
|
|
7
|
+
Project-URL: Repository, https://github.com/velocitydigitallabs/justanalytics
|
|
8
|
+
Author-email: Velocity Digital Labs LLC <support@velocitydigitallabs.com>
|
|
9
|
+
License-Expression: MIT
|
|
10
|
+
Keywords: analytics,apm,errors,logs,monitoring,observability,tracing
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
20
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
21
|
+
Classifier: Topic :: System :: Monitoring
|
|
22
|
+
Classifier: Typing :: Typed
|
|
23
|
+
Requires-Python: >=3.9
|
|
24
|
+
Requires-Dist: urllib3>=1.26
|
|
25
|
+
Provides-Extra: dev
|
|
26
|
+
Requires-Dist: flask>=2.0; extra == 'dev'
|
|
27
|
+
Requires-Dist: pytest-asyncio>=0.21; extra == 'dev'
|
|
28
|
+
Requires-Dist: pytest>=7.0; extra == 'dev'
|
|
29
|
+
Requires-Dist: requests>=2.20; extra == 'dev'
|
|
30
|
+
Provides-Extra: django
|
|
31
|
+
Requires-Dist: django>=3.2; extra == 'django'
|
|
32
|
+
Provides-Extra: fastapi
|
|
33
|
+
Requires-Dist: starlette>=0.20; extra == 'fastapi'
|
|
34
|
+
Provides-Extra: flask
|
|
35
|
+
Requires-Dist: flask>=2.0; extra == 'flask'
|
|
36
|
+
Provides-Extra: requests
|
|
37
|
+
Requires-Dist: requests>=2.20; extra == 'requests'
|
|
38
|
+
Description-Content-Type: text/markdown
|
|
39
|
+
|
|
40
|
+
# justanalytics-python
|
|
41
|
+
|
|
42
|
+
Official Python SDK for [JustAnalytics](https://justanalytics.up.railway.app) — end-to-end observability (traces, errors, logs, metrics).
|
|
43
|
+
|
|
44
|
+
## Installation
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
pip install justanalytics-python
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
With framework extras:
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
pip install justanalytics-python[django]
|
|
54
|
+
pip install justanalytics-python[flask]
|
|
55
|
+
pip install justanalytics-python[fastapi]
|
|
56
|
+
pip install justanalytics-python[requests]
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Quick Start
|
|
60
|
+
|
|
61
|
+
```python
|
|
62
|
+
import justanalytics
|
|
63
|
+
|
|
64
|
+
justanalytics.init(
|
|
65
|
+
site_id="site_abc123",
|
|
66
|
+
api_key="ja_sk_your_api_key_here",
|
|
67
|
+
service_name="api-server",
|
|
68
|
+
environment="production",
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
# Traced spans (context manager)
|
|
72
|
+
with justanalytics.start_span("process-order") as span:
|
|
73
|
+
span.set_attribute("order.id", "12345")
|
|
74
|
+
result = process_order()
|
|
75
|
+
|
|
76
|
+
# Decorator
|
|
77
|
+
@justanalytics.span(op="db.query")
|
|
78
|
+
def get_user(user_id: str):
|
|
79
|
+
return db.query(...)
|
|
80
|
+
|
|
81
|
+
# Error capture
|
|
82
|
+
try:
|
|
83
|
+
risky_operation()
|
|
84
|
+
except Exception as e:
|
|
85
|
+
justanalytics.capture_exception(e, tags={"module": "payments"})
|
|
86
|
+
|
|
87
|
+
# Message capture
|
|
88
|
+
justanalytics.capture_message("Deployment complete", level="info")
|
|
89
|
+
|
|
90
|
+
# User context
|
|
91
|
+
justanalytics.set_user(id="user-123", email="alice@example.com")
|
|
92
|
+
|
|
93
|
+
# Tags
|
|
94
|
+
justanalytics.set_tag("feature", "checkout")
|
|
95
|
+
|
|
96
|
+
# Structured logging
|
|
97
|
+
justanalytics.log("info", "User logged in", {"userId": "u123"})
|
|
98
|
+
|
|
99
|
+
# Metrics
|
|
100
|
+
justanalytics.record_metric("custom.queue_size", 42, {"queue": "emails"})
|
|
101
|
+
|
|
102
|
+
# Flush before shutdown
|
|
103
|
+
justanalytics.flush()
|
|
104
|
+
justanalytics.close()
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## Framework Integrations
|
|
108
|
+
|
|
109
|
+
### Django
|
|
110
|
+
|
|
111
|
+
```python
|
|
112
|
+
# settings.py
|
|
113
|
+
MIDDLEWARE = [
|
|
114
|
+
"justanalytics.integrations.django.JustAnalyticsMiddleware",
|
|
115
|
+
# ... other middleware
|
|
116
|
+
]
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### Flask
|
|
120
|
+
|
|
121
|
+
```python
|
|
122
|
+
from flask import Flask
|
|
123
|
+
from justanalytics.integrations.flask import JustAnalyticsMiddleware
|
|
124
|
+
|
|
125
|
+
app = Flask(__name__)
|
|
126
|
+
JustAnalyticsMiddleware(app)
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
### FastAPI
|
|
130
|
+
|
|
131
|
+
```python
|
|
132
|
+
from fastapi import FastAPI
|
|
133
|
+
from justanalytics.integrations.fastapi import JustAnalyticsMiddleware
|
|
134
|
+
|
|
135
|
+
app = FastAPI()
|
|
136
|
+
app.add_middleware(JustAnalyticsMiddleware)
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
### requests library
|
|
140
|
+
|
|
141
|
+
```python
|
|
142
|
+
from justanalytics.integrations.requests import RequestsIntegration
|
|
143
|
+
|
|
144
|
+
integration = RequestsIntegration(service_name="my-service")
|
|
145
|
+
integration.enable()
|
|
146
|
+
# All requests.get/post calls are now traced
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
### Python logging bridge
|
|
150
|
+
|
|
151
|
+
```python
|
|
152
|
+
import logging
|
|
153
|
+
from justanalytics.integrations.logging import JustAnalyticsHandler
|
|
154
|
+
|
|
155
|
+
handler = JustAnalyticsHandler(level=logging.WARNING)
|
|
156
|
+
logging.getLogger().addHandler(handler)
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
## W3C Trace Context
|
|
160
|
+
|
|
161
|
+
```python
|
|
162
|
+
from justanalytics import parse_traceparent, serialize_traceparent
|
|
163
|
+
|
|
164
|
+
# Parse incoming header
|
|
165
|
+
data = parse_traceparent("00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01")
|
|
166
|
+
|
|
167
|
+
# Serialize outgoing header
|
|
168
|
+
header = serialize_traceparent(trace_id, span_id, sampled=True)
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
## License
|
|
172
|
+
|
|
173
|
+
MIT
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
# justanalytics-python
|
|
2
|
+
|
|
3
|
+
Official Python SDK for [JustAnalytics](https://justanalytics.up.railway.app) — end-to-end observability (traces, errors, logs, metrics).
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pip install justanalytics-python
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
With framework extras:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
pip install justanalytics-python[django]
|
|
15
|
+
pip install justanalytics-python[flask]
|
|
16
|
+
pip install justanalytics-python[fastapi]
|
|
17
|
+
pip install justanalytics-python[requests]
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Quick Start
|
|
21
|
+
|
|
22
|
+
```python
|
|
23
|
+
import justanalytics
|
|
24
|
+
|
|
25
|
+
justanalytics.init(
|
|
26
|
+
site_id="site_abc123",
|
|
27
|
+
api_key="ja_sk_your_api_key_here",
|
|
28
|
+
service_name="api-server",
|
|
29
|
+
environment="production",
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
# Traced spans (context manager)
|
|
33
|
+
with justanalytics.start_span("process-order") as span:
|
|
34
|
+
span.set_attribute("order.id", "12345")
|
|
35
|
+
result = process_order()
|
|
36
|
+
|
|
37
|
+
# Decorator
|
|
38
|
+
@justanalytics.span(op="db.query")
|
|
39
|
+
def get_user(user_id: str):
|
|
40
|
+
return db.query(...)
|
|
41
|
+
|
|
42
|
+
# Error capture
|
|
43
|
+
try:
|
|
44
|
+
risky_operation()
|
|
45
|
+
except Exception as e:
|
|
46
|
+
justanalytics.capture_exception(e, tags={"module": "payments"})
|
|
47
|
+
|
|
48
|
+
# Message capture
|
|
49
|
+
justanalytics.capture_message("Deployment complete", level="info")
|
|
50
|
+
|
|
51
|
+
# User context
|
|
52
|
+
justanalytics.set_user(id="user-123", email="alice@example.com")
|
|
53
|
+
|
|
54
|
+
# Tags
|
|
55
|
+
justanalytics.set_tag("feature", "checkout")
|
|
56
|
+
|
|
57
|
+
# Structured logging
|
|
58
|
+
justanalytics.log("info", "User logged in", {"userId": "u123"})
|
|
59
|
+
|
|
60
|
+
# Metrics
|
|
61
|
+
justanalytics.record_metric("custom.queue_size", 42, {"queue": "emails"})
|
|
62
|
+
|
|
63
|
+
# Flush before shutdown
|
|
64
|
+
justanalytics.flush()
|
|
65
|
+
justanalytics.close()
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Framework Integrations
|
|
69
|
+
|
|
70
|
+
### Django
|
|
71
|
+
|
|
72
|
+
```python
|
|
73
|
+
# settings.py
|
|
74
|
+
MIDDLEWARE = [
|
|
75
|
+
"justanalytics.integrations.django.JustAnalyticsMiddleware",
|
|
76
|
+
# ... other middleware
|
|
77
|
+
]
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### Flask
|
|
81
|
+
|
|
82
|
+
```python
|
|
83
|
+
from flask import Flask
|
|
84
|
+
from justanalytics.integrations.flask import JustAnalyticsMiddleware
|
|
85
|
+
|
|
86
|
+
app = Flask(__name__)
|
|
87
|
+
JustAnalyticsMiddleware(app)
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### FastAPI
|
|
91
|
+
|
|
92
|
+
```python
|
|
93
|
+
from fastapi import FastAPI
|
|
94
|
+
from justanalytics.integrations.fastapi import JustAnalyticsMiddleware
|
|
95
|
+
|
|
96
|
+
app = FastAPI()
|
|
97
|
+
app.add_middleware(JustAnalyticsMiddleware)
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### requests library
|
|
101
|
+
|
|
102
|
+
```python
|
|
103
|
+
from justanalytics.integrations.requests import RequestsIntegration
|
|
104
|
+
|
|
105
|
+
integration = RequestsIntegration(service_name="my-service")
|
|
106
|
+
integration.enable()
|
|
107
|
+
# All requests.get/post calls are now traced
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### Python logging bridge
|
|
111
|
+
|
|
112
|
+
```python
|
|
113
|
+
import logging
|
|
114
|
+
from justanalytics.integrations.logging import JustAnalyticsHandler
|
|
115
|
+
|
|
116
|
+
handler = JustAnalyticsHandler(level=logging.WARNING)
|
|
117
|
+
logging.getLogger().addHandler(handler)
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
## W3C Trace Context
|
|
121
|
+
|
|
122
|
+
```python
|
|
123
|
+
from justanalytics import parse_traceparent, serialize_traceparent
|
|
124
|
+
|
|
125
|
+
# Parse incoming header
|
|
126
|
+
data = parse_traceparent("00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01")
|
|
127
|
+
|
|
128
|
+
# Serialize outgoing header
|
|
129
|
+
header = serialize_traceparent(trace_id, span_id, sampled=True)
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
## License
|
|
133
|
+
|
|
134
|
+
MIT
|