appmap 1.24.1__tar.gz → 2.0.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 (164) hide show
  1. {appmap-1.24.1 → appmap-2.0.0}/PKG-INFO +6 -2
  2. {appmap-1.24.1 → appmap-2.0.0}/README.md +5 -1
  3. {appmap-1.24.1 → appmap-2.0.0}/_appmap/env.py +19 -29
  4. {appmap-1.24.1 → appmap-2.0.0}/_appmap/recording.py +1 -4
  5. {appmap-1.24.1 → appmap-2.0.0}/_appmap/test/test_configuration.py +0 -6
  6. {appmap-1.24.1 → appmap-2.0.0}/_appmap/test/test_django.py +13 -0
  7. {appmap-1.24.1 → appmap-2.0.0}/_appmap/test/test_flask.py +16 -1
  8. {appmap-1.24.1 → appmap-2.0.0}/_appmap/test/test_runner.py +1 -1
  9. {appmap-1.24.1 → appmap-2.0.0}/_appmap/test/test_test_frameworks.py +8 -1
  10. {appmap-1.24.1 → appmap-2.0.0}/_appmap/unittest.py +0 -3
  11. {appmap-1.24.1 → appmap-2.0.0}/_appmap/web_framework.py +0 -2
  12. appmap-2.0.0/appmap/__init__.py +48 -0
  13. {appmap-1.24.1 → appmap-2.0.0}/appmap/command/runner.py +1 -2
  14. {appmap-1.24.1 → appmap-2.0.0}/appmap/pytest.py +1 -5
  15. {appmap-1.24.1 → appmap-2.0.0}/appmap/unittest.py +1 -1
  16. {appmap-1.24.1 → appmap-2.0.0}/pyproject.toml +1 -1
  17. appmap-1.24.1/appmap/__init__.py +0 -48
  18. {appmap-1.24.1 → appmap-2.0.0}/LICENSE +0 -0
  19. {appmap-1.24.1 → appmap-2.0.0}/_appmap/__init__.py +0 -0
  20. {appmap-1.24.1 → appmap-2.0.0}/_appmap/configuration.py +0 -0
  21. {appmap-1.24.1 → appmap-2.0.0}/_appmap/django.py +0 -0
  22. {appmap-1.24.1 → appmap-2.0.0}/_appmap/event.py +0 -0
  23. {appmap-1.24.1 → appmap-2.0.0}/_appmap/fastapi.py +0 -0
  24. {appmap-1.24.1 → appmap-2.0.0}/_appmap/flask.py +0 -0
  25. {appmap-1.24.1 → appmap-2.0.0}/_appmap/generation.py +0 -0
  26. {appmap-1.24.1 → appmap-2.0.0}/_appmap/importer.py +0 -0
  27. {appmap-1.24.1 → appmap-2.0.0}/_appmap/instrument.py +0 -0
  28. {appmap-1.24.1 → appmap-2.0.0}/_appmap/labels.py +0 -0
  29. {appmap-1.24.1 → appmap-2.0.0}/_appmap/metadata.py +0 -0
  30. {appmap-1.24.1 → appmap-2.0.0}/_appmap/noappmap.py +0 -0
  31. {appmap-1.24.1 → appmap-2.0.0}/_appmap/py_version_check.py +0 -0
  32. {appmap-1.24.1 → appmap-2.0.0}/_appmap/recorder.py +0 -0
  33. {appmap-1.24.1 → appmap-2.0.0}/_appmap/remote_recording.py +0 -0
  34. {appmap-1.24.1 → appmap-2.0.0}/_appmap/singleton.py +0 -0
  35. {appmap-1.24.1 → appmap-2.0.0}/_appmap/test/__init__.py +0 -0
  36. {appmap-1.24.1 → appmap-2.0.0}/_appmap/test/appmap_test_base.py +0 -0
  37. {appmap-1.24.1 → appmap-2.0.0}/_appmap/test/bin/server_runner +0 -0
  38. {appmap-1.24.1 → appmap-2.0.0}/_appmap/test/conftest.py +0 -0
  39. {appmap-1.24.1 → appmap-2.0.0}/_appmap/test/data/appmap-all-paths-malformed.yml +0 -0
  40. {appmap-1.24.1 → appmap-2.0.0}/_appmap/test/data/appmap-broken.yml +0 -0
  41. {appmap-1.24.1 → appmap-2.0.0}/_appmap/test/data/appmap-class.yml +0 -0
  42. {appmap-1.24.1 → appmap-2.0.0}/_appmap/test/data/appmap-empty-path.yml +0 -0
  43. {appmap-1.24.1 → appmap-2.0.0}/_appmap/test/data/appmap-exclude-fn.yml +0 -0
  44. {appmap-1.24.1 → appmap-2.0.0}/_appmap/test/data/appmap-func.yml +0 -0
  45. {appmap-1.24.1 → appmap-2.0.0}/_appmap/test/data/appmap-malformed-path.yml +0 -0
  46. {appmap-1.24.1 → appmap-2.0.0}/_appmap/test/data/appmap-no-pyyaml.yml +0 -0
  47. {appmap-1.24.1 → appmap-2.0.0}/_appmap/test/data/appmap.yml +0 -0
  48. {appmap-1.24.1 → appmap-2.0.0}/_appmap/test/data/appmap_testing/__init__.py +0 -0
  49. {appmap-1.24.1 → appmap-2.0.0}/_appmap/test/data/appmap_testing/django_simplelazyobject.py +0 -0
  50. {appmap-1.24.1 → appmap-2.0.0}/_appmap/test/data/config/src/package/__init__.py +0 -0
  51. {appmap-1.24.1 → appmap-2.0.0}/_appmap/test/data/config/test/__init__.py +0 -0
  52. {appmap-1.24.1 → appmap-2.0.0}/_appmap/test/data/config/test/foo.py +0 -0
  53. {appmap-1.24.1 → appmap-2.0.0}/_appmap/test/data/config-exclude/.hide/hidden_mod/__init__.py +0 -0
  54. {appmap-1.24.1 → appmap-2.0.0}/_appmap/test/data/config-exclude/node_modules/node_mod/__init__.py +0 -0
  55. {appmap-1.24.1 → appmap-2.0.0}/_appmap/test/data/config-exclude/src/package/__init__.py +0 -0
  56. {appmap-1.24.1 → appmap-2.0.0}/_appmap/test/data/config-exclude/test/__init__.py +0 -0
  57. {appmap-1.24.1 → appmap-2.0.0}/_appmap/test/data/config-exclude/venv/venv_mod/__init__.py +0 -0
  58. {appmap-1.24.1 → appmap-2.0.0}/_appmap/test/data/config-up/appmap.yml +0 -0
  59. {appmap-1.24.1 → appmap-2.0.0}/_appmap/test/data/config-up/project/p1/__init__.py +0 -0
  60. {appmap-1.24.1 → appmap-2.0.0}/_appmap/test/data/config-up/project/p2/sub1/__init__.py +0 -0
  61. {appmap-1.24.1 → appmap-2.0.0}/_appmap/test/data/django/appmap.yml +0 -0
  62. {appmap-1.24.1 → appmap-2.0.0}/_appmap/test/data/django/djangoapp/__init__.py +0 -0
  63. {appmap-1.24.1 → appmap-2.0.0}/_appmap/test/data/django/djangoapp/djangoapp.py +0 -0
  64. {appmap-1.24.1 → appmap-2.0.0}/_appmap/test/data/django/djangoapp/hello_world.html +0 -0
  65. {appmap-1.24.1 → appmap-2.0.0}/_appmap/test/data/django/djangoapp/middleware.py +0 -0
  66. {appmap-1.24.1 → appmap-2.0.0}/_appmap/test/data/django/djangoapp/settings.py +0 -0
  67. {appmap-1.24.1 → appmap-2.0.0}/_appmap/test/data/django/djangoapp/settings_dev.py +0 -0
  68. {appmap-1.24.1 → appmap-2.0.0}/_appmap/test/data/django/djangoapp/urls.py +0 -0
  69. {appmap-1.24.1 → appmap-2.0.0}/_appmap/test/data/django/init/sitecustomize.py +0 -0
  70. {appmap-1.24.1 → appmap-2.0.0}/_appmap/test/data/django/manage.py +0 -0
  71. {appmap-1.24.1 → appmap-2.0.0}/_appmap/test/data/django/pytest.ini +0 -0
  72. {appmap-1.24.1 → appmap-2.0.0}/_appmap/test/data/django/test/__init__.py +0 -0
  73. {appmap-1.24.1 → appmap-2.0.0}/_appmap/test/data/django/test/test_app.py +0 -0
  74. {appmap-1.24.1 → appmap-2.0.0}/_appmap/test/data/example_class.py +0 -0
  75. {appmap-1.24.1 → appmap-2.0.0}/_appmap/test/data/expected.appmap.json +0 -0
  76. {appmap-1.24.1 → appmap-2.0.0}/_appmap/test/data/fastapi/appmap.yml +0 -0
  77. {appmap-1.24.1 → appmap-2.0.0}/_appmap/test/data/fastapi/fastapiapp/__init__.py +0 -0
  78. {appmap-1.24.1 → appmap-2.0.0}/_appmap/test/data/fastapi/fastapiapp/main.py +0 -0
  79. {appmap-1.24.1 → appmap-2.0.0}/_appmap/test/data/fastapi/init/sitecustomize.py +0 -0
  80. {appmap-1.24.1 → appmap-2.0.0}/_appmap/test/data/fastapi/test_app.py +0 -0
  81. {appmap-1.24.1 → appmap-2.0.0}/_appmap/test/data/flask/appmap.yml +0 -0
  82. {appmap-1.24.1 → appmap-2.0.0}/_appmap/test/data/flask/flaskapp.py +0 -0
  83. {appmap-1.24.1 → appmap-2.0.0}/_appmap/test/data/flask/init/sitecustomize.py +0 -0
  84. {appmap-1.24.1 → appmap-2.0.0}/_appmap/test/data/flask/templates/test.html +0 -0
  85. {appmap-1.24.1 → appmap-2.0.0}/_appmap/test/data/flask/test_app.py +0 -0
  86. {appmap-1.24.1 → appmap-2.0.0}/_appmap/test/data/package1/__init__.py +0 -0
  87. {appmap-1.24.1 → appmap-2.0.0}/_appmap/test/data/package1/package2/__init__.py +0 -0
  88. {appmap-1.24.1 → appmap-2.0.0}/_appmap/test/data/package1/package2/__main__.py +0 -0
  89. {appmap-1.24.1 → appmap-2.0.0}/_appmap/test/data/package1/package2/mod1.py +0 -0
  90. {appmap-1.24.1 → appmap-2.0.0}/_appmap/test/data/params.py +0 -0
  91. {appmap-1.24.1 → appmap-2.0.0}/_appmap/test/data/pytest/appmap.yml +0 -0
  92. {appmap-1.24.1 → appmap-2.0.0}/_appmap/test/data/pytest/expected/pytest.appmap.json +0 -0
  93. {appmap-1.24.1 → appmap-2.0.0}/_appmap/test/data/pytest/expected/status_errored.metadata.json +0 -0
  94. {appmap-1.24.1 → appmap-2.0.0}/_appmap/test/data/pytest/expected/status_failed.metadata.json +0 -0
  95. {appmap-1.24.1 → appmap-2.0.0}/_appmap/test/data/pytest/expected/status_xfailed.metadata.json +0 -0
  96. {appmap-1.24.1 → appmap-2.0.0}/_appmap/test/data/pytest/simple.py +0 -0
  97. {appmap-1.24.1 → appmap-2.0.0}/_appmap/test/data/pytest/test_noappmap.py +0 -0
  98. {appmap-1.24.1 → appmap-2.0.0}/_appmap/test/data/pytest/test_simple.py +0 -0
  99. {appmap-1.24.1 → appmap-2.0.0}/_appmap/test/data/remote.appmap.json +0 -0
  100. {appmap-1.24.1 → appmap-2.0.0}/_appmap/test/data/trial/.gitignore +0 -0
  101. {appmap-1.24.1 → appmap-2.0.0}/_appmap/test/data/trial/appmap.yml +0 -0
  102. {appmap-1.24.1 → appmap-2.0.0}/_appmap/test/data/trial/expected/pytest.appmap.json +0 -0
  103. {appmap-1.24.1 → appmap-2.0.0}/_appmap/test/data/trial/init/sitecustomize.py +0 -0
  104. {appmap-1.24.1 → appmap-2.0.0}/_appmap/test/data/trial/test/__init__.py +0 -0
  105. {appmap-1.24.1 → appmap-2.0.0}/_appmap/test/data/trial/test/test_deferred.py +0 -0
  106. {appmap-1.24.1 → appmap-2.0.0}/_appmap/test/data/unittest/appmap.yml +0 -0
  107. {appmap-1.24.1 → appmap-2.0.0}/_appmap/test/data/unittest/expected/pytest.appmap.json +0 -0
  108. {appmap-1.24.1 → appmap-2.0.0}/_appmap/test/data/unittest/expected/status_errored.metadata.json +0 -0
  109. {appmap-1.24.1 → appmap-2.0.0}/_appmap/test/data/unittest/expected/status_failed.metadata.json +0 -0
  110. {appmap-1.24.1 → appmap-2.0.0}/_appmap/test/data/unittest/expected/status_xfailed.metadata.json +0 -0
  111. {appmap-1.24.1 → appmap-2.0.0}/_appmap/test/data/unittest/expected/status_xsucceeded.metadata.json +0 -0
  112. {appmap-1.24.1 → appmap-2.0.0}/_appmap/test/data/unittest/expected/unittest.appmap.json +0 -0
  113. {appmap-1.24.1 → appmap-2.0.0}/_appmap/test/data/unittest/init/sitecustomize.py +0 -0
  114. {appmap-1.24.1 → appmap-2.0.0}/_appmap/test/data/unittest/simple/__init__.py +0 -0
  115. {appmap-1.24.1 → appmap-2.0.0}/_appmap/test/data/unittest/simple/test_noappmap.py +0 -0
  116. {appmap-1.24.1 → appmap-2.0.0}/_appmap/test/data/unittest/simple/test_simple.py +0 -0
  117. {appmap-1.24.1 → appmap-2.0.0}/_appmap/test/helpers.py +0 -0
  118. {appmap-1.24.1 → appmap-2.0.0}/_appmap/test/normalize.py +0 -0
  119. {appmap-1.24.1 → appmap-2.0.0}/_appmap/test/test_command.py +0 -0
  120. {appmap-1.24.1 → appmap-2.0.0}/_appmap/test/test_describe_value.py +0 -0
  121. {appmap-1.24.1 → appmap-2.0.0}/_appmap/test/test_django_simplelazyobject.py +0 -0
  122. {appmap-1.24.1 → appmap-2.0.0}/_appmap/test/test_env.py +0 -0
  123. {appmap-1.24.1 → appmap-2.0.0}/_appmap/test/test_events.py +0 -0
  124. {appmap-1.24.1 → appmap-2.0.0}/_appmap/test/test_fastapi.py +0 -0
  125. {appmap-1.24.1 → appmap-2.0.0}/_appmap/test/test_generation.py +0 -0
  126. {appmap-1.24.1 → appmap-2.0.0}/_appmap/test/test_http.py +0 -0
  127. {appmap-1.24.1 → appmap-2.0.0}/_appmap/test/test_importer.py +0 -0
  128. {appmap-1.24.1 → appmap-2.0.0}/_appmap/test/test_labels.py +0 -0
  129. {appmap-1.24.1 → appmap-2.0.0}/_appmap/test/test_metadata.py +0 -0
  130. {appmap-1.24.1 → appmap-2.0.0}/_appmap/test/test_params.py +0 -0
  131. {appmap-1.24.1 → appmap-2.0.0}/_appmap/test/test_recording.py +0 -0
  132. {appmap-1.24.1 → appmap-2.0.0}/_appmap/test/test_sqlalchemy.py +0 -0
  133. {appmap-1.24.1 → appmap-2.0.0}/_appmap/test/test_util.py +0 -0
  134. {appmap-1.24.1 → appmap-2.0.0}/_appmap/test/web_framework.py +0 -0
  135. {appmap-1.24.1 → appmap-2.0.0}/_appmap/testing_framework.py +0 -0
  136. {appmap-1.24.1 → appmap-2.0.0}/_appmap/trace_logger.py +0 -0
  137. {appmap-1.24.1 → appmap-2.0.0}/_appmap/utils.py +0 -0
  138. {appmap-1.24.1 → appmap-2.0.0}/appmap/command/__init__.py +0 -0
  139. {appmap-1.24.1 → appmap-2.0.0}/appmap/command/appmap_agent_init.py +0 -0
  140. {appmap-1.24.1 → appmap-2.0.0}/appmap/command/appmap_agent_status.py +0 -0
  141. {appmap-1.24.1 → appmap-2.0.0}/appmap/command/appmap_agent_validate.py +0 -0
  142. {appmap-1.24.1 → appmap-2.0.0}/appmap/django.py +0 -0
  143. {appmap-1.24.1 → appmap-2.0.0}/appmap/fastapi.py +0 -0
  144. {appmap-1.24.1 → appmap-2.0.0}/appmap/flask.py +0 -0
  145. {appmap-1.24.1 → appmap-2.0.0}/appmap/http.py +0 -0
  146. {appmap-1.24.1 → appmap-2.0.0}/appmap/labeling/__init__.py +0 -0
  147. {appmap-1.24.1 → appmap-2.0.0}/appmap/labeling/crypto.yml +0 -0
  148. {appmap-1.24.1 → appmap-2.0.0}/appmap/labeling/django.yml +0 -0
  149. {appmap-1.24.1 → appmap-2.0.0}/appmap/labeling/flask.yml +0 -0
  150. {appmap-1.24.1 → appmap-2.0.0}/appmap/labeling/formats.yml +0 -0
  151. {appmap-1.24.1 → appmap-2.0.0}/appmap/labeling/http.yml +0 -0
  152. {appmap-1.24.1 → appmap-2.0.0}/appmap/labeling/jobs.yml +0 -0
  153. {appmap-1.24.1 → appmap-2.0.0}/appmap/labeling/jwt.yml +0 -0
  154. {appmap-1.24.1 → appmap-2.0.0}/appmap/labeling/logger.yml +0 -0
  155. {appmap-1.24.1 → appmap-2.0.0}/appmap/labeling/random.yml +0 -0
  156. {appmap-1.24.1 → appmap-2.0.0}/appmap/sqlalchemy.py +0 -0
  157. {appmap-1.24.1 → appmap-2.0.0}/appmap/uvicorn.py +0 -0
  158. {appmap-1.24.1 → appmap-2.0.0}/appmap.pth +0 -0
  159. {appmap-1.24.1 → appmap-2.0.0}/vendor/_appmap/wrapt/LICENSE +0 -0
  160. {appmap-1.24.1 → appmap-2.0.0}/vendor/_appmap/wrapt/__init__.py +0 -0
  161. {appmap-1.24.1 → appmap-2.0.0}/vendor/_appmap/wrapt/arguments.py +0 -0
  162. {appmap-1.24.1 → appmap-2.0.0}/vendor/_appmap/wrapt/decorators.py +0 -0
  163. {appmap-1.24.1 → appmap-2.0.0}/vendor/_appmap/wrapt/importer.py +0 -0
  164. {appmap-1.24.1 → appmap-2.0.0}/vendor/_appmap/wrapt/wrappers.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: appmap
