@appland/appmap 3.133.0 → 3.134.0

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 (83) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/built/cmds/index/index.js +3 -3
  3. package/built/cmds/index/index.js.map +1 -1
  4. package/built/cmds/index/rpc.js +18 -7
  5. package/built/cmds/index/rpc.js.map +1 -1
  6. package/built/cmds/navie/help.js +122 -0
  7. package/built/cmds/navie/help.js.map +1 -0
  8. package/built/docs/CLA Instructions.pdf +0 -0
  9. package/built/docs/Code of Conduct for Contributors.pdf +0 -0
  10. package/built/docs/analysis/rules-reference.html +27 -0
  11. package/built/docs/appmap-overview.md +54 -0
  12. package/built/docs/community.md +27 -0
  13. package/built/docs/diagrams/dependency-map.md +63 -0
  14. package/built/docs/diagrams/flamegraph.md +91 -0
  15. package/built/docs/diagrams/how-it-works.md +60 -0
  16. package/built/docs/diagrams/index.md +20 -0
  17. package/built/docs/diagrams/sequence-diagram.md +75 -0
  18. package/built/docs/diagrams/trace-view.md +55 -0
  19. package/built/docs/guides/configuring-analysis.md +157 -0
  20. package/built/docs/guides/handling-large-appmaps.md +43 -0
  21. package/built/docs/guides/index.md +17 -0
  22. package/built/docs/guides/openapi.md +104 -0
  23. package/built/docs/guides/reading-sql-in-appmaps.md +67 -0
  24. package/built/docs/guides/refine-appmaps.md +186 -0
  25. package/built/docs/guides/reverse-engineering.md +375 -0
  26. package/built/docs/guides/runtime-code-review.md +108 -0
  27. package/built/docs/integrations/atlassian-compass.md +24 -0
  28. package/built/docs/integrations/atlassian-confluence.md +50 -0
  29. package/built/docs/integrations/docker.md +108 -0
  30. package/built/docs/integrations/github-actions.md +24 -0
  31. package/built/docs/integrations/index.md +17 -0
  32. package/built/docs/integrations/plantuml.md +65 -0
  33. package/built/docs/integrations/postman.md +29 -0
  34. package/built/docs/integrations/readme.md +38 -0
  35. package/built/docs/integrations/smartbear-swaggerhub.md +125 -0
  36. package/built/docs/navie/bring-your-own-key.md +98 -0
  37. package/built/docs/navie/demo.md +49 -0
  38. package/built/docs/navie/how-navie-works.md +26 -0
  39. package/built/docs/navie/how-to-use-navie.md +152 -0
  40. package/built/docs/navie/index.md +20 -0
  41. package/built/docs/reference/analysis-labels.md +48 -0
  42. package/built/docs/reference/analysis-rules.md +60 -0
  43. package/built/docs/reference/appmap-agent-js.md +215 -0
  44. package/built/docs/reference/appmap-client-cli.md +527 -0
  45. package/built/docs/reference/appmap-gradle-plugin.md +140 -0
  46. package/built/docs/reference/appmap-java.md +310 -0
  47. package/built/docs/reference/appmap-maven-plugin.md +163 -0
  48. package/built/docs/reference/appmap-node.md +185 -0
  49. package/built/docs/reference/appmap-python.md +395 -0
  50. package/built/docs/reference/appmap-ruby.md +514 -0
  51. package/built/docs/reference/github-action.md +164 -0
  52. package/built/docs/reference/index.md +23 -0
  53. package/built/docs/reference/jetbrains.md +119 -0
  54. package/built/docs/reference/license-key-install.md +73 -0
  55. package/built/docs/reference/remote-recording-api.md +97 -0
  56. package/built/docs/reference/uninstalling-appmap.md +109 -0
  57. package/built/docs/reference/vscode.md +125 -0
  58. package/built/docs/setup-appmap-in-ci/example-projects.md +20 -0
  59. package/built/docs/setup-appmap-in-ci/how-it-works.md +42 -0
  60. package/built/docs/setup-appmap-in-ci/in-circleci.md +422 -0
  61. package/built/docs/setup-appmap-in-ci/in-github-actions.md +176 -0
  62. package/built/docs/setup-appmap-in-ci/index.md +21 -0
  63. package/built/docs/setup-appmap-in-ci/matrix-builds.md +224 -0
  64. package/built/docs/setup-appmap-in-ci/troubleshooting.md +70 -0
  65. package/built/docs/setup-appmap-in-your-code-editor/add-appmap-to-your-code-editor.md +43 -0
  66. package/built/docs/setup-appmap-in-your-code-editor/appmap-analysis.md +76 -0
  67. package/built/docs/setup-appmap-in-your-code-editor/generate-appmaps-from-tests.md +92 -0
  68. package/built/docs/setup-appmap-in-your-code-editor/generate-appmaps-with-remote-recording.md +111 -0
  69. package/built/docs/setup-appmap-in-your-code-editor/generate-appmaps-with-request-recording.md +79 -0
  70. package/built/docs/setup-appmap-in-your-code-editor/how-appmap-works.md +165 -0
  71. package/built/docs/setup-appmap-in-your-code-editor/index.md +23 -0
  72. package/built/docs/setup-appmap-in-your-code-editor/navigating-appmaps.md +58 -0
  73. package/built/docs/setup-appmap-in-your-code-editor/navigating-code-objects.md +66 -0
  74. package/built/docs/unused_for_now_index.html +11 -0
  75. package/built/rpc/appmap/stats.js +1 -1
  76. package/built/rpc/appmap/stats.js.map +1 -1
  77. package/built/rpc/explain/explain.js +6 -1
  78. package/built/rpc/explain/explain.js.map +1 -1
  79. package/built/rpc/explain/navie/navie-local.js +6 -2
  80. package/built/rpc/explain/navie/navie-local.js.map +1 -1
  81. package/built/rpc/explain/navie/navie-remote.js +5 -1
  82. package/built/rpc/explain/navie/navie-remote.js.map +1 -1
  83. package/package.json +3 -3
@@ -0,0 +1,395 @@
1
+ ---
2
+ layout: docs
3
+ title: Docs - Reference
4
+ toc: true
5
+ reference: true
6
+ name: AppMap Agent for Python
7
+ step: 4
8
+ ---
9
+
10
+ # AppMap Agent for Python
11
+ - [About](#about)
12
+ - [Supported versions](#supported-versions)
13
+ - [Installation](#installation)
14
+ - [Configuration](#configuration)
15
+ - [Tests recording](#tests-recording)
16
+ - [pytest](#pytest)
17
+ - [unittest](#unittest)
18
+ - [Request recording](#request-recording)
19
+ - [Remote recording](#remote-recording)
20
+ - [Code Block Recording](#code-block-recording)
21
+ - [Web framework support](#web-framework-support)
22
+ - [Django](#django)
23
+ - [Flask](#flask)
24
+ - [FastAPI](#fastapi)
25
+ - [uvicorn](#uvicorn)
26
+ - [Other ASGI servers](#other-asgi-servers)
27
+ - [Decorators](#decorators)
28
+ - [@appmap.labels](#appmaplabels)
29
+ - [@appmap.noappmap](#appmapnoappmap)
30
+ - [Environment variables](#environment-variables)
31
+ - [General configuration](#general-configuration)
32
+ - [Controlling recording](#controlling-recording)
33
+ - [Disabling recording methods](#disabling-recording-methods)
34
+ - [Enabling recording methods](#enabling-recording-methods)
35
+ - [GitHub repository](#github-repository)
36
+
37
+ ## About
38
+
39
+ `appmap` is a Python package for recording [AppMaps](https://github.com/getappmap/appmap) of your code.
40
+
41
+ {% include docs/what_is_appmap_snippet.md %}
42
+
43
+ ### Supported versions
44
+
45
+ {% include docs/python_support_matrix.html %}
46
+
47
+ Support for new versions is added frequently, please check back regularly for updates.
48
+
49
+ ## Installation
50
+
51
+ If your project uses `pip` for dependency management, add the `appmap` package to the requirements
52
+ file or install it directly with
53
+ ```shell
54
+ pip install appmap
55
+ ```
56
+ {: .example-code}
57
+
58
+ For projects that use `poetry` , add the `appmap` package to `pyproject.toml`.
59
+ ```
60
+ poetry add --group=dev appmap
61
+ ```
62
+ {: .example-code}
63
+
64
+ `pipenv` is also supported:
65
+ ```
66
+ pipenv install --dev appmap
67
+ ```
68
+ {: .example-code}
69
+
70
+ {% include docs/install_appmap_extension.md %}
71
+
72
+ ## Configuration
73
+
74
+ Add your modules as `path` entries in `appmap.yml`, and external packages
75
+ (distributions) as `dist`:
76
+
77
+ ```
78
+ name: my_python_app
79
+ packages:
80
+ - path: app.mod1
81
+ shallow: true
82
+ - path: app.mod2
83
+ exclude:
84
+ - MyClass
85
+ - MyOtherClass.my_instance_method
86
+ - MyOtherClass.my_class_method
87
+ # You can record dependency packages, such as Django.
88
+ # We don't recommend recording Django by default though, your AppMaps will be quite large
89
+ # and mostly about Django itself, not your own code.
90
+ #- dist: Django
91
+ # exclude:
92
+ # - django.db
93
+ ```
94
+
95
+ Note that an `exclude` is resolved relative to the associated path. So, for example, this
96
+ configuration excludes `app.mod2.MyClass`.
97
+
98
+ For external [distribution packages](https://packaging.python.org/glossary/#term-Distribution-Package)
99
+ use the `dist` specifier; the names are looked up in the
100
+ [database of installed Python distributions](https://www.python.org/dev/peps/pep-0376/).
101
+ This is generally the same package name as you'd give to `pip install` or put
102
+ in `pyproject.toml`. You can additionally use `path` and `exclude` on `dist`
103
+ entries to limit the capture to specific patterns.
104
+
105
+ By default, shallow capture is enabled on `dist` packages, supressing tracking
106
+ of most internal execution flow. This allows you to capture the interaction without
107
+ getting bogged down with detail. To see these details, set `shallow: false`.
108
+ You can also use `shallow: true` on `path` entries.
109
+
110
+ ## Tests recording
111
+
112
+ `appmap` supports recording [pytest](https://pytest.org) and
113
+ [unittest](https://docs.python.org/3/library/unittest.html) test cases.
114
+
115
+ ### pytest
116
+
117
+ `appmap` is a `pytest` plugin. When it's installed in a project that uses
118
+ `pytest`, it will be available to generate AppMaps.
119
+
120
+ ```
121
+ root@e9987eaa93c8:/src/appmap/test/data/pytest# pip show appmap
122
+ Name: appmap
123
+ Version: 0.0.0
124
+ Summary: Create AppMap files by recording a Python application.
125
+ Home-page: None
126
+ Author: Alan Potter
127
+ Author-email: alan@app.land
128
+ License: None
129
+ Location: /usr/local/lib/python3.9/site-packages
130
+ Requires: orjson, PyYAML, inflection
131
+ Required-by:
132
+ root@e9987eaa93c8:/src/appmap/test/data/pytest# APPMAP_LOG_LEVEL=info pytest -svv
133
+ [2021-02-10 11:37:59,345] INFO root: appmap enabled: True
134
+ [2021-02-10 11:37:59,350] INFO appmap._implementation.configuration: ConfigFilter, includes {'simple'}
135
+ [2021-02-10 11:37:59,350] INFO appmap._implementation.configuration: ConfigFilter, excludes set()
136
+ ===================================================================== test session starts =====================================================================
137
+ platform linux -- Python 3.9.1, pytest-6.2.2, py-1.10.0, pluggy-0.13.1 -- /usr/local/bin/python
138
+ cachedir: .pytest_cache
139
+ rootdir: /src, configfile: pytest.ini
140
+ plugins: appmap-0.0.0
141
+ collected 1 item
142
+
143
+ test_simple.py::test_hello_world [2021-02-10 11:37:59,482] INFO appmap.pytest: starting recording /tmp/pytest/test_hello_world.appmap.json
144
+ [2021-02-10 11:37:59,484] INFO appmap._implementation.configuration: included class simple.Simple
145
+ [2021-02-10 11:37:59,484] INFO appmap._implementation.configuration: included function simple.Simple.hello
146
+ [2021-02-10 11:37:59,489] INFO appmap._implementation.configuration: included function simple.Simple.hello_world
147
+ [2021-02-10 11:37:59,490] INFO appmap._implementation.configuration: included function simple.Simple.world
148
+ [2021-02-10 11:37:59,828] INFO appmap.pytest: wrote recording /tmp/pytest/test_hello_world.appmap.json
149
+ PASSED
150
+
151
+ ====================================================================== 1 passed in 0.45s ======================================================================
152
+ ```
153
+
154
+ ### unittest
155
+
156
+ A subclass of `unittest.TestCase` is instrumented automatically, and an AppMap is recorded for each
157
+ `test_*` function in the subclass.
158
+
159
+ ## Request recording
160
+
161
+ `appmap-python` can automatically record and save an AppMap for each HTTP server request. To do this, the AppMap agent hooks into the web server request processing framework. It starts a recording when each new request is received,
162
+ records the execution thread into an AppMap, and saves in when the request is completed.
163
+
164
+ **Note** Your application must be running in a supported web framework for request recording to work.
165
+
166
+ ## Remote recording
167
+
168
+ The AppMap agent supports remote recording of web applications during development. When your application is run with debugging support, remote recording will be enabled automatically.
169
+
170
+ To enable debugging support, ensure:
171
+
172
+ * **Django** `DEBUG = True` in settings.py
173
+ * **Flask** run with the `--debug` option
174
+
175
+ **Note** Your application must be running in a supported web framework for remote recording to work.
176
+
177
+ ## Code Block Recording
178
+
179
+ You can use `appmap.record` as a context manager to record a specific span of code. With this method, you can control exactly
180
+ what code is recorded, and where the recording is saved.
181
+
182
+ Given a source file `record_sample.py`:
183
+
184
+ ```
185
+ import os
186
+ import sys
187
+
188
+ import appmap
189
+
190
+ r = appmap.Recording()
191
+ with r:
192
+ import sample
193
+ print(sample.C().hello_world(), file=sys.stderr)
194
+
195
+ with os.fdopen(sys.stdout.fileno(), "w", closefd=False) as stdout:
196
+ stdout.write(appmap.generation.dump(r))
197
+ stdout.flush()
198
+ ```
199
+
200
+ and a source file `sample.py`:
201
+
202
+ ```
203
+ class C:
204
+ def make_str(self, s):
205
+ return s;
206
+
207
+ def hello_world(self):
208
+ return f'{self.make_str("Hello")} {self.make_str("world!")}'
209
+ ```
210
+
211
+ as well as `appmap.yml`:
212
+
213
+ ```
214
+ name: sample
215
+ packages:
216
+ - path: sample
217
+ language: python
218
+ appmap_dir: tmp/appmap
219
+ ```
220
+
221
+ you can generate a recording of the code
222
+
223
+ ```
224
+ % python record_sample.py > record_sample.appmap.json
225
+ % jq '.events | length' record_sample.appmap.json
226
+ 6
227
+ % jq < record_sample.appmap.json | head -10
228
+ {
229
+ "version": "1.4",
230
+ "metadata": {
231
+ "language": {
232
+ "name": "python",
233
+ "engine": "CPython",
234
+ "version": "3.9.1"
235
+ },
236
+ "client": {
237
+ "name": "appmap",
238
+ ```
239
+
240
+ ## Web framework support
241
+
242
+ `appmap-python` integrates with the Django, Flask, and FastAPI web frameworks. When an application is started in a development environment, it inserts itself into the application's request processing stack. This enables recording of requests, as well as support for the [AppMap remote recording API](./remote-recording-api).
243
+
244
+ ### Django
245
+
246
+ To start a Django app with AppMap integration enabled, add
247
+ ```
248
+ DEBUG = True
249
+ ```
250
+ to your application's `settings.py`.
251
+
252
+ ### Flask
253
+
254
+ When `flask` is invoked with the `--debug` switch, debugging is enabled, as well as AppMap integration.
255
+
256
+ ### FastAPI
257
+ The FastAPI integration supports both request recording and remote recording. Request
258
+ recording is enabled by default. When running during application development,
259
+ remote recording can also be enabled.
260
+
261
+ #### uvicorn
262
+ To create remote recordings of a FastAPI application run with `uvicorn`, use the
263
+ `--reload` switch:
264
+
265
+ ```
266
+ $ uvicorn main:app --reload
267
+ INFO: Will watch for changes in these directories: ['/Users/example/fastapiapp']
268
+ INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
269
+ INFO: Started reloader process [57259] using StatReload
270
+ INFO: Started server process [57261]
271
+ INFO: Waiting for application startup.
272
+ INFO: Application startup complete.
273
+ ```
274
+ #### Other ASGI servers
275
+ To create remote recordings with other ASGI servers, you must modify your application code to add the agent's middleware. For example:
276
+
277
+ ```
278
+ from fastapi import FastAPI, HTTPException, Request
279
+ import appmap.fastapi
280
+
281
+ app = FastAPI()
282
+
283
+ @app.get("/")
284
+ def root():
285
+ return {"hello":"world"}
286
+
287
+ app = appmap.fastapi.Middleware(app, remote_enabled=True).init_app()
288
+ ```
289
+ Remote recordings will be enabled when `remote_enabled` is `True`.
290
+
291
+ ## Decorators
292
+
293
+ ### @appmap.labels
294
+
295
+ The [AppMap data format](https://github.com/getappmap/appmap) provides for class and
296
+ function `labels`, which can be used to enhance the AppMap visualizations, and to
297
+ programatically analyze the data.
298
+
299
+ You can apply function labels using the `appmap.labels` decorator in your Python code. To
300
+ apply a label to a function, decorate the function with `@appmap.labels`.
301
+
302
+ For example, to label a function as an authentication provider:
303
+ ```
304
+ import appmap
305
+
306
+ class ApiKey
307
+ @appmap.labels('provider.authentication', 'security')
308
+ def authenticate(self, key):
309
+ # logic to verify the key here...
310
+ ```
311
+
312
+ Then the AppMap metadata section for this function will include:
313
+
314
+ ```
315
+ {
316
+ "name": "authenticate",
317
+ "type": "function",
318
+ "labels": [ "provider.authentication", "security" ]
319
+ }
320
+ ```
321
+
322
+ ### @appmap.noappmap
323
+ The `@appmap.noappmap` decorator can be used to disable recording of `pytest` and `unittest` tests. If applied to a specific function, that function will not generate an AppMap. Alternatively, it can be applied to a test class to disable generation of AppMaps for all tests in the class.
324
+
325
+ For example:
326
+ ```
327
+ import appmap
328
+
329
+ def test_test1():
330
+ ...
331
+
332
+ @appmap.noappmap
333
+ def test_test2():
334
+ ....
335
+ ```
336
+ When the tests above are executed, `test_test1` will generate an AppMap, but `test_test2` will not.
337
+
338
+ For example, to decorate a test class:
339
+
340
+ ```
341
+ import unitest
342
+
343
+ import appmap
344
+
345
+ @appmap.noappmap
346
+ class TestNoAppMaps(unittest.TestCase):
347
+ def test_test1(self):
348
+ ...
349
+
350
+ def test_test2(self):
351
+ ...
352
+ ```
353
+
354
+ When functions within `TestNoAppMaps` are executed, no AppMaps will be generated.
355
+
356
+ ## Environment variables
357
+
358
+ ### General configuration
359
+ These environment variables can be used to control various aspects of the AppMap agent.
360
+
361
+ * `APPMAP_CONFIG` specifies the configuration file to use. Defaults to `appmap.yml` in the
362
+ current directory.
363
+
364
+ * `APPMAP_LOG_LEVEL` specifies log level to use, from the set `CRITICAL`, `ERROR`,
365
+ `WARNING`, `INFO`, `DEBUG`. Not case-sensitive, defaults to `INFO`.
366
+
367
+ * `APPMAP_DISPLAY_PARAMS` enables rendering of parameters as strings. If `true` (the
368
+ default, not case-sensitive), parameters are rendered using `repr`. If
369
+ `false`, a generic string is used instead.
370
+
371
+ * `APPMAP_DISABLE_LOG_FILE` controls the automatic creation of a log file by the
372
+ AppMap agent. If not `true` (the default), a log file will be created.
373
+
374
+ ### Controlling recording
375
+ These variables control the types of recordings generated by the agent.
376
+
377
+ #### Disabling recording methods
378
+ Some recording types are enabled by default. These variables allow you to disable them.
379
+
380
+ * `APPMAP_RECORD_<PYTEST|UNITTEST>` disables recording for individual test frameworks when set to `false`. For example, to disable recording when using `pytest`, use the variable `APPMAP_RECORD_PYTEST`.
381
+
382
+ * `APPMAP_RECORD_REQUESTS` disables recording of HTTP requests when set to `false`.
383
+
384
+ * `APPMAP_RECORD_REMOTE` disables remote recording when set to `false`.
385
+
386
+ * `APPMAP` controls all instrumentation and recording. When set to `false`, application code will run as if the AppMap agent was not installed.
387
+
388
+ #### Enabling recording methods
389
+ Some recording types are not enabled by default. These variables allow you to enable them
390
+
391
+ * `APPMAP_RECORD_PROCESS` controls recording of the entire python process that loads the agent. When `true`, recording starts when the agent is loaded. When the process exits, an AppMap will be created.
392
+
393
+ ## GitHub repository
394
+
395
+ [https://github.com/getappmap/appmap-python](https://github.com/getappmap/appmap-python)