thinkingsdk 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.
Files changed (51) hide show
  1. thinkingsdk-0.1.0/LICENSE +21 -0
  2. thinkingsdk-0.1.0/PKG-INFO +165 -0
  3. thinkingsdk-0.1.0/README.md +124 -0
  4. thinkingsdk-0.1.0/pyproject.toml +93 -0
  5. thinkingsdk-0.1.0/setup.cfg +4 -0
  6. thinkingsdk-0.1.0/tests/test_background_sender.py +370 -0
  7. thinkingsdk-0.1.0/tests/test_client_integration.py +477 -0
  8. thinkingsdk-0.1.0/tests/test_config.py +282 -0
  9. thinkingsdk-0.1.0/tests/test_event_queue.py +198 -0
  10. thinkingsdk-0.1.0/tests/test_instrumentation.py +388 -0
  11. thinkingsdk-0.1.0/tests/test_packaging_and_api.py +105 -0
  12. thinkingsdk-0.1.0/tests/test_sample_data.py +504 -0
  13. thinkingsdk-0.1.0/tests/test_utils.py +267 -0
  14. thinkingsdk-0.1.0/thinkingsdk/__init__.py +443 -0
  15. thinkingsdk-0.1.0/thinkingsdk/_version.py +12 -0
  16. thinkingsdk-0.1.0/thinkingsdk/async_instrumentation.py +366 -0
  17. thinkingsdk-0.1.0/thinkingsdk/auto_instrument.py +115 -0
  18. thinkingsdk-0.1.0/thinkingsdk/background_sender.py +387 -0
  19. thinkingsdk-0.1.0/thinkingsdk/config.py +158 -0
  20. thinkingsdk-0.1.0/thinkingsdk/config_loader.py +316 -0
  21. thinkingsdk-0.1.0/thinkingsdk/context.py +279 -0
  22. thinkingsdk-0.1.0/thinkingsdk/custom_events.py +363 -0
  23. thinkingsdk-0.1.0/thinkingsdk/enhanced_context.py +239 -0
  24. thinkingsdk-0.1.0/thinkingsdk/enhanced_queue.py +80 -0
  25. thinkingsdk-0.1.0/thinkingsdk/event_deduplicator.py +338 -0
  26. thinkingsdk-0.1.0/thinkingsdk/event_queue.py +116 -0
  27. thinkingsdk-0.1.0/thinkingsdk/exception_chain.py +301 -0
  28. thinkingsdk-0.1.0/thinkingsdk/instrumentation.py +1139 -0
  29. thinkingsdk-0.1.0/thinkingsdk/integrations/__init__.py +84 -0
  30. thinkingsdk-0.1.0/thinkingsdk/integrations/console.py +60 -0
  31. thinkingsdk-0.1.0/thinkingsdk/integrations/django.py +328 -0
  32. thinkingsdk-0.1.0/thinkingsdk/integrations/fastapi.py +434 -0
  33. thinkingsdk-0.1.0/thinkingsdk/integrations/flask.py +323 -0
  34. thinkingsdk-0.1.0/thinkingsdk/integrations/logging.py +173 -0
  35. thinkingsdk-0.1.0/thinkingsdk/integrations/middleware_base.py +102 -0
  36. thinkingsdk-0.1.0/thinkingsdk/integrations/psycopg2.py +243 -0
  37. thinkingsdk-0.1.0/thinkingsdk/integrations/pymongo.py +223 -0
  38. thinkingsdk-0.1.0/thinkingsdk/integrations/redis_integration.py +244 -0
  39. thinkingsdk-0.1.0/thinkingsdk/integrations/sqlalchemy.py +219 -0
  40. thinkingsdk-0.1.0/thinkingsdk/integrations/stdlib.py +138 -0
  41. thinkingsdk-0.1.0/thinkingsdk/performance_monitor.py +314 -0
  42. thinkingsdk-0.1.0/thinkingsdk/pii_scrubber.py +250 -0
  43. thinkingsdk-0.1.0/thinkingsdk/strategic_sampling.py +357 -0
  44. thinkingsdk-0.1.0/thinkingsdk/thinkingsdk.yaml +119 -0
  45. thinkingsdk-0.1.0/thinkingsdk/validate.py +487 -0
  46. thinkingsdk-0.1.0/thinkingsdk.egg-info/PKG-INFO +165 -0
  47. thinkingsdk-0.1.0/thinkingsdk.egg-info/SOURCES.txt +49 -0
  48. thinkingsdk-0.1.0/thinkingsdk.egg-info/dependency_links.txt +1 -0
  49. thinkingsdk-0.1.0/thinkingsdk.egg-info/entry_points.txt +2 -0
  50. thinkingsdk-0.1.0/thinkingsdk.egg-info/requires.txt +17 -0
  51. thinkingsdk-0.1.0/thinkingsdk.egg-info/top_level.txt +1 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 srikar appalaraju
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,165 @@
1
+ Metadata-Version: 2.4
2
+ Name: thinkingsdk
3
+ Version: 0.1.0
4
+ Summary: AI crash debugging for Python in production
5
+ Author-email: srikar appalaraju <srikar2097@gmail.com>
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/srikarappal/thinkingsdk-python
8
+ Project-URL: Website, https://thinkingsdk.ai
9
+ Project-URL: Issues, https://github.com/srikarappal/thinkingsdk-python/issues
10
+ Keywords: crash reporting,error tracking,exceptions,debugging,observability,monitoring,AI,production
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Topic :: Software Development :: Debuggers
14
+ Classifier: Topic :: System :: Monitoring
15
+ Classifier: License :: OSI Approved :: MIT License
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.7
18
+ Classifier: Programming Language :: Python :: 3.8
19
+ Classifier: Programming Language :: Python :: 3.9
20
+ Classifier: Programming Language :: Python :: 3.10
21
+ Classifier: Programming Language :: Python :: 3.11
22
+ Classifier: Programming Language :: Python :: 3.12
23
+ Classifier: Operating System :: OS Independent
24
+ Requires-Python: >=3.7
25
+ Description-Content-Type: text/markdown
26
+ License-File: LICENSE
27
+ Requires-Dist: requests>=2.25.0
28
+ Requires-Dist: pyyaml>=5.4
29
+ Requires-Dist: contextvars>=2.4; python_version < "3.7"
30
+ Provides-Extra: dev
31
+ Requires-Dist: pytest>=7.0; extra == "dev"
32
+ Requires-Dist: pytest-asyncio>=0.21; extra == "dev"
33
+ Requires-Dist: pytest-cov>=4.0; extra == "dev"
34
+ Requires-Dist: black>=22.0; extra == "dev"
35
+ Requires-Dist: flake8>=5.0; extra == "dev"
36
+ Requires-Dist: mypy>=1.0; extra == "dev"
37
+ Requires-Dist: psutil>=5.9; extra == "dev"
38
+ Provides-Extra: performance
39
+ Requires-Dist: psutil>=5.9; extra == "performance"
40
+ Dynamic: license-file
41
+
42
+ # ThinkingSDK
43
+
44
+ AI crash debugging for Python in production. One line catches every uncaught exception in your live app, ships it to ThinkingSDK's analysis service, and gives you back the root cause and a concrete fix, not just another stack trace.
45
+
46
+ [![PyPI version](https://badge.fury.io/py/thinkingsdk.svg)](https://pypi.org/project/thinkingsdk/)
47
+ [![Python](https://img.shields.io/badge/python-3.7%2B-blue)](https://www.python.org/downloads/)
48
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
49
+
50
+ ```bash
51
+ pip install thinkingsdk
52
+ ```
53
+
54
+ ```python
55
+ import thinkingsdk as thinking
56
+
57
+ thinking.start(api_key="sk_live_...") # the whole integration
58
+ ```
59
+
60
+ That is it. Deploy. When your app throws an unhandled exception, in a request handler, a worker thread, or a background job, ThinkingSDK captures it with full context, analyzes it, and shows you the diagnosis in your dashboard at [thinkingsdk.ai](https://thinkingsdk.ai). Get your project key there.
61
+
62
+ ## What you get for every crash
63
+
64
+ - **Root cause in plain language.** Why it happened, grounded in the actual stack and the local variables at each frame, not just where it threw.
65
+ - **A concrete fix.** The specific code change to make, not a generic "handle the exception."
66
+ - **Full context.** Stack trace, locals per frame, and the execution path into the failure.
67
+ - **Smart grouping.** Repeated crashes are deduplicated, so one real bug is one issue, not a thousand alerts.
68
+
69
+ ## How it works
70
+
71
+ ThinkingSDK installs exception hooks at startup:
72
+
73
+ - `sys.excepthook` for the main thread and `threading.excepthook` for worker threads, so no uncaught exception escapes unseen.
74
+ - Captured events are sent asynchronously in batches on a background sender, off your request path, so reporting a crash never blocks or slows the failing request.
75
+ - Only runtime event data leaves your process. Your source code is never uploaded.
76
+
77
+ Deeper call tracing and performance capture are available via config, off by default to keep overhead near zero.
78
+
79
+ ## Performance
80
+
81
+ ThinkingSDK is built to stay off your application's hot path. The capture path is cheap and bounded; the network and the AI analysis happen elsewhere. What makes that true, in the client itself:
82
+
83
+ - **Background daemon thread**, sends off your request path; capture just enqueues in microseconds.
84
+ - **Bounded ring buffer** (`deque(maxlen=…)`), drops oldest when full instead of back-pressuring, so a flood can't stall your app or grow memory.
85
+ - **Batching** (50 events, or ~2s), flat network cost, not one request per event.
86
+ - **Circuit breaker**, pauses sending after repeated backend failures, so a down service can't become retry pressure on you.
87
+ - **Bounded retries + exponential backoff + hard request timeout**, all confined to the background thread.
88
+ - **Priority sampling**, exceptions/errors always captured, routine events sampled by rate.
89
+ - **Call-stack dedup**, a hot error loop collapses to one analyzed issue, not thousands of sends.
90
+ - **Idle-until-throw hooks**, `excepthook` adds no per-call/per-line cost on the happy path; deeper tracing is opt-in.
91
+
92
+ ## Framework and library integrations
93
+
94
+ Awareness for the stack you already run:
95
+
96
+ - **Web:** FastAPI, Flask, Django
97
+ - **Data:** SQLAlchemy, psycopg2, PyMongo, Redis
98
+ - **Standard library:** logging
99
+
100
+ ## Production example (FastAPI)
101
+
102
+ ```python
103
+ import thinkingsdk as thinking
104
+ from fastapi import FastAPI
105
+
106
+ thinking.start(api_key="sk_live_...")
107
+
108
+ app = FastAPI()
109
+
110
+ @app.get("/orders/{order_id}")
111
+ def get_order(order_id: str):
112
+ # If this raises in production, ThinkingSDK captures it with the request
113
+ # context and returns an AI root cause plus a fix in your dashboard.
114
+ return load_order(order_id)
115
+ ```
116
+
117
+ When `load_order` blows up on a malformed id, you do not get a bare `KeyError` buried in your logs. You get:
118
+
119
+ ```
120
+ KeyError in get_order -> load_order at order_store.py:42
121
+
122
+ Root cause: load_order indexes self._orders[order_id] directly, but order_id
123
+ arrives from the URL unvalidated, so any unknown id raises KeyError instead of
124
+ returning a 404.
125
+
126
+ Suggested fix:
127
+ order = self._orders.get(order_id)
128
+ if order is None:
129
+ raise HTTPException(status_code=404, detail="order not found")
130
+ return order
131
+ ```
132
+
133
+ ## Configuration
134
+
135
+ `thinking.start()` accepts:
136
+
137
+ - `api_key`: your project key from [thinkingsdk.ai](https://thinkingsdk.ai)
138
+ - `server_url`: defaults to the hosted service (`https://api.thinkingsdk.ai`); point it at your own deployment to self host
139
+ - `config`: a dict of tuning options
140
+
141
+ ```python
142
+ thinking.start(
143
+ api_key="sk_live_...",
144
+ config={
145
+ "capture_exceptions": True,
146
+ "capture_performance": False,
147
+ "sample_rate": 1.0, # e.g. 0.1 to sample 10% on a high traffic service
148
+ },
149
+ )
150
+ ```
151
+
152
+ ### Environment variables
153
+
154
+ ```bash
155
+ export THINKINGSDK_API_KEY=sk_live_...
156
+ export THINKINGSDK_SERVER_URL=https://api.thinkingsdk.ai # optional override
157
+ ```
158
+
159
+ ## Self hosting
160
+
161
+ The analysis service (the AI engine and dashboard) runs as a separate component. To use your own instead of the hosted service, point `server_url` at your deployment. See [thinkingsdk.ai](https://thinkingsdk.ai) for details.
162
+
163
+ ## License
164
+
165
+ MIT
@@ -0,0 +1,124 @@
1
+ # ThinkingSDK
2
+
3
+ AI crash debugging for Python in production. One line catches every uncaught exception in your live app, ships it to ThinkingSDK's analysis service, and gives you back the root cause and a concrete fix, not just another stack trace.
4
+
5
+ [![PyPI version](https://badge.fury.io/py/thinkingsdk.svg)](https://pypi.org/project/thinkingsdk/)
6
+ [![Python](https://img.shields.io/badge/python-3.7%2B-blue)](https://www.python.org/downloads/)
7
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
8
+
9
+ ```bash
10
+ pip install thinkingsdk
11
+ ```
12
+
13
+ ```python
14
+ import thinkingsdk as thinking
15
+
16
+ thinking.start(api_key="sk_live_...") # the whole integration
17
+ ```
18
+
19
+ That is it. Deploy. When your app throws an unhandled exception, in a request handler, a worker thread, or a background job, ThinkingSDK captures it with full context, analyzes it, and shows you the diagnosis in your dashboard at [thinkingsdk.ai](https://thinkingsdk.ai). Get your project key there.
20
+
21
+ ## What you get for every crash
22
+
23
+ - **Root cause in plain language.** Why it happened, grounded in the actual stack and the local variables at each frame, not just where it threw.
24
+ - **A concrete fix.** The specific code change to make, not a generic "handle the exception."
25
+ - **Full context.** Stack trace, locals per frame, and the execution path into the failure.
26
+ - **Smart grouping.** Repeated crashes are deduplicated, so one real bug is one issue, not a thousand alerts.
27
+
28
+ ## How it works
29
+
30
+ ThinkingSDK installs exception hooks at startup:
31
+
32
+ - `sys.excepthook` for the main thread and `threading.excepthook` for worker threads, so no uncaught exception escapes unseen.
33
+ - Captured events are sent asynchronously in batches on a background sender, off your request path, so reporting a crash never blocks or slows the failing request.
34
+ - Only runtime event data leaves your process. Your source code is never uploaded.
35
+
36
+ Deeper call tracing and performance capture are available via config, off by default to keep overhead near zero.
37
+
38
+ ## Performance
39
+
40
+ ThinkingSDK is built to stay off your application's hot path. The capture path is cheap and bounded; the network and the AI analysis happen elsewhere. What makes that true, in the client itself:
41
+
42
+ - **Background daemon thread**, sends off your request path; capture just enqueues in microseconds.
43
+ - **Bounded ring buffer** (`deque(maxlen=…)`), drops oldest when full instead of back-pressuring, so a flood can't stall your app or grow memory.
44
+ - **Batching** (50 events, or ~2s), flat network cost, not one request per event.
45
+ - **Circuit breaker**, pauses sending after repeated backend failures, so a down service can't become retry pressure on you.
46
+ - **Bounded retries + exponential backoff + hard request timeout**, all confined to the background thread.
47
+ - **Priority sampling**, exceptions/errors always captured, routine events sampled by rate.
48
+ - **Call-stack dedup**, a hot error loop collapses to one analyzed issue, not thousands of sends.
49
+ - **Idle-until-throw hooks**, `excepthook` adds no per-call/per-line cost on the happy path; deeper tracing is opt-in.
50
+
51
+ ## Framework and library integrations
52
+
53
+ Awareness for the stack you already run:
54
+
55
+ - **Web:** FastAPI, Flask, Django
56
+ - **Data:** SQLAlchemy, psycopg2, PyMongo, Redis
57
+ - **Standard library:** logging
58
+
59
+ ## Production example (FastAPI)
60
+
61
+ ```python
62
+ import thinkingsdk as thinking
63
+ from fastapi import FastAPI
64
+
65
+ thinking.start(api_key="sk_live_...")
66
+
67
+ app = FastAPI()
68
+
69
+ @app.get("/orders/{order_id}")
70
+ def get_order(order_id: str):
71
+ # If this raises in production, ThinkingSDK captures it with the request
72
+ # context and returns an AI root cause plus a fix in your dashboard.
73
+ return load_order(order_id)
74
+ ```
75
+
76
+ When `load_order` blows up on a malformed id, you do not get a bare `KeyError` buried in your logs. You get:
77
+
78
+ ```
79
+ KeyError in get_order -> load_order at order_store.py:42
80
+
81
+ Root cause: load_order indexes self._orders[order_id] directly, but order_id
82
+ arrives from the URL unvalidated, so any unknown id raises KeyError instead of
83
+ returning a 404.
84
+
85
+ Suggested fix:
86
+ order = self._orders.get(order_id)
87
+ if order is None:
88
+ raise HTTPException(status_code=404, detail="order not found")
89
+ return order
90
+ ```
91
+
92
+ ## Configuration
93
+
94
+ `thinking.start()` accepts:
95
+
96
+ - `api_key`: your project key from [thinkingsdk.ai](https://thinkingsdk.ai)
97
+ - `server_url`: defaults to the hosted service (`https://api.thinkingsdk.ai`); point it at your own deployment to self host
98
+ - `config`: a dict of tuning options
99
+
100
+ ```python
101
+ thinking.start(
102
+ api_key="sk_live_...",
103
+ config={
104
+ "capture_exceptions": True,
105
+ "capture_performance": False,
106
+ "sample_rate": 1.0, # e.g. 0.1 to sample 10% on a high traffic service
107
+ },
108
+ )
109
+ ```
110
+
111
+ ### Environment variables
112
+
113
+ ```bash
114
+ export THINKINGSDK_API_KEY=sk_live_...
115
+ export THINKINGSDK_SERVER_URL=https://api.thinkingsdk.ai # optional override
116
+ ```
117
+
118
+ ## Self hosting
119
+
120
+ The analysis service (the AI engine and dashboard) runs as a separate component. To use your own instead of the hosted service, point `server_url` at your deployment. See [thinkingsdk.ai](https://thinkingsdk.ai) for details.
121
+
122
+ ## License
123
+
124
+ MIT
@@ -0,0 +1,93 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "thinkingsdk"
7
+ version = "0.1.0"
8
+ description = "AI crash debugging for Python in production"
9
+ readme = "README.md"
10
+ authors = [
11
+ {name = "srikar appalaraju", email = "srikar2097@gmail.com"}
12
+ ]
13
+ license = {text = "MIT"}
14
+ classifiers = [
15
+ "Development Status :: 4 - Beta",
16
+ "Intended Audience :: Developers",
17
+ "Topic :: Software Development :: Debuggers",
18
+ "Topic :: System :: Monitoring",
19
+ "License :: OSI Approved :: MIT License",
20
+ "Programming Language :: Python :: 3",
21
+ "Programming Language :: Python :: 3.7",
22
+ "Programming Language :: Python :: 3.8",
23
+ "Programming Language :: Python :: 3.9",
24
+ "Programming Language :: Python :: 3.10",
25
+ "Programming Language :: Python :: 3.11",
26
+ "Programming Language :: Python :: 3.12",
27
+ "Operating System :: OS Independent",
28
+ ]
29
+ keywords = ["crash reporting", "error tracking", "exceptions", "debugging", "observability", "monitoring", "AI", "production"]
30
+ requires-python = ">=3.7"
31
+ dependencies = [
32
+ "requests>=2.25.0",
33
+ "pyyaml>=5.4",
34
+ "contextvars>=2.4;python_version<'3.7'",
35
+ ]
36
+
37
+ [project.optional-dependencies]
38
+ dev = [
39
+ "pytest>=7.0",
40
+ "pytest-asyncio>=0.21",
41
+ "pytest-cov>=4.0",
42
+ "black>=22.0",
43
+ "flake8>=5.0",
44
+ "mypy>=1.0",
45
+ "psutil>=5.9",
46
+ ]
47
+ performance = [
48
+ "psutil>=5.9",
49
+ ]
50
+
51
+ [project.urls]
52
+ Homepage = "https://github.com/srikarappal/thinkingsdk-python"
53
+ Website = "https://thinkingsdk.ai"
54
+ Issues = "https://github.com/srikarappal/thinkingsdk-python/issues"
55
+
56
+ [project.scripts]
57
+ thinkingsdk = "thinkingsdk.validate:main"
58
+
59
+ [tool.setuptools.packages.find]
60
+ include = ["thinkingsdk*"]
61
+ namespaces = false
62
+
63
+ [tool.setuptools.package-data]
64
+ thinkingsdk = ["*.yaml", "*.yml"]
65
+
66
+ [tool.black]
67
+ line-length = 100
68
+ target-version = ['py37', 'py38', 'py39', 'py310', 'py311']
69
+
70
+ [tool.mypy]
71
+ python_version = "3.7"
72
+ warn_return_any = true
73
+ warn_unused_configs = true
74
+ disallow_untyped_defs = true
75
+
76
+ [tool.pytest.ini_options]
77
+ testpaths = ["tests"]
78
+ python_files = ["test_*.py"]
79
+ python_functions = ["test_*"]
80
+ addopts = "-v --tb=short"
81
+
82
+ [tool.coverage.run]
83
+ source = ["thinkingsdk"]
84
+ omit = ["*/tests/*", "*/test_*.py"]
85
+
86
+ [tool.coverage.report]
87
+ exclude_lines = [
88
+ "pragma: no cover",
89
+ "def __repr__",
90
+ "if __name__ == .__main__.:",
91
+ "raise AssertionError",
92
+ "raise NotImplementedError",
93
+ ]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+