3
- Version: 1.24.1
3
+ Version: 2.0.0
4
4
  Summary: Create AppMap files by recording a Python application.
5
5
  Home-page: https://github.com/applandinc/appmap-python
6
6
  License: MIT
@@ -118,9 +118,13 @@ reenabled as soon as possible.]
118
118
  ### pytest
119
119
 
120
120
  Note that you must install the dependencies contained in
121
- [requirements-test.txt](requirements-test.txt) before running tests. See the explanation in
121
+ [requirements-dev.txt](requirements-dev.txt) before running tests. See the explanation in
122
122
  [pyproject.toml](pyproject.toml) for details.
123
123
 
124
+ Additionally, the tests currently require that you set `APPMAP=true`. You can
125
+ either run `pytest` with `appmap-python` (see [tox.ini](tox.ini)), or you can explicitly
126
+ set the environment variable.
127
+
124
128
  [pytest](https://docs.pytest.org/en/stable/) for testing:
125
129
 
126
130
  ```
@@ -87,9 +87,13 @@ reenabled as soon as possible.]
87
87
  ### pytest
88
88
 
89
89
  Note that you must install the dependencies contained in
90
- [requirements-test.txt](requirements-test.txt) before running tests. See the explanation in
90
+ [requirements-dev.txt](requirements-dev.txt) before running tests. See the explanation in
91
91
  [pyproject.toml](pyproject.toml) for details.
92
92
 
93
+ Additionally, the tests currently require that you set `APPMAP=true`. You can
94
+ either run `pytest` with `appmap-python` (see [tox.ini](tox.ini)), or you can explicitly
95
+ set the environment variable.
96
+
93
97
  [pytest](https://docs.pytest.org/en/stable/) for testing:
94
98
 
95
99
  ```
@@ -3,7 +3,6 @@
3
3
  import logging
4
4
  import logging.config
5
5
  import os
6
- import warnings
7
6
  from contextlib import contextmanager
8
7
  from os import environ
9
8
  from pathlib import Path
@@ -13,20 +12,6 @@ from _appmap.singleton import SingletonMeta
13
12
 
14
13
  from . import trace_logger
15
14
 
16
- _ENABLED_BY_DEFAULT_MSG = """
17
-
18
- The APPMAP environment variable is unset. Your code will be
19
- instrumented and recorded according to the configuration in appmap.yml.
20
-
21
- Starting with version 2, this behavior will change: when APPMAP is
22
- unset, no code will be instrumented. You will need to use the
23
- appmap-python script to run your application, or explicitly set
24
- APPMAP.
25
-
26
- Visit https://appmap.io/docs/reference/appmap-python.html#appmap-python-script for more
27
- details.
28
- """
29
-
30
15
  _cwd = Path.cwd()
31
16
  _bootenv = environ.copy()
32
17
 
@@ -36,9 +21,9 @@ def _recording_method_key(recording_method):
36
21
 
37
22
 
38
23
  class Env(metaclass=SingletonMeta):
39
- def __init__(self, env=None, cwd=None):
40
- warnings.filterwarnings("once", _ENABLED_BY_DEFAULT_MSG)
24
+ RECORD_PROCESS_DEFAULT = "false"
41
25
 
26
+ def __init__(self, env=None, cwd=None):
42
27
  # root_dir and root_dir_len are going to be used when
43
28
  # instrumenting every function, so preprocess them as
44
29
  # much as possible.
@@ -54,7 +39,6 @@ class Env(metaclass=SingletonMeta):
54
39
 
55
40
  self._configure_logging()
56
41
  enabled = self._env.get("_APPMAP", None)
57
- self._enabled_by_default = enabled is None
58
42
  self._enabled = enabled is None or enabled.lower() != "false"
59
43
 
60
44
  self._root_dir = str(self._cwd) + "/"
@@ -73,6 +57,9 @@ class Env(metaclass=SingletonMeta):
73
57
  def set(self, name, value):
74
58
  self._env[name] = value
75
59
 
60
+ def setdefault(self, name, default_value):
61
+ self._env.setdefault(name, default_value)
62
+
76
63
  def get(self, name, default=None):
77
64
  return self._env.get(name, default)
78
65
 
@@ -95,14 +82,6 @@ class Env(metaclass=SingletonMeta):
95
82
  def output_dir(self, value):
96
83
  self._output_dir = value
97
84
 
98
- @property
99
- def enabled_by_default(self):
100
- return self._enabled_by_default
101
-
102
- def warn_enabled_by_default(self):
103
- if self._enabled_by_default:
104
- warnings.warn(_ENABLED_BY_DEFAULT_MSG, category=DeprecationWarning, stacklevel=2)
105
-
106
85
  @property
107
86
  def enabled(self):
108
87
  return self._enabled
@@ -115,14 +94,25 @@ class Env(metaclass=SingletonMeta):
115
94
  if not self.enabled:
116
95
  return False
117
96
 
118
- v = self.get(_recording_method_key(recording_method), default).lower()
119
- return v != "false"
97
+ process_enabled = self._enables("process", self.RECORD_PROCESS_DEFAULT)
98
+ if recording_method == "process":
99
+ return process_enabled
100
+
101
+ # If process recording is enabled, others should be disabled
102
+ if process_enabled:
103
+ return False
104
+
105
+ # Otherwise, check the environment variable
106
+ return self._enables(recording_method, default)
107
+
108
+ def _enables(self, recording_method, default):
109
+ return self.get(_recording_method_key(recording_method), default).lower() != "false"
120
110
 
121
111
  @contextmanager
122
112
  def disabled(self, recording_method: str):
123
113
  key = _recording_method_key(recording_method)
124
114
  value = self.get(key)
125
- self.set(key, "false")
115
+ self.setdefault(key, "false")
126
116
  try:
127
117
  yield
128
118
  finally:
@@ -44,7 +44,6 @@ class Recording:
44
44
  return Recorder.get_enabled()
45
45
 
46
46
  def __enter__(self):
47
- Env.current.warn_enabled_by_default()
48
47
  self.start()
49
48
 
50
49
  def __exit__(self, exc_type, exc_value, tb):
@@ -80,9 +79,7 @@ def write_appmap(
80
79
 
81
80
 
82
81
  def initialize():
83
- if Env.current.enables("process", "false"):
84
- Env.current.warn_enabled_by_default()
85
-
82
+ if Env.current.enables("process", Env.RECORD_PROCESS_DEFAULT):
86
83
  r = Recording()
87
84
  r.start()
88
85
 
@@ -16,10 +16,6 @@ from _appmap.env import Env
16
16
  from _appmap.importer import Filterable, NullFilter
17
17
 
18
18
 
19
- def test_enabled_by_default():
20
- assert appmap.enabled()
21
-
22
-
23
19
  @pytest.mark.appmap_enabled
24
20
  def test_can_be_configured():
25
21
  """
@@ -45,8 +41,6 @@ def test_reports_invalid():
45
41
  @pytest.mark.appmap_enabled(config="appmap-broken.yml")
46
42
  def test_is_disabled_when_unset():
47
43
  """Test that recording is disabled when APPMAP is unset but the config is broken"""
48
- assert Env.current.get("_APPMAP", None) is None
49
-
50
44
  assert not appmap.enabled()
51
45
 
52
46
 
@@ -216,6 +216,19 @@ class TestDjangoApp:
216
216
  result.assert_outcomes(passed=1, failed=0, errors=0)
217
217
  assert not (pytester.path / "tmp").exists()
218
218
 
219
+ def test_disabled_for_process(self, pytester, monkeypatch):
220
+ monkeypatch.setenv("APPMAP_RECORD_PROCESS", "true")
221
+
222
+ result = pytester.runpytest("-svv")
223
+
224
+ # There are two tests for remote recording. They should both fail,
225
+ # because process recording should disable remote recording.
226
+ result.assert_outcomes(passed=2, failed=2, errors=0)
227
+
228
+ assert (pytester.path / "tmp" / "appmap" / "process").exists()
229
+ assert not (pytester.path / "tmp" / "appmap" / "requests").exists()
230
+ assert not (pytester.path / "tmp" / "appmap" / "pytest").exists()
231
+
219
232
 
220
233
  @pytest.fixture(name="server")
221
234
  def django_server(xprocess, server_base):
@@ -8,10 +8,10 @@ from types import SimpleNamespace as NS
8
8
 
9
9
  import flask
10
10
  import pytest
11
- from appmap.flask import AppmapFlask
12
11
 
13
12
  from _appmap.env import Env
14
13
  from _appmap.metadata import Metadata
14
+ from appmap.flask import AppmapFlask
15
15
 
16
16
  from ..test.helpers import DictIncluding
17
17
  from .web_framework import (
@@ -144,7 +144,11 @@ class TestFlaskApp:
144
144
  appmap_file = (
145
145
  pytester.path / "tmp" / "appmap" / "pytest" / "test_request.appmap.json"
146
146
  )
147
+
148
+ # No request recordings should have been created
147
149
  assert not os.path.exists(pytester.path / "tmp" / "appmap" / "requests")
150
+
151
+ # but there should be a test recording
148
152
  assert appmap_file.exists()
149
153
 
150
154
  def test_disabled(self, pytester, monkeypatch):
@@ -154,3 +158,14 @@ class TestFlaskApp:
154
158
 
155
159
  result.assert_outcomes(passed=1, failed=0, errors=0)
156
160
  assert not (pytester.path / "tmp" / "appmap").exists()
161
+
162
+ def test_disabled_for_process(self, pytester, monkeypatch):
163
+ monkeypatch.setenv("APPMAP_RECORD_PROCESS", "true")
164
+
165
+ result = pytester.runpytest("-svv")
166
+
167
+ result.assert_outcomes(passed=1, failed=0, errors=0)
168
+
169
+ assert (pytester.path / "tmp" / "appmap" / "process").exists()
170
+ assert not (pytester.path / "tmp" / "appmap" / "requests").exists()
171
+ assert not (pytester.path / "tmp" / "appmap" / "pytest").exists()
@@ -15,7 +15,7 @@ def test_runner_help(script_runner):
15
15
  assert result.stdout.startswith("usage")
16
16
 
17
17
 
18
- @pytest.mark.parametrize("recording_type", ["process", "pytest", "remote", "requests", "unittest"])
18
+ @pytest.mark.parametrize("recording_type", ["process", "remote", "requests", "tests"])
19
19
  def test_runner_recording_type(script_runner, recording_type):
20
20
  result = script_runner.run(["appmap-python", "--record", recording_type])
21
21
  assert result.returncode == 0
@@ -39,11 +39,18 @@ class _TestTestRunner(ABC):
39
39
  assert not testdir.output().exists()
40
40
 
41
41
  def test_disabled(self, testdir, monkeypatch):
42
- monkeypatch.setenv(f"APPMAP_RECORD_{self._test_type.upper()}", "false")
42
+ monkeypatch.setenv("APPMAP_RECORD_TESTS", "false")
43
43
 
44
44
  self.run_tests(testdir)
45
45
  assert not testdir.output().exists()
46
46
 
47
+ def test_disabled_for_process(self, testdir, monkeypatch):
48
+ monkeypatch.setenv("APPMAP_RECORD_PROCESS", "true")
49
+
50
+ self.run_tests(testdir)
51
+ assert (testdir.path / "tmp" / "appmap" / "process").exists()
52
+ assert not testdir.output().exists()
53
+
47
54
 
48
55
  class TestUnittestRunner(_TestTestRunner):
49
56
  @classmethod
@@ -3,7 +3,6 @@ import unittest
3
3
  from contextlib import contextmanager
4
4
 
5
5
  from _appmap import noappmap, testing_framework, wrapt
6
- from _appmap.env import Env
7
6
  from _appmap.utils import get_function_location
8
7
 
9
8
  _session = testing_framework.session("unittest", "tests")
@@ -43,7 +42,6 @@ if sys.version_info[1] < 8:
43
42
  with _session.record(
44
43
  test_case.__class__, method_name, location=location
45
44
  ) as metadata:
46
- Env.current.warn_enabled_by_default()
47
45
  if metadata:
48
46
  with wrapped(
49
47
  *args, **kwargs
@@ -69,7 +67,6 @@ else:
69
67
  method_name = test_case.id().split(".")[-1]
70
68
  location = _get_test_location(test_case.__class__, method_name)
71
69
  with _session.record(test_case.__class__, method_name, location=location) as metadata:
72
- Env.current.warn_enabled_by_default()
73
70
  if metadata:
74
71
  with testing_framework.collect_result_metadata(metadata):
75
72
  wrapped(*args, **kwargs)
@@ -250,8 +250,6 @@ class MiddlewareInserter(ABC):
250
250
  """Return True if the AppMap middleware has enabled remote recording, False otherwise."""
251
251
 
252
252
  def run(self):
253
- Env.current.warn_enabled_by_default()
254
-
255
253
  if not self.middleware_present():
256
254
  return self.insert_middleware()
257
255
 
@@ -0,0 +1,48 @@
1
+ """AppMap recorder for Python"""
2
+ import os
3
+
4
+ # Note that we need to guard these imports with a conditional, rather than
5
+ # putting them in a function and conditionally calling the function. If we
6
+ # execute the imports in a function, the modules all get put into the funtion's
7
+ # globals, rather than into appmap's globals.
8
+ _enabled = os.environ.get("APPMAP", None)
9
+ if _enabled is None or _enabled.upper() == "TRUE":
10
+ if _enabled is not None:
11
+ # Use setdefault so tests can manage _APPMAP as necessary
12
+ os.environ.setdefault("_APPMAP", _enabled)
13
+ from _appmap import generation # noqa: F401
14
+ from _appmap.env import Env # noqa: F401
15
+ from _appmap.importer import instrument_module # noqa: F401
16
+ from _appmap.labels import labels # noqa: F401
17
+ from _appmap.noappmap import decorator as noappmap # noqa: F401
18
+ from _appmap.recording import Recording # noqa: F401
19
+
20
+ try:
21
+ from . import django # noqa: F401
22
+ except ImportError:
23
+ pass
24
+
25
+ try:
26
+ from . import flask # noqa: F401
27
+ except ImportError:
28
+ pass
29
+
30
+ try:
31
+ from . import fastapi # noqa: F401
32
+ except ImportError:
33
+ pass
34
+
35
+ try:
36
+ from . import uvicorn # noqa: F401
37
+ except ImportError:
38
+ pass
39
+
40
+ # Note: pytest integration is configured as a pytest plugin, so it doesn't
41
+ # need to be imported here
42
+
43
+ # unittest is part of the standard library, so it should always be
44
+ # importable (and therefore doesn't need to be in a try .. except block)
45
+ from . import unittest # noqa: F401
46
+
47
+ def enabled():
48
+ return Env.current.enabled
@@ -24,10 +24,9 @@ will be displayed.
24
24
  _RECORDING_TYPES = set(
25
25
  [
26
26
  "process",
27
- "pytest",
28
27
  "remote",
29
28
  "requests",
30
- "unittest",
29
+ "tests",
31
30
  ]
32
31
  )
33
32
 
@@ -22,13 +22,9 @@ class recorded_testcase: # pylint: disable=too-few-public-methods
22
22
  return wrapped(*args, **kwargs)
23
23
 
24
24
 
25
- if not Env.current.is_appmap_repo and Env.current.enables("pytest"):
25
+ if not Env.current.is_appmap_repo and Env.current.enables("tests"):
26
26
  logger.debug("Test recording is enabled (Pytest)")
27
27
 
28
- @pytest.hookimpl
29
- def pytest_configure(config): # pylint: disable=unused-argument
30
- Env.current.warn_enabled_by_default()
31
-
32
28
  @pytest.hookimpl
33
29
  def pytest_sessionstart(session):
34
30
  session.appmap = testing_framework.session(
@@ -2,7 +2,7 @@ from _appmap.env import Env
2
2
 
3
3
  logger = Env.current.getLogger(__name__)
4
4
 
5
- if not Env.current.is_appmap_repo and Env.current.enables("unittest"):
5
+ if not Env.current.is_appmap_repo and Env.current.enables("tests"):
6
6
  logger.debug("Test recording is enabled (unittest)")
7
7
  # pylint: disable=unused-import
8
8
  import _appmap.unittest # pyright: ignore # noqa: F401
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "appmap"
3
- version = "1.24.1"
3
+ version = "2.0.0"
4
4
  description = "Create AppMap files by recording a Python application."
5
5
  readme = "README.md"
6
6
  authors = [
@@ -1,48 +0,0 @@
1
- """AppMap recorder for Python"""
2
- import os
3
-
4
- # Note that we need to guard these imports with a conditional, rather than
5
- # putting them in a function and conditionally calling the function. If we
6
- # execute the imports in a function, the modules all get put into the funtion's
7
- # globals, rather than into appmap's globals.
8
- _enabled = os.environ.get("APPMAP", None)
9
- if _enabled is None or _enabled.upper() == "TRUE":
10
- if _enabled is not None:
11
- # Use setdefault so tests can manage _APPMAP as necessary
12
- os.environ["_APPMAP"] = _enabled
13
- from _appmap import generation # noqa: F401
14
- from _appmap.env import Env # noqa: F401
15
- from _appmap.importer import instrument_module # noqa: F401
16
- from _appmap.labels import labels # noqa: F401
17
- from _appmap.noappmap import decorator as noappmap # noqa: F401
18
- from _appmap.recording import Recording # noqa: F401
19
-
20
- try:
21
- from . import django # noqa: F401
22
- except ImportError:
23
- pass
24
-
25
- try:
26
- from . import flask # noqa: F401
27
- except ImportError:
28
- pass
29
-
30
- try:
31
- from . import fastapi # noqa: F401
32
- except ImportError:
33
- pass
34
-
35
- try:
36
- from . import uvicorn # noqa: F401
37
- except ImportError:
38
- pass
39
-
40
- # Note: pytest integration is configured as a pytest plugin, so it doesn't
41
- # need to be imported here
42
-
43
- # unittest is part of the standard library, so it should always be
44
- # importable (and therefore doesn't need to be in a try .. except block)
45
- from . import unittest # noqa: F401
46
-
47
- def enabled():
48
- return Env.current.enabled
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes