tracekit-sdk 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 (36) hide show
  1. tracekit_sdk-0.1.0/.github/workflows/ci.yml +35 -0
  2. tracekit_sdk-0.1.0/.github/workflows/publish.yml +58 -0
  3. tracekit_sdk-0.1.0/.gitignore +36 -0
  4. tracekit_sdk-0.1.0/LICENSE +21 -0
  5. tracekit_sdk-0.1.0/PKG-INFO +266 -0
  6. tracekit_sdk-0.1.0/README.md +243 -0
  7. tracekit_sdk-0.1.0/examples/async_demo.py +61 -0
  8. tracekit_sdk-0.1.0/examples/script_demo.py +57 -0
  9. tracekit_sdk-0.1.0/pyproject.toml +55 -0
  10. tracekit_sdk-0.1.0/src/tracekit/__init__.py +161 -0
  11. tracekit_sdk-0.1.0/src/tracekit/cli.py +144 -0
  12. tracekit_sdk-0.1.0/src/tracekit/client.py +194 -0
  13. tracekit_sdk-0.1.0/src/tracekit/config.py +47 -0
  14. tracekit_sdk-0.1.0/src/tracekit/event.py +190 -0
  15. tracekit_sdk-0.1.0/src/tracekit/filters.py +162 -0
  16. tracekit_sdk-0.1.0/src/tracekit/hooks.py +150 -0
  17. tracekit_sdk-0.1.0/src/tracekit/integrations/__init__.py +5 -0
  18. tracekit_sdk-0.1.0/src/tracekit/integrations/logging.py +75 -0
  19. tracekit_sdk-0.1.0/src/tracekit/py.typed +1 -0
  20. tracekit_sdk-0.1.0/src/tracekit/scope.py +136 -0
  21. tracekit_sdk-0.1.0/src/tracekit/sinks.py +205 -0
  22. tracekit_sdk-0.1.0/src/tracekit/tracing.py +168 -0
  23. tracekit_sdk-0.1.0/src/tracekit/transport.py +155 -0
  24. tracekit_sdk-0.1.0/src/tracekit/viewer.py +200 -0
  25. tracekit_sdk-0.1.0/technicalprd.md +218 -0
  26. tracekit_sdk-0.1.0/tests/__init__.py +1 -0
  27. tracekit_sdk-0.1.0/tests/test_phase1.py +348 -0
  28. tracekit_sdk-0.1.0/tests/test_phase2.py +285 -0
  29. tracekit_sdk-0.1.0/tests/test_phase3.py +341 -0
  30. tracekit_sdk-0.1.0/tests/test_phase4.py +329 -0
  31. tracekit_sdk-0.1.0/tests/test_phase5.py +351 -0
  32. tracekit_sdk-0.1.0/tests/test_phase6.py +346 -0
  33. tracekit_sdk-0.1.0/tests/test_phase7.py +391 -0
  34. tracekit_sdk-0.1.0/tests/test_phase8.py +161 -0
  35. tracekit_sdk-0.1.0/tests/test_smoke.py +15 -0
  36. tracekit_sdk-0.1.0/uv.lock +108 -0
@@ -0,0 +1,35 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+
8
+ permissions:
9
+ contents: read
10
+
11
+ jobs:
12
+ test:
13
+ runs-on: ubuntu-latest
14
+ strategy:
15
+ fail-fast: false
16
+ matrix:
17
+ python-version: ["3.12", "3.13"]
18
+
19
+ steps:
20
+ - name: Checkout repository
21
+ uses: actions/checkout@v7
22
+
23
+ - name: Install uv
24
+ uses: astral-sh/setup-uv@v10.4.0
25
+ with:
26
+ python-version: ${{ matrix.python-version }}
27
+
28
+ - name: Install dependencies
29
+ run: uv sync --locked
30
+
31
+ - name: Run linter
32
+ run: uv run ruff check
33
+
34
+ - name: Run tests
35
+ run: uv run pytest
@@ -0,0 +1,58 @@
1
+ name: Publish to PyPI
2
+
3
+ on:
4
+ release:
5
+ types: [published]
6
+
7
+ jobs:
8
+ build:
9
+ runs-on: ubuntu-latest
10
+ permissions:
11
+ contents: read
12
+
13
+ steps:
14
+ - name: Checkout repository
15
+ uses: actions/checkout@v7
16
+
17
+ - name: Install uv
18
+ uses: astral-sh/setup-uv@v10.4.0
19
+
20
+ - name: Verify release tag matches pyproject.toml version
21
+ run: |
22
+ PROJECT_VERSION=$(python3 -c "import tomllib; print(tomllib.load(open('pyproject.toml', 'rb'))['project']['version'])")
23
+ EXPECTED_TAG="v${PROJECT_VERSION}"
24
+ if [ "${GITHUB_REF_NAME}" != "${EXPECTED_TAG}" ]; then
25
+ echo "Error: Release tag '${GITHUB_REF_NAME}' does not match '${EXPECTED_TAG}' from pyproject.toml."
26
+ exit 1
27
+ fi
28
+ echo "Verified tag ${GITHUB_REF_NAME} matches version ${PROJECT_VERSION}."
29
+
30
+ - name: Build distribution packages
31
+ run: uv build
32
+
33
+ - name: Upload dist artifact
34
+ uses: actions/upload-artifact@v7
35
+ with:
36
+ name: dist
37
+ path: dist/
38
+
39
+ publish:
40
+ needs: build
41
+ runs-on: ubuntu-latest
42
+ environment: pypi
43
+ permissions:
44
+ id-token: write
45
+ contents: read
46
+
47
+ steps:
48
+ - name: Download dist artifact
49
+ uses: actions/download-artifact@v8
50
+ with:
51
+ name: dist
52
+ path: dist/
53
+
54
+ - name: Install uv
55
+ uses: astral-sh/setup-uv@v10.4.0
56
+
57
+ - name: Publish to PyPI
58
+ run: uv publish --trusted-publishing always
@@ -0,0 +1,36 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *.pyo
5
+ *.pyd
6
+ *.egg-info/
7
+ dist/
8
+ build/
9
+ .eggs/
10
+
11
+ # Environments
12
+ .venv/
13
+ .env
14
+ .env.*
15
+ .python-version
16
+
17
+ # Tool caches
18
+ .pytest_cache/
19
+ .ruff_cache/
20
+ .mypy_cache/
21
+ htmlcov/
22
+ .coverage
23
+
24
+ # TraceKit runtime output
25
+ events.jsonl
26
+ *.jsonl
27
+
28
+ # Editor and OS
29
+ .vscode/
30
+ .idea/
31
+ *.swp
32
+ *.swo
33
+ .DS_Store
34
+ Thumbs.db
35
+
36
+ docs.md
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 its-bismay
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,266 @@
1
+ Metadata-Version: 2.5
2
+ Name: tracekit-sdk
3
+ Version: 0.1.0
4
+ Summary: Minimal zero-dependency Python observability SDK
5
+ Project-URL: Homepage, https://github.com/its-bismay/tracekit-sdk
6
+ Project-URL: Repository, https://github.com/its-bismay/tracekit-sdk
7
+ Project-URL: Issues, https://github.com/its-bismay/tracekit-sdk/issues
8
+ Author-email: its-bismay <2023ugee070@nitjsr.ac.in>
9
+ License: MIT
10
+ License-File: LICENSE
11
+ Keywords: error-tracking,monitoring,observability,sdk,tracing
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: 3.13
18
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
19
+ Classifier: Topic :: System :: Monitoring
20
+ Classifier: Typing :: Typed
21
+ Requires-Python: >=3.12
22
+ Description-Content-Type: text/markdown
23
+
24
+ # TraceKit
25
+
26
+ [![PyPI](https://img.shields.io/pypi/v/tracekit-sdk.svg)](https://pypi.org/project/tracekit-sdk/)
27
+ [![CI](https://github.com/its-bismay/tracekit/actions/workflows/ci.yml/badge.svg)](https://github.com/its-bismay/tracekit/actions/workflows/ci.yml)
28
+
29
+ A minimal, zero-dependency Python observability SDK — error tracking and performance timing, inspired by Sentry but far smaller.
30
+
31
+ **Package:** `tracekit-sdk` · **Import:** `tracekit` · **Python:** 3.12+ · **Dependencies:** none (stdlib only)
32
+
33
+ ---
34
+
35
+ ## 30-second quickstart
36
+
37
+ ```bash
38
+ pip install tracekit-sdk # or: uv add tracekit-sdk
39
+ ```
40
+
41
+ ```python
42
+ import tracekit
43
+
44
+ tracekit.init(
45
+ output="console", # "console" | "file:events.jsonl" | "http://..."
46
+ environment="production",
47
+ release="1.0.0",
48
+ )
49
+
50
+ # Manual capture
51
+ tracekit.capture_message("App started", level="info")
52
+
53
+ try:
54
+ result = 1 / 0
55
+ except ZeroDivisionError:
56
+ tracekit.capture_exception() # captures current exception automatically
57
+
58
+ # Performance tracing
59
+ @tracekit.trace
60
+ def fetch_user(user_id: int) -> dict:
61
+ ... # your code here
62
+
63
+ # or with a context manager
64
+ with tracekit.span("db.query"):
65
+ ...
66
+
67
+ tracekit.flush() # ensure all events are delivered before exit
68
+ ```
69
+
70
+ ---
71
+
72
+ ## Output modes
73
+
74
+ ### Console (default)
75
+
76
+ ```
77
+ [TraceKit 2026-11-28 10:15:30] ERROR ZeroDivisionError: division by zero app.py:12 in main
78
+ [TraceKit 2026-11-28 10:15:30] INFO App started
79
+ [TraceKit 2026-11-28 10:15:30] SPAN fetch_user (1.42ms) ok
80
+ ```
81
+
82
+ ### File (JSONL)
83
+
84
+ ```python
85
+ tracekit.init(output="file:events.jsonl")
86
+ ```
87
+
88
+ Each event is one JSON object per line. Use `tracekit tail` to watch it live:
89
+
90
+ ```bash
91
+ tracekit tail events.jsonl
92
+ ```
93
+
94
+ ### HTTP (local viewer or remote ingest)
95
+
96
+ ```python
97
+ tracekit.init(output="http://127.0.0.1:8765/ingest")
98
+ ```
99
+
100
+ Start the built-in viewer:
101
+
102
+ ```bash
103
+ tracekit serve --port 8765
104
+ # Open http://127.0.0.1:8765 in your browser — auto-refreshes every 2 s
105
+ ```
106
+
107
+ ---
108
+
109
+ ## Full API reference
110
+
111
+ ### `tracekit.init(...)`
112
+
113
+ | Parameter | Type | Default | Description |
114
+ |---|---|---|---|
115
+ | `output` | `str` | `"console"` | Delivery target (see Output modes above) |
116
+ | `environment` | `str` | `"production"` | Attached to every event |
117
+ | `release` | `str \| None` | `None` | App version string |
118
+ | `sample_rate` | `float` | `1.0` | Fraction of **span** events to keep (0.0–1.0); errors are always kept |
119
+ | `ignore_errors` | `list` | `[]` | Exception classes or name strings to silently drop |
120
+ | `before_send` | `callable \| None` | `None` | Called with every event dict; return `None` to drop |
121
+ | `debug` | `bool` | `False` | Print internal SDK errors to stderr |
122
+
123
+ ### Automatic exception capture
124
+
125
+ After `init()`, unhandled exceptions are captured automatically:
126
+
127
+ ```python
128
+ # Main thread — via sys.excepthook
129
+ # Worker threads — via threading.excepthook
130
+ # asyncio tasks — call once after creating your loop:
131
+ tracekit.install_asyncio_hook(loop)
132
+ ```
133
+
134
+ ### Scope enrichment
135
+
136
+ ```python
137
+ tracekit.set_user(id="42", email="alice@example.com")
138
+ tracekit.set_tag("region", "eu-west-1")
139
+ tracekit.add_breadcrumb("Payment initiated", category="checkout")
140
+ ```
141
+
142
+ All subsequent events from the same thread / async task carry these fields.
143
+
144
+ ### Performance tracing
145
+
146
+ ```python
147
+ # Decorator — sync and async both supported
148
+ @tracekit.trace
149
+ async def process_order(order_id: int) -> None: ...
150
+
151
+ @tracekit.trace(name="custom.span.name")
152
+ def expensive_query() -> list: ...
153
+
154
+ # Context manager
155
+ with tracekit.span("external.api.call"):
156
+ response = requests.get(url)
157
+ ```
158
+
159
+ ### Filtering and scrubbing
160
+
161
+ ```python
162
+ def drop_health_checks(event: dict) -> dict | None:
163
+ if event.get("message") == "GET /health":
164
+ return None # drop
165
+ return event # keep
166
+
167
+ tracekit.init(
168
+ before_send=drop_health_checks,
169
+ ignore_errors=[ConnectionResetError, "TimeoutError"],
170
+ sample_rate=0.1, # keep 10 % of spans
171
+ )
172
+ ```
173
+
174
+ Fields named `password`, `secret`, `token`, `api_key`, `authorization`, `cookie` etc. are automatically replaced with `[Filtered]` before any event leaves the process.
175
+
176
+ ### Python `logging` integration
177
+
178
+ ```python
179
+ import logging
180
+ from tracekit.integrations.logging import TraceKitHandler
181
+
182
+ tracekit.init(...)
183
+ logging.getLogger().addHandler(TraceKitHandler())
184
+
185
+ logging.error("Something broke") # → error event
186
+ logging.warning("Slow query: 2.3 s") # → breadcrumb
187
+ logging.info("User signed in") # → breadcrumb
188
+ ```
189
+
190
+ ### CLI tools
191
+
192
+ ```bash
193
+ tracekit tail events.jsonl # follow a JSONL file live
194
+ tracekit serve --port 8765 # start the HTML viewer
195
+ ```
196
+
197
+ ---
198
+
199
+ ## Architecture
200
+
201
+ ```
202
+ Your app
203
+ │
204
+ ├─ tracekit.capture_exception / capture_message
205
+ ├─ @tracekit.trace / tracekit.span()
206
+ └─ sys/threading/asyncio hooks
207
+ │
208
+ ▼
209
+ Client
210
+ ├─ apply_filters() ← sample_rate, ignore_errors, scrubbing, before_send
211
+ └─ Transport.enqueue() ← non-blocking, drops if queue full (max 1000)
212
+ │
213
+ ▼ (single daemon thread)
214
+ Sink.emit()
215
+ ├─ ConsoleSink → stderr (ANSI colour)
216
+ ├─ FileSink → JSONL file (open/write/close per event)
217
+ └─ HttpSink → POST batches ≤20 events, retry ×3 with backoff
218
+ ```
219
+
220
+ **Resource limits (PRD §1.10)**
221
+
222
+ | Resource | Limit |
223
+ |---|---|
224
+ | Background threads | 1 daemon thread |
225
+ | Event queue | 1 000 slots (drop when full, never block) |
226
+ | Stack frames per error | 50 (innermost kept) |
227
+ | String field length | 1 000 chars (truncated with `…`) |
228
+ | Breadcrumbs per context | 20 (oldest dropped) |
229
+ | HTTP batch size | 20 events |
230
+ | HTTP retry attempts | 3 × exponential backoff (0.5 → 1.0 → 2.0 s) |
231
+ | Viewer ring buffer | 500 events |
232
+
233
+ ---
234
+
235
+ ## Development
236
+
237
+ ```bash
238
+ git clone https://github.com/yourname/tracekit
239
+ cd tracekit
240
+ uv sync --dev
241
+
242
+ uv run pytest -v # run tests
243
+ uv run ruff check . # lint
244
+ uv build # build wheel → dist/
245
+ ```
246
+
247
+ > **Note:** Phase 6 network tests use loopback TCP — run `uv run pytest -v` outside any sandbox environment that restricts `bind()`/`connect()`.
248
+
249
+ ---
250
+
251
+ ## Releasing
252
+
253
+ Releases are published automatically to PyPI via GitHub Actions Trusted Publishing when a GitHub release is published:
254
+
255
+ 1. Bump `version` in `pyproject.toml`.
256
+ 2. Run `uv lock` to update the lockfile.
257
+ 3. Commit the changes: `git commit -am "Release vX.Y.Z"`.
258
+ 4. Tag the commit: `git tag vX.Y.Z`.
259
+ 5. Push the commit and tag: `git push && git push --tags`.
260
+ 6. Create and publish a GitHub Release for tag `vX.Y.Z`.
261
+
262
+ ---
263
+
264
+ ## License
265
+
266
+ MIT
@@ -0,0 +1,243 @@
1
+ # TraceKit
2
+
3
+ [![PyPI](https://img.shields.io/pypi/v/tracekit-sdk.svg)](https://pypi.org/project/tracekit-sdk/)
4
+ [![CI](https://github.com/its-bismay/tracekit/actions/workflows/ci.yml/badge.svg)](https://github.com/its-bismay/tracekit/actions/workflows/ci.yml)
5
+
6
+ A minimal, zero-dependency Python observability SDK — error tracking and performance timing, inspired by Sentry but far smaller.
7
+
8
+ **Package:** `tracekit-sdk` · **Import:** `tracekit` · **Python:** 3.12+ · **Dependencies:** none (stdlib only)
9
+
10
+ ---
11
+
12
+ ## 30-second quickstart
13
+
14
+ ```bash
15
+ pip install tracekit-sdk # or: uv add tracekit-sdk
16
+ ```
17
+
18
+ ```python
19
+ import tracekit
20
+
21
+ tracekit.init(
22
+ output="console", # "console" | "file:events.jsonl" | "http://..."
23
+ environment="production",
24
+ release="1.0.0",
25
+ )
26
+
27
+ # Manual capture
28
+ tracekit.capture_message("App started", level="info")
29
+
30
+ try:
31
+ result = 1 / 0
32
+ except ZeroDivisionError:
33
+ tracekit.capture_exception() # captures current exception automatically
34
+
35
+ # Performance tracing
36
+ @tracekit.trace
37
+ def fetch_user(user_id: int) -> dict:
38
+ ... # your code here
39
+
40
+ # or with a context manager
41
+ with tracekit.span("db.query"):
42
+ ...
43
+
44
+ tracekit.flush() # ensure all events are delivered before exit
45
+ ```
46
+
47
+ ---
48
+
49
+ ## Output modes
50
+
51
+ ### Console (default)
52
+
53
+ ```
54
+ [TraceKit 2026-11-28 10:15:30] ERROR ZeroDivisionError: division by zero app.py:12 in main
55
+ [TraceKit 2026-11-28 10:15:30] INFO App started
56
+ [TraceKit 2026-11-28 10:15:30] SPAN fetch_user (1.42ms) ok
57
+ ```
58
+
59
+ ### File (JSONL)
60
+
61
+ ```python
62
+ tracekit.init(output="file:events.jsonl")
63
+ ```
64
+
65
+ Each event is one JSON object per line. Use `tracekit tail` to watch it live:
66
+
67
+ ```bash
68
+ tracekit tail events.jsonl
69
+ ```
70
+
71
+ ### HTTP (local viewer or remote ingest)
72
+
73
+ ```python
74
+ tracekit.init(output="http://127.0.0.1:8765/ingest")
75
+ ```
76
+
77
+ Start the built-in viewer:
78
+
79
+ ```bash
80
+ tracekit serve --port 8765
81
+ # Open http://127.0.0.1:8765 in your browser — auto-refreshes every 2 s
82
+ ```
83
+
84
+ ---
85
+
86
+ ## Full API reference
87
+
88
+ ### `tracekit.init(...)`
89
+
90
+ | Parameter | Type | Default | Description |
91
+ |---|---|---|---|
92
+ | `output` | `str` | `"console"` | Delivery target (see Output modes above) |
93
+ | `environment` | `str` | `"production"` | Attached to every event |
94
+ | `release` | `str \| None` | `None` | App version string |
95
+ | `sample_rate` | `float` | `1.0` | Fraction of **span** events to keep (0.0–1.0); errors are always kept |
96
+ | `ignore_errors` | `list` | `[]` | Exception classes or name strings to silently drop |
97
+ | `before_send` | `callable \| None` | `None` | Called with every event dict; return `None` to drop |
98
+ | `debug` | `bool` | `False` | Print internal SDK errors to stderr |
99
+
100
+ ### Automatic exception capture
101
+
102
+ After `init()`, unhandled exceptions are captured automatically:
103
+
104
+ ```python
105
+ # Main thread — via sys.excepthook
106
+ # Worker threads — via threading.excepthook
107
+ # asyncio tasks — call once after creating your loop:
108
+ tracekit.install_asyncio_hook(loop)
109
+ ```
110
+
111
+ ### Scope enrichment
112
+
113
+ ```python
114
+ tracekit.set_user(id="42", email="alice@example.com")
115
+ tracekit.set_tag("region", "eu-west-1")
116
+ tracekit.add_breadcrumb("Payment initiated", category="checkout")
117
+ ```
118
+
119
+ All subsequent events from the same thread / async task carry these fields.
120
+
121
+ ### Performance tracing
122
+
123
+ ```python
124
+ # Decorator — sync and async both supported
125
+ @tracekit.trace
126
+ async def process_order(order_id: int) -> None: ...
127
+
128
+ @tracekit.trace(name="custom.span.name")
129
+ def expensive_query() -> list: ...
130
+
131
+ # Context manager
132
+ with tracekit.span("external.api.call"):
133
+ response = requests.get(url)
134
+ ```
135
+
136
+ ### Filtering and scrubbing
137
+
138
+ ```python
139
+ def drop_health_checks(event: dict) -> dict | None:
140
+ if event.get("message") == "GET /health":
141
+ return None # drop
142
+ return event # keep
143
+
144
+ tracekit.init(
145
+ before_send=drop_health_checks,
146
+ ignore_errors=[ConnectionResetError, "TimeoutError"],
147
+ sample_rate=0.1, # keep 10 % of spans
148
+ )
149
+ ```
150
+
151
+ Fields named `password`, `secret`, `token`, `api_key`, `authorization`, `cookie` etc. are automatically replaced with `[Filtered]` before any event leaves the process.
152
+
153
+ ### Python `logging` integration
154
+
155
+ ```python
156
+ import logging
157
+ from tracekit.integrations.logging import TraceKitHandler
158
+
159
+ tracekit.init(...)
160
+ logging.getLogger().addHandler(TraceKitHandler())
161
+
162
+ logging.error("Something broke") # → error event
163
+ logging.warning("Slow query: 2.3 s") # → breadcrumb
164
+ logging.info("User signed in") # → breadcrumb
165
+ ```
166
+
167
+ ### CLI tools
168
+
169
+ ```bash
170
+ tracekit tail events.jsonl # follow a JSONL file live
171
+ tracekit serve --port 8765 # start the HTML viewer
172
+ ```
173
+
174
+ ---
175
+
176
+ ## Architecture
177
+
178
+ ```
179
+ Your app
180
+ │
181
+ ├─ tracekit.capture_exception / capture_message
182
+ ├─ @tracekit.trace / tracekit.span()
183
+ └─ sys/threading/asyncio hooks
184
+ │
185
+ ▼
186
+ Client
187
+ ├─ apply_filters() ← sample_rate, ignore_errors, scrubbing, before_send
188
+ └─ Transport.enqueue() ← non-blocking, drops if queue full (max 1000)
189
+ │
190
+ ▼ (single daemon thread)
191
+ Sink.emit()
192
+ ├─ ConsoleSink → stderr (ANSI colour)
193
+ ├─ FileSink → JSONL file (open/write/close per event)
194
+ └─ HttpSink → POST batches ≤20 events, retry ×3 with backoff
195
+ ```
196
+
197
+ **Resource limits (PRD §1.10)**
198
+
199
+ | Resource | Limit |
200
+ |---|---|
201
+ | Background threads | 1 daemon thread |
202
+ | Event queue | 1 000 slots (drop when full, never block) |
203
+ | Stack frames per error | 50 (innermost kept) |
204
+ | String field length | 1 000 chars (truncated with `…`) |
205
+ | Breadcrumbs per context | 20 (oldest dropped) |
206
+ | HTTP batch size | 20 events |
207
+ | HTTP retry attempts | 3 × exponential backoff (0.5 → 1.0 → 2.0 s) |
208
+ | Viewer ring buffer | 500 events |
209
+
210
+ ---
211
+
212
+ ## Development
213
+
214
+ ```bash
215
+ git clone https://github.com/yourname/tracekit
216
+ cd tracekit
217
+ uv sync --dev
218
+
219
+ uv run pytest -v # run tests
220
+ uv run ruff check . # lint
221
+ uv build # build wheel → dist/
222
+ ```
223
+
224
+ > **Note:** Phase 6 network tests use loopback TCP — run `uv run pytest -v` outside any sandbox environment that restricts `bind()`/`connect()`.
225
+
226
+ ---
227
+
228
+ ## Releasing
229
+
230
+ Releases are published automatically to PyPI via GitHub Actions Trusted Publishing when a GitHub release is published:
231
+
232
+ 1. Bump `version` in `pyproject.toml`.
233
+ 2. Run `uv lock` to update the lockfile.
234
+ 3. Commit the changes: `git commit -am "Release vX.Y.Z"`.
235
+ 4. Tag the commit: `git tag vX.Y.Z`.
236
+ 5. Push the commit and tag: `git push && git push --tags`.
237
+ 6. Create and publish a GitHub Release for tag `vX.Y.Z`.
238
+
239
+ ---
240
+
241
+ ## License
242
+
243
+ MIT