mermaid-trace 0.5.3.post0__py3-none-any.whl → 0.6.1.post0__py3-none-any.whl
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.
- mermaid_trace/cli.py +30 -2
- mermaid_trace/integrations/__init__.py +5 -0
- mermaid_trace/integrations/langchain.py +447 -0
- mermaid_trace/server.py +406 -0
- mermaid_trace-0.6.1.post0.dist-info/METADATA +275 -0
- {mermaid_trace-0.5.3.post0.dist-info → mermaid_trace-0.6.1.post0.dist-info}/RECORD +9 -7
- mermaid_trace-0.5.3.post0.dist-info/METADATA +0 -232
- {mermaid_trace-0.5.3.post0.dist-info → mermaid_trace-0.6.1.post0.dist-info}/WHEEL +0 -0
- {mermaid_trace-0.5.3.post0.dist-info → mermaid_trace-0.6.1.post0.dist-info}/entry_points.txt +0 -0
- {mermaid_trace-0.5.3.post0.dist-info → mermaid_trace-0.6.1.post0.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
mermaid_trace/__init__.py,sha256=EnAsz6R6ag4dtabdHEg1wdB2k7V1uwmwpYTTC41GQX4,6721
|
|
2
|
-
mermaid_trace/cli.py,sha256=
|
|
2
|
+
mermaid_trace/cli.py,sha256=FCbm9kHf7B74bvkRv_k7stTeG7S7GqNSITmUQW1kJEA,16173
|
|
3
3
|
mermaid_trace/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
|
+
mermaid_trace/server.py,sha256=1nNIS6pNAn3_XCwuoUkKIOsq4GJK5o33QFzv-hh-IJY,15458
|
|
4
5
|
mermaid_trace/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
5
6
|
mermaid_trace/core/config.py,sha256=akTOc3m_bzcZ7e1Qtf1n5Ct9Dj8XPTTcWzATG3-qJHw,1890
|
|
6
7
|
mermaid_trace/core/context.py,sha256=wr-Ys3c6PsYCtbPUsQTrnaciSkP-fofxOewo4oZ27QM,8556
|
|
@@ -10,10 +11,11 @@ mermaid_trace/core/formatter.py,sha256=3KEq236E3GAj_j53MuBM2ndWm7Kx4KeywJWmoY5o5
|
|
|
10
11
|
mermaid_trace/core/utils.py,sha256=FagsMYLZcbmOgKmRo3v9tcRNVIpuc1YEKTAjcRk7keY,3410
|
|
11
12
|
mermaid_trace/handlers/async_handler.py,sha256=WmLcULXHasapt7-W0p_Eltjmwvlq6r6BS6pViuseZ4w,8252
|
|
12
13
|
mermaid_trace/handlers/mermaid_handler.py,sha256=Czar6JYSPTu5L1fQC0I8v1UpToD6aE_r96IkPpRSByw,6142
|
|
13
|
-
mermaid_trace/integrations/__init__.py,sha256=
|
|
14
|
+
mermaid_trace/integrations/__init__.py,sha256=stWAHIL1zv21foaXFXZ_3SLxJ8icN0YFGWOvvHERCDI,269
|
|
14
15
|
mermaid_trace/integrations/fastapi.py,sha256=6LRs4Z508l38ymfj5SP39vOV6OLfYLRkpxyL_SxvudM,9483
|
|
15
|
-
mermaid_trace
|
|
16
|
-
mermaid_trace-0.
|
|
17
|
-
mermaid_trace-0.
|
|
18
|
-
mermaid_trace-0.
|
|
19
|
-
mermaid_trace-0.
|
|
16
|
+
mermaid_trace/integrations/langchain.py,sha256=NAbfxAWybbH94ZKIgPsD6zCCc1j5gVXqUdtYlwVUVRs,14019
|
|
17
|
+
mermaid_trace-0.6.1.post0.dist-info/METADATA,sha256=ZW8sme2ss9f6eylmbMCxVO5Q6869XCPW8p2aSs9uyBM,11099
|
|
18
|
+
mermaid_trace-0.6.1.post0.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
19
|
+
mermaid_trace-0.6.1.post0.dist-info/entry_points.txt,sha256=WS57KT_870v0A4B87QDjQUqJcddMQxbCQyYeczDAX34,57
|
|
20
|
+
mermaid_trace-0.6.1.post0.dist-info/licenses/LICENSE,sha256=BrBog1Etiq9PdWy0SVQNVByIMD9ss4Edz-R0oXt49zA,1062
|
|
21
|
+
mermaid_trace-0.6.1.post0.dist-info/RECORD,,
|
|
@@ -1,232 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: mermaid-trace
|
|
3
|
-
Version: 0.5.3.post0
|
|
4
|
-
Summary: Visualize your Python code execution flow as Mermaid Sequence Diagrams.
|
|
5
|
-
Project-URL: Documentation, https://github.com/xt765/mermaid-trace#readme
|
|
6
|
-
Project-URL: Changelog, https://github.com/xt765/mermaid-trace/blob/main/docs/en/CHANGELOG.md
|
|
7
|
-
Project-URL: Issues, https://github.com/xt765/mermaid-trace/issues
|
|
8
|
-
Project-URL: Source, https://github.com/xt765/mermaid-trace
|
|
9
|
-
Author-email: xt765 <xt765@foxmail.com>
|
|
10
|
-
License: MIT License
|
|
11
|
-
|
|
12
|
-
Copyright (c) 2026 xt765
|
|
13
|
-
|
|
14
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
15
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
16
|
-
in the Software without restriction, including without limitation the rights
|
|
17
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
18
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
19
|
-
furnished to do so, subject to the following conditions:
|
|
20
|
-
|
|
21
|
-
The above copyright notice and this permission notice shall be included in all
|
|
22
|
-
copies or substantial portions of the Software.
|
|
23
|
-
|
|
24
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
25
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
26
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
27
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
28
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
29
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
30
|
-
SOFTWARE.
|
|
31
|
-
License-File: LICENSE
|
|
32
|
-
Keywords: asyncio,logging,mermaid,mermaid-trace,sequence-diagram,trace,visualization
|
|
33
|
-
Classifier: Development Status :: 4 - Beta
|
|
34
|
-
Classifier: Intended Audience :: Developers
|
|
35
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
36
|
-
Classifier: Operating System :: OS Independent
|
|
37
|
-
Classifier: Programming Language :: Python
|
|
38
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
39
|
-
Classifier: Programming Language :: Python :: 3.11
|
|
40
|
-
Classifier: Programming Language :: Python :: 3.12
|
|
41
|
-
Classifier: Programming Language :: Python :: 3.13
|
|
42
|
-
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
43
|
-
Classifier: Programming Language :: Python :: Implementation :: PyPy
|
|
44
|
-
Classifier: Topic :: Software Development :: Debuggers
|
|
45
|
-
Classifier: Topic :: System :: Logging
|
|
46
|
-
Requires-Python: >=3.10
|
|
47
|
-
Requires-Dist: typing-extensions>=4.0.0
|
|
48
|
-
Requires-Dist: watchdog>=2.0.0
|
|
49
|
-
Provides-Extra: all
|
|
50
|
-
Requires-Dist: fastapi>=0.100.0; extra == 'all'
|
|
51
|
-
Provides-Extra: dev
|
|
52
|
-
Requires-Dist: fastapi>=0.100.0; extra == 'dev'
|
|
53
|
-
Requires-Dist: httpx; extra == 'dev'
|
|
54
|
-
Requires-Dist: mypy; extra == 'dev'
|
|
55
|
-
Requires-Dist: pytest; extra == 'dev'
|
|
56
|
-
Requires-Dist: pytest-asyncio; extra == 'dev'
|
|
57
|
-
Requires-Dist: pytest-cov; extra == 'dev'
|
|
58
|
-
Requires-Dist: ruff; extra == 'dev'
|
|
59
|
-
Provides-Extra: fastapi
|
|
60
|
-
Requires-Dist: fastapi>=0.100.0; extra == 'fastapi'
|
|
61
|
-
Description-Content-Type: text/markdown
|
|
62
|
-
|
|
63
|
-
# MermaidTrace: The Python Logger That Draws Diagrams
|
|
64
|
-
|
|
65
|
-
🌐 **Language**: [English](README.md) | [中文](README_CN.md)
|
|
66
|
-
|
|
67
|
-
[](https://pypi.org/project/mermaid-trace/)
|
|
68
|
-
[](https://pypi.org/project/mermaid-trace/)
|
|
69
|
-
[](LICENSE)
|
|
70
|
-
[](https://github.com/xt765/mermaid-trace/actions/workflows/ci.yml)
|
|
71
|
-
[](https://codecov.io/gh/xt765/mermaid-trace)
|
|
72
|
-
|
|
73
|
-
---
|
|
74
|
-
|
|
75
|
-
## 📋 Overview
|
|
76
|
-
|
|
77
|
-
**Stop reading logs. Start watching them.**
|
|
78
|
-
|
|
79
|
-
MermaidTrace is a specialized logging tool that automatically generates [Mermaid JS](https://mermaid.js.org/) sequence diagrams from your code execution. It's perfect for visualizing complex business logic, microservice interactions, or asynchronous flows.
|
|
80
|
-
|
|
81
|
-
---
|
|
82
|
-
|
|
83
|
-
## 📚 Documentation
|
|
84
|
-
|
|
85
|
-
### Core Documentation
|
|
86
|
-
|
|
87
|
-
[User Guide](docs/en/USER_GUIDE.md) · [API Reference](docs/en/API.md) · [Contributing Guidelines](docs/en/CONTRIBUTING.md) · [Changelog](docs/en/CHANGELOG.md) · [License](docs/en/LICENSE)
|
|
88
|
-
|
|
89
|
-
### Code Comment Documents (Chinese)
|
|
90
|
-
|
|
91
|
-
| Category | Links |
|
|
92
|
-
| :--- | :--- |
|
|
93
|
-
| **Core Modules** | [Context](docs/zh/code_comments/src/mermaid_trace/core/context.md) · [Decorators](docs/zh/code_comments/src/mermaid_trace/core/decorators.md) · [Events](docs/zh/code_comments/src/mermaid_trace/core/events.md) · [Formatter](docs/zh/code_comments/src/mermaid_trace/core/formatter.md) |
|
|
94
|
-
| **Handlers** | [Async Handler](docs/zh/code_comments/src/mermaid_trace/handlers/async_handler.md) · [Mermaid Handler](docs/zh/code_comments/src/mermaid_trace/handlers/mermaid_handler.md) |
|
|
95
|
-
| **Integrations** | [FastAPI](docs/zh/code_comments/src/mermaid_trace/integrations/fastapi.md) |
|
|
96
|
-
| **Others** | [init](docs/zh/code_comments/src/mermaid_trace/__init__.md) · [CLI](docs/zh/code_comments/src/mermaid_trace/cli.md) |
|
|
97
|
-
|
|
98
|
-
---
|
|
99
|
-
|
|
100
|
-
## ✨ Key Features
|
|
101
|
-
|
|
102
|
-
- **Decorator-Driven**: Just add `@trace` or `@trace_interaction` to your functions.
|
|
103
|
-
- **Auto-Instrumentation**: Use `@trace_class` to trace a whole class at once.
|
|
104
|
-
- **Third-Party Patching**: Use `patch_object` to trace calls inside external libraries.
|
|
105
|
-
- **Auto-Diagramming**: Generates `.mmd` files that can be viewed in VS Code, GitHub, or Mermaid Live Editor.
|
|
106
|
-
- **Async Support**: Works seamlessly with `asyncio` coroutines.
|
|
107
|
-
- **Context Inference**: Automatically tracks nested calls and infers `source` participants using `contextvars`.
|
|
108
|
-
- **Intelligent Collapsing**: Prevents diagram explosion by collapsing repetitive high-frequency calls and identifying recurring patterns (e.g., loops).
|
|
109
|
-
- **Detailed Exceptions**: Captures full stack traces for errors, displayed in interactive notes.
|
|
110
|
-
- **Simplified Objects**: Automatically cleans up memory addresses (e.g., `<__main__.Obj at 0x...>` -> `<Obj>`) and **groups consecutive identical items** in lists/tuples (e.g., `[<Obj> x 5]`) for cleaner diagrams.
|
|
111
|
-
- **Log Rotation**: Supports `RotatingMermaidFileHandler` for handling long-running systems by splitting logs based on size or time.
|
|
112
|
-
- **FastAPI Integration**: Includes middleware for zero-config HTTP request tracing, supporting distributed tracing via `X-Trace-ID` and `X-Source` headers.
|
|
113
|
-
- **CLI Tool**: Built-in viewer with live-reload to preview diagrams in your browser.
|
|
114
|
-
|
|
115
|
-
---
|
|
116
|
-
|
|
117
|
-
## 🚀 Quick Start
|
|
118
|
-
|
|
119
|
-
### Installation
|
|
120
|
-
|
|
121
|
-
```bash
|
|
122
|
-
pip install mermaid-trace
|
|
123
|
-
```
|
|
124
|
-
|
|
125
|
-
### Basic Usage
|
|
126
|
-
|
|
127
|
-
```python
|
|
128
|
-
from mermaid_trace import trace, configure_flow
|
|
129
|
-
import time
|
|
130
|
-
|
|
131
|
-
# 1. Configure output
|
|
132
|
-
# Recommendation: Store diagrams in a dedicated directory (e.g., mermaid_diagrams/)
|
|
133
|
-
configure_flow("mermaid_diagrams/my_flow.mmd", async_mode=True)
|
|
134
|
-
|
|
135
|
-
# 2. Add decorators
|
|
136
|
-
@trace(source="Client", target="PaymentService", action="Process Payment")
|
|
137
|
-
def process_payment(amount):
|
|
138
|
-
if check_balance(amount):
|
|
139
|
-
return "Success"
|
|
140
|
-
return "Failed"
|
|
141
|
-
|
|
142
|
-
@trace(source="PaymentService", target="Database", action="Check Balance")
|
|
143
|
-
def check_balance(amount):
|
|
144
|
-
return True
|
|
145
|
-
|
|
146
|
-
# 3. Run your code
|
|
147
|
-
process_payment(100)
|
|
148
|
-
```
|
|
149
|
-
|
|
150
|
-
### Configuration
|
|
151
|
-
|
|
152
|
-
You can configure global settings via `configure_flow` or environment variables to control performance and behavior.
|
|
153
|
-
|
|
154
|
-
```python
|
|
155
|
-
configure_flow(
|
|
156
|
-
"flow.mmd",
|
|
157
|
-
overwrite=True, # Overwrite the file on each restart (default: True)
|
|
158
|
-
level=logging.DEBUG,
|
|
159
|
-
queue_size=5000, # Increase buffer for high-throughput
|
|
160
|
-
config_overrides={
|
|
161
|
-
"capture_args": False, # Disable arg capturing for max performance
|
|
162
|
-
"max_string_length": 100 # Increase string truncation limit
|
|
163
|
-
}
|
|
164
|
-
)
|
|
165
|
-
```
|
|
166
|
-
|
|
167
|
-
**Environment Variables:**
|
|
168
|
-
- `MERMAID_TRACE_CAPTURE_ARGS` (true/false)
|
|
169
|
-
- `MERMAID_TRACE_MAX_STRING_LENGTH` (int)
|
|
170
|
-
- `MERMAID_TRACE_MAX_ARG_DEPTH` (int)
|
|
171
|
-
- `MERMAID_TRACE_QUEUE_SIZE` (int)
|
|
172
|
-
|
|
173
|
-
### Nested Calls (Context Inference)
|
|
174
|
-
|
|
175
|
-
You don't need to specify `source` every time. MermaidTrace infers it from the current context.
|
|
176
|
-
|
|
177
|
-
```python
|
|
178
|
-
@trace(source="Client", target="API")
|
|
179
|
-
def main():
|
|
180
|
-
# Inside here, current participant is "API"
|
|
181
|
-
service_call()
|
|
182
|
-
|
|
183
|
-
@trace(target="Service") # source inferred as "API"
|
|
184
|
-
def service_call():
|
|
185
|
-
pass
|
|
186
|
-
```
|
|
187
|
-
|
|
188
|
-
### FastAPI Integration
|
|
189
|
-
|
|
190
|
-
```python
|
|
191
|
-
from fastapi import FastAPI
|
|
192
|
-
from mermaid_trace.integrations.fastapi import MermaidTraceMiddleware
|
|
193
|
-
|
|
194
|
-
app = FastAPI()
|
|
195
|
-
app.add_middleware(MermaidTraceMiddleware, app_name="MyAPI")
|
|
196
|
-
|
|
197
|
-
@app.get("/")
|
|
198
|
-
async def root():
|
|
199
|
-
return {"message": "Hello World"}
|
|
200
|
-
```
|
|
201
|
-
|
|
202
|
-
### CLI Viewer
|
|
203
|
-
|
|
204
|
-
Visualize your generated `.mmd` files instantly:
|
|
205
|
-
|
|
206
|
-
```bash
|
|
207
|
-
mermaid-trace serve my_flow.mmd
|
|
208
|
-
```
|
|
209
|
-
|
|
210
|
-
### Examples
|
|
211
|
-
|
|
212
|
-
Check out the [examples/](examples/) directory for a complete set of demos covering all features:
|
|
213
|
-
- **[Basic Usage](examples/01_basic_usage.py)**: Decorators and class methods.
|
|
214
|
-
- **[Advanced Instrumentation](examples/02_advanced_instrumentation.py)**: `@trace_class` and `patch_object` for third-party libraries.
|
|
215
|
-
- **[Async & Concurrency](examples/03_async_concurrency.py)**: Tracing `asyncio` and concurrent tasks.
|
|
216
|
-
- **[Error Handling](examples/04_error_handling.py)**: Stack trace capture and error rendering.
|
|
217
|
-
- **[Intelligent Collapsing](examples/05_intelligent_collapsing.py)**: Keeping diagrams clean in loops.
|
|
218
|
-
- **[FastAPI Integration](examples/06_fastapi_integration.py)**: Middleware for web apps.
|
|
219
|
-
- **[Full Stack App](examples/07_full_stack_app.py)**: Comprehensive example with FastAPI, SQLAlchemy, and Pydantic.
|
|
220
|
-
- **[Log Rotation](examples/08-log-rotation.py)**: Handling long-running processes with file rotation.
|
|
221
|
-
|
|
222
|
-
---
|
|
223
|
-
|
|
224
|
-
## 🤝 Contributing
|
|
225
|
-
|
|
226
|
-
We welcome contributions! Please see [CONTRIBUTING.md](docs/en/CONTRIBUTING.md) for details.
|
|
227
|
-
|
|
228
|
-
---
|
|
229
|
-
|
|
230
|
-
## 📄 License
|
|
231
|
-
|
|
232
|
-
MIT
|
|
File without changes
|
{mermaid_trace-0.5.3.post0.dist-info → mermaid_trace-0.6.1.post0.dist-info}/entry_points.txt
RENAMED
|
File without changes
|
{mermaid_trace-0.5.3.post0.dist-info → mermaid_trace-0.6.1.post0.dist-info}/licenses/LICENSE
RENAMED
|
File without changes
|