appmap 1.22.0__tar.gz → 1.23.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.
- {appmap-1.22.0 → appmap-1.23.0}/PKG-INFO +1 -1
- {appmap-1.22.0 → appmap-1.23.0}/_appmap/__init__.py +1 -2
- {appmap-1.22.0 → appmap-1.23.0}/_appmap/configuration.py +51 -27
- {appmap-1.22.0 → appmap-1.23.0}/_appmap/env.py +3 -17
- {appmap-1.22.0 → appmap-1.23.0}/_appmap/importer.py +1 -1
- appmap-1.23.0/_appmap/singleton.py +14 -0
- appmap-1.23.0/_appmap/test/data/appmap-all-paths-malformed.yml +9 -0
- appmap-1.23.0/_appmap/test/data/appmap-empty-path.yml +5 -0
- appmap-1.23.0/_appmap/test/data/appmap-malformed-path.yml +4 -0
- {appmap-1.22.0 → appmap-1.23.0}/_appmap/test/test_configuration.py +34 -13
- {appmap-1.22.0 → appmap-1.23.0}/_appmap/test/test_sqlalchemy.py +19 -13
- {appmap-1.22.0 → appmap-1.23.0}/_appmap/testing_framework.py +1 -1
- {appmap-1.22.0 → appmap-1.23.0}/appmap/command/appmap_agent_init.py +1 -1
- {appmap-1.22.0 → appmap-1.23.0}/appmap/command/appmap_agent_status.py +1 -1
- {appmap-1.22.0 → appmap-1.23.0}/appmap/sqlalchemy.py +1 -1
- {appmap-1.22.0 → appmap-1.23.0}/pyproject.toml +1 -2
- {appmap-1.22.0 → appmap-1.23.0}/LICENSE +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/README.md +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/_appmap/django.py +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/_appmap/event.py +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/_appmap/fastapi.py +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/_appmap/flask.py +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/_appmap/generation.py +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/_appmap/instrument.py +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/_appmap/labels.py +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/_appmap/metadata.py +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/_appmap/noappmap.py +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/_appmap/py_version_check.py +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/_appmap/recorder.py +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/_appmap/recording.py +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/_appmap/remote_recording.py +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/_appmap/test/__init__.py +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/_appmap/test/appmap_test_base.py +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/_appmap/test/bin/server_runner +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/_appmap/test/conftest.py +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/_appmap/test/data/appmap-broken.yml +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/_appmap/test/data/appmap-class.yml +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/_appmap/test/data/appmap-exclude-fn.yml +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/_appmap/test/data/appmap-func.yml +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/_appmap/test/data/appmap-no-pyyaml.yml +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/_appmap/test/data/appmap.yml +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/_appmap/test/data/appmap_testing/__init__.py +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/_appmap/test/data/appmap_testing/django_simplelazyobject.py +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/_appmap/test/data/config/src/package/__init__.py +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/_appmap/test/data/config/test/__init__.py +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/_appmap/test/data/config/test/foo.py +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/_appmap/test/data/config-exclude/.hide/hidden_mod/__init__.py +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/_appmap/test/data/config-exclude/node_modules/node_mod/__init__.py +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/_appmap/test/data/config-exclude/src/package/__init__.py +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/_appmap/test/data/config-exclude/test/__init__.py +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/_appmap/test/data/config-exclude/venv/venv_mod/__init__.py +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/_appmap/test/data/config-up/appmap.yml +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/_appmap/test/data/config-up/subprojects/p1/__init__.py +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/_appmap/test/data/config-up/subprojects/p2/sub1/__init__.py +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/_appmap/test/data/django/appmap.yml +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/_appmap/test/data/django/djangoapp/__init__.py +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/_appmap/test/data/django/djangoapp/djangoapp.py +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/_appmap/test/data/django/djangoapp/hello_world.html +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/_appmap/test/data/django/djangoapp/middleware.py +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/_appmap/test/data/django/djangoapp/settings.py +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/_appmap/test/data/django/djangoapp/settings_dev.py +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/_appmap/test/data/django/djangoapp/urls.py +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/_appmap/test/data/django/init/sitecustomize.py +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/_appmap/test/data/django/manage.py +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/_appmap/test/data/django/pytest.ini +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/_appmap/test/data/django/test/__init__.py +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/_appmap/test/data/django/test/test_app.py +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/_appmap/test/data/example_class.py +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/_appmap/test/data/expected.appmap.json +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/_appmap/test/data/fastapi/appmap.yml +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/_appmap/test/data/fastapi/fastapiapp/__init__.py +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/_appmap/test/data/fastapi/fastapiapp/main.py +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/_appmap/test/data/fastapi/init/sitecustomize.py +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/_appmap/test/data/fastapi/test_app.py +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/_appmap/test/data/flask/appmap.yml +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/_appmap/test/data/flask/flaskapp.py +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/_appmap/test/data/flask/init/sitecustomize.py +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/_appmap/test/data/flask/templates/test.html +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/_appmap/test/data/flask/test_app.py +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/_appmap/test/data/package1/__init__.py +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/_appmap/test/data/package1/package2/__init__.py +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/_appmap/test/data/package1/package2/__main__.py +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/_appmap/test/data/package1/package2/mod1.py +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/_appmap/test/data/params.py +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/_appmap/test/data/pytest/appmap.yml +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/_appmap/test/data/pytest/expected/pytest.appmap.json +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/_appmap/test/data/pytest/expected/status_errored.metadata.json +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/_appmap/test/data/pytest/expected/status_failed.metadata.json +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/_appmap/test/data/pytest/expected/status_xfailed.metadata.json +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/_appmap/test/data/pytest/simple.py +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/_appmap/test/data/pytest/test_noappmap.py +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/_appmap/test/data/pytest/test_simple.py +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/_appmap/test/data/remote.appmap.json +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/_appmap/test/data/trial/.gitignore +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/_appmap/test/data/trial/appmap.yml +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/_appmap/test/data/trial/expected/pytest.appmap.json +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/_appmap/test/data/trial/init/sitecustomize.py +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/_appmap/test/data/trial/test/__init__.py +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/_appmap/test/data/trial/test/test_deferred.py +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/_appmap/test/data/unittest/appmap.yml +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/_appmap/test/data/unittest/expected/pytest.appmap.json +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/_appmap/test/data/unittest/expected/status_errored.metadata.json +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/_appmap/test/data/unittest/expected/status_failed.metadata.json +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/_appmap/test/data/unittest/expected/status_xfailed.metadata.json +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/_appmap/test/data/unittest/expected/status_xsucceeded.metadata.json +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/_appmap/test/data/unittest/expected/unittest.appmap.json +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/_appmap/test/data/unittest/init/sitecustomize.py +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/_appmap/test/data/unittest/simple/__init__.py +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/_appmap/test/data/unittest/simple/test_noappmap.py +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/_appmap/test/data/unittest/simple/test_simple.py +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/_appmap/test/helpers.py +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/_appmap/test/normalize.py +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/_appmap/test/test_command.py +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/_appmap/test/test_describe_value.py +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/_appmap/test/test_django.py +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/_appmap/test/test_django_simplelazyobject.py +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/_appmap/test/test_env.py +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/_appmap/test/test_events.py +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/_appmap/test/test_fastapi.py +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/_appmap/test/test_flask.py +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/_appmap/test/test_generation.py +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/_appmap/test/test_http.py +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/_appmap/test/test_importer.py +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/_appmap/test/test_labels.py +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/_appmap/test/test_metadata.py +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/_appmap/test/test_params.py +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/_appmap/test/test_recording.py +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/_appmap/test/test_runner.py +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/_appmap/test/test_test_frameworks.py +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/_appmap/test/test_util.py +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/_appmap/test/web_framework.py +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/_appmap/trace_logger.py +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/_appmap/unittest.py +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/_appmap/utils.py +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/_appmap/web_framework.py +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/appmap/__init__.py +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/appmap/command/__init__.py +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/appmap/command/appmap_agent_validate.py +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/appmap/command/runner.py +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/appmap/django.py +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/appmap/fastapi.py +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/appmap/flask.py +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/appmap/http.py +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/appmap/labeling/__init__.py +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/appmap/labeling/crypto.yml +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/appmap/labeling/django.yml +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/appmap/labeling/flask.yml +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/appmap/labeling/formats.yml +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/appmap/labeling/http.yml +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/appmap/labeling/jobs.yml +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/appmap/labeling/jwt.yml +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/appmap/labeling/logger.yml +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/appmap/labeling/random.yml +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/appmap/pytest.py +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/appmap/unittest.py +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/appmap/uvicorn.py +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/appmap.pth +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/vendor/_appmap/wrapt/LICENSE +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/vendor/_appmap/wrapt/__init__.py +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/vendor/_appmap/wrapt/arguments.py +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/vendor/_appmap/wrapt/decorators.py +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/vendor/_appmap/wrapt/importer.py +0 -0
- {appmap-1.22.0 → appmap-1.23.0}/vendor/_appmap/wrapt/wrappers.py +0 -0
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
from . import configuration
|
|
1
|
+
from . import configuration, event, importer, metadata, recorder, recording, web_framework
|
|
2
2
|
from . import env as appmapenv
|
|
3
|
-
from . import event, importer, metadata, recorder, recording, web_framework
|
|
4
3
|
from .py_version_check import check_py_version
|
|
5
4
|
|
|
6
5
|
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Manage Configuration AppMap recorder for Python.
|
|
3
3
|
"""
|
|
4
4
|
|
|
5
|
+
import ast
|
|
5
6
|
import importlib.metadata
|
|
6
7
|
import inspect
|
|
7
8
|
import os
|
|
@@ -14,6 +15,7 @@ import yaml
|
|
|
14
15
|
from yaml.parser import ParserError
|
|
15
16
|
|
|
16
17
|
from _appmap.labels import LabelSet
|
|
18
|
+
from _appmap.singleton import SingletonMeta
|
|
17
19
|
from appmap.labeling import presets as label_presets
|
|
18
20
|
|
|
19
21
|
from . import utils
|
|
@@ -124,25 +126,13 @@ def find_top_packages(rootdir):
|
|
|
124
126
|
|
|
125
127
|
return packages
|
|
126
128
|
|
|
129
|
+
class AppMapInvalidConfigException(Exception):
|
|
130
|
+
pass
|
|
127
131
|
|
|
128
|
-
class Config:
|
|
132
|
+
class Config(metaclass=SingletonMeta):
|
|
129
133
|
"""Singleton Config class"""
|
|
130
134
|
|
|
131
|
-
_instance = None
|
|
132
|
-
|
|
133
|
-
def __new__(cls):
|
|
134
|
-
if cls._instance is None:
|
|
135
|
-
logger.trace("Creating the Config object")
|
|
136
|
-
cls._instance = super(Config, cls).__new__(cls)
|
|
137
|
-
|
|
138
|
-
cls._instance._initialized = False
|
|
139
|
-
|
|
140
|
-
return cls._instance
|
|
141
|
-
|
|
142
135
|
def __init__(self):
|
|
143
|
-
if self._initialized:
|
|
144
|
-
return
|
|
145
|
-
|
|
146
136
|
self.file_present = False
|
|
147
137
|
self.file_valid = False
|
|
148
138
|
self.package_functions = {}
|
|
@@ -154,12 +144,6 @@ class Config:
|
|
|
154
144
|
if "labels" in self._config:
|
|
155
145
|
self.labels.append(self._config["labels"])
|
|
156
146
|
|
|
157
|
-
self._initialized = True
|
|
158
|
-
|
|
159
|
-
@classmethod
|
|
160
|
-
def initialize(cls):
|
|
161
|
-
cls._instance = None
|
|
162
|
-
|
|
163
147
|
@property
|
|
164
148
|
def name(self):
|
|
165
149
|
return self._config["name"]
|
|
@@ -198,7 +182,7 @@ class Config:
|
|
|
198
182
|
root_dir = Env.current.root_dir
|
|
199
183
|
return [{"path": p} for p in find_top_packages(root_dir)]
|
|
200
184
|
|
|
201
|
-
def _load_config(self):
|
|
185
|
+
def _load_config(self, show_warnings=False):
|
|
202
186
|
self._config = {"name": None, "packages": []}
|
|
203
187
|
|
|
204
188
|
# Only use a default config if the user hasn't specified a
|
|
@@ -211,7 +195,7 @@ class Config:
|
|
|
211
195
|
|
|
212
196
|
env = Env.current
|
|
213
197
|
config_dir = env.root_dir
|
|
214
|
-
|
|
198
|
+
|
|
215
199
|
path = _resolve_relative_to(Path(env_config_filename), Path(config_dir))
|
|
216
200
|
if not path.is_file():
|
|
217
201
|
# search config file in parent directories up to
|
|
@@ -240,6 +224,8 @@ class Config:
|
|
|
240
224
|
self._config["name"] = self.default_name
|
|
241
225
|
if "packages" not in self._config:
|
|
242
226
|
self._config["packages"] = self.default_packages
|
|
227
|
+
else:
|
|
228
|
+
self._drop_malformed_package_paths(show_warnings)
|
|
243
229
|
|
|
244
230
|
# Is appmap_dir specified?
|
|
245
231
|
appmap_dir = (
|
|
@@ -303,6 +289,43 @@ It will be created with this configuration:
|
|
|
303
289
|
|
|
304
290
|
self.package_functions.update(modules)
|
|
305
291
|
|
|
292
|
+
def _drop_malformed_package_paths(self, show_warnings):
|
|
293
|
+
invalid_items = []
|
|
294
|
+
for item in self._config["packages"]:
|
|
295
|
+
# it can be a "dist" entry
|
|
296
|
+
if "path" not in item:
|
|
297
|
+
continue
|
|
298
|
+
|
|
299
|
+
path = item.get("path")
|
|
300
|
+
if path is None:
|
|
301
|
+
if show_warnings:
|
|
302
|
+
logger.warning("Missing path value in configuration file.")
|
|
303
|
+
invalid_items.append(item)
|
|
304
|
+
continue
|
|
305
|
+
|
|
306
|
+
if not self._check_path_value(path):
|
|
307
|
+
has_separator = isinstance(path, str) and ('/' in path or '\\' in path)
|
|
308
|
+
if show_warnings:
|
|
309
|
+
logger.warning(
|
|
310
|
+
f"Malformed path value '{path}' in configuration file. "
|
|
311
|
+
"Path entries must be module names"
|
|
312
|
+
f"{' not directory paths' if has_separator else ''}.",
|
|
313
|
+
stack_info=False,
|
|
314
|
+
)
|
|
315
|
+
invalid_items.append(item)
|
|
316
|
+
continue
|
|
317
|
+
|
|
318
|
+
if len(invalid_items) > 0:
|
|
319
|
+
self._config["packages"] = [item for item in self._config["packages"]
|
|
320
|
+
if item not in invalid_items]
|
|
321
|
+
|
|
322
|
+
def _check_path_value(self, value):
|
|
323
|
+
try:
|
|
324
|
+
ast.parse(f"import {value}")
|
|
325
|
+
return True
|
|
326
|
+
except SyntaxError:
|
|
327
|
+
return False
|
|
328
|
+
|
|
306
329
|
|
|
307
330
|
def startswith(prefix, sequence):
|
|
308
331
|
"""
|
|
@@ -395,7 +418,7 @@ class MatcherFilter(Filter):
|
|
|
395
418
|
wrapped = getattr(filterable.obj, "_appmap_wrapped", None)
|
|
396
419
|
if wrapped is None:
|
|
397
420
|
logger.trace(" wrapping %s", filterable.fqname)
|
|
398
|
-
Config
|
|
421
|
+
Config.current.labels.apply(filterable)
|
|
399
422
|
ret = instrument(filterable)
|
|
400
423
|
if rule and rule.shallow:
|
|
401
424
|
setattr(ret, "_appmap_shallow", rule)
|
|
@@ -428,7 +451,7 @@ class ConfigFilter(MatcherFilter):
|
|
|
428
451
|
def __init__(self, *args, **kwargs):
|
|
429
452
|
matchers = []
|
|
430
453
|
if Env.current.enabled:
|
|
431
|
-
matchers = [matcher_of_config(p) for p in Config
|
|
454
|
+
matchers = [matcher_of_config(p) for p in Config.current.packages]
|
|
432
455
|
super().__init__(matchers, *args, **kwargs)
|
|
433
456
|
|
|
434
457
|
|
|
@@ -441,14 +464,15 @@ class BuiltinFilter(MatcherFilter):
|
|
|
441
464
|
|
|
442
465
|
|
|
443
466
|
def initialize():
|
|
444
|
-
Config
|
|
467
|
+
Config.reset()
|
|
445
468
|
Importer.use_filter(BuiltinFilter)
|
|
446
469
|
Importer.use_filter(ConfigFilter)
|
|
447
470
|
|
|
448
471
|
|
|
449
472
|
initialize()
|
|
450
473
|
|
|
451
|
-
c = Config
|
|
474
|
+
c = Config.current
|
|
475
|
+
c._load_config(show_warnings=True)
|
|
452
476
|
logger.info("config: %s", c._config)
|
|
453
477
|
logger.debug("package_functions: %s", c.package_functions)
|
|
454
478
|
logger.info("env: %r", os.environ)
|
|
@@ -10,6 +10,8 @@ from os import environ
|
|
|
10
10
|
from pathlib import Path
|
|
11
11
|
from typing import cast
|
|
12
12
|
|
|
13
|
+
from _appmap.singleton import SingletonMeta
|
|
14
|
+
|
|
13
15
|
from . import trace_logger
|
|
14
16
|
|
|
15
17
|
_ENABLED_BY_DEFAULT_MSG = """
|
|
@@ -34,23 +36,7 @@ def _recording_method_key(recording_method):
|
|
|
34
36
|
return f"APPMAP_RECORD_{recording_method.upper()}"
|
|
35
37
|
|
|
36
38
|
|
|
37
|
-
class
|
|
38
|
-
def __init__(cls, *args, **kwargs):
|
|
39
|
-
type.__init__(cls, *args, **kwargs)
|
|
40
|
-
cls._instance = None
|
|
41
|
-
|
|
42
|
-
@property
|
|
43
|
-
def current(cls):
|
|
44
|
-
if not cls._instance:
|
|
45
|
-
cls._instance = Env()
|
|
46
|
-
|
|
47
|
-
return cls._instance
|
|
48
|
-
|
|
49
|
-
def reset(cls, **kwargs):
|
|
50
|
-
cls._instance = Env(**kwargs)
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
class Env(metaclass=_EnvMeta):
|
|
39
|
+
class Env(metaclass=SingletonMeta):
|
|
54
40
|
def __init__(self, env=None, cwd=None):
|
|
55
41
|
warnings.filterwarnings("once", _ENABLED_BY_DEFAULT_MSG)
|
|
56
42
|
|
|
@@ -189,7 +189,7 @@ class Importer:
|
|
|
189
189
|
# Import Config here, to avoid circular top-level imports.
|
|
190
190
|
from .configuration import Config # pylint: disable=import-outside-toplevel
|
|
191
191
|
|
|
192
|
-
package_functions = Config
|
|
192
|
+
package_functions = Config.current.package_functions
|
|
193
193
|
fm = FilterableMod(mod)
|
|
194
194
|
if fm.fqname in package_functions:
|
|
195
195
|
instrument_functions(fm, package_functions.get(fm.fqname))
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
class SingletonMeta(type):
|
|
2
|
+
def __init__(cls, *args, **kwargs):
|
|
3
|
+
type.__init__(cls, *args, **kwargs)
|
|
4
|
+
cls._instance = None
|
|
5
|
+
|
|
6
|
+
@property
|
|
7
|
+
def current(cls):
|
|
8
|
+
if not cls._instance:
|
|
9
|
+
cls._instance = cls()
|
|
10
|
+
|
|
11
|
+
return cls._instance
|
|
12
|
+
|
|
13
|
+
def reset(cls, **kwargs):
|
|
14
|
+
cls._instance = cls(**kwargs)
|
|
@@ -26,7 +26,7 @@ def test_can_be_configured():
|
|
|
26
26
|
"""
|
|
27
27
|
assert appmap.enabled()
|
|
28
28
|
|
|
29
|
-
c = Config
|
|
29
|
+
c = Config.current
|
|
30
30
|
assert c.file_present
|
|
31
31
|
assert c.file_valid
|
|
32
32
|
|
|
@@ -38,7 +38,7 @@ def test_reports_invalid():
|
|
|
38
38
|
indicates that the config is not valid.
|
|
39
39
|
"""
|
|
40
40
|
assert not appmap.enabled()
|
|
41
|
-
assert not Config
|
|
41
|
+
assert not Config.current.file_valid
|
|
42
42
|
|
|
43
43
|
|
|
44
44
|
@pytest.mark.appmap_enabled(config="appmap-broken.yml")
|
|
@@ -62,9 +62,9 @@ def test_config_not_found(caplog):
|
|
|
62
62
|
"APPMAP_CONFIG": "notfound.yml",
|
|
63
63
|
}
|
|
64
64
|
)
|
|
65
|
-
assert Config
|
|
66
|
-
assert not Config
|
|
67
|
-
assert not Config
|
|
65
|
+
assert Config.current.name is None
|
|
66
|
+
assert not Config.current.file_present
|
|
67
|
+
assert not Config.current.file_valid
|
|
68
68
|
|
|
69
69
|
assert not appmap.enabled()
|
|
70
70
|
not_found = Path("notfound.yml").resolve()
|
|
@@ -80,7 +80,7 @@ def test_config_no_message(caplog):
|
|
|
80
80
|
"""
|
|
81
81
|
|
|
82
82
|
assert not appmap.enabled()
|
|
83
|
-
assert Config
|
|
83
|
+
assert Config.current.name is None
|
|
84
84
|
assert caplog.text == ""
|
|
85
85
|
|
|
86
86
|
|
|
@@ -120,6 +120,27 @@ class TestConfiguration:
|
|
|
120
120
|
f = Filterable(None, "package1_prefix.cls", None)
|
|
121
121
|
assert cf().filter(f) is False
|
|
122
122
|
|
|
123
|
+
def test_malformed_path(self, data_dir, caplog):
|
|
124
|
+
_appmap.initialize(env={"APPMAP_CONFIG": "appmap-malformed-path.yml"}, cwd=data_dir)
|
|
125
|
+
Config.current._load_config(show_warnings=True)
|
|
126
|
+
assert (
|
|
127
|
+
"Malformed path value 'package1/package2/Mod1Class' in configuration file. "
|
|
128
|
+
"Path entries must be module names not directory paths."
|
|
129
|
+
in caplog.text
|
|
130
|
+
)
|
|
131
|
+
|
|
132
|
+
def test_all_paths_malformed(self, data_dir):
|
|
133
|
+
_appmap.initialize(env={"APPMAP_CONFIG": "appmap-all-paths-malformed.yml"}, cwd=data_dir)
|
|
134
|
+
assert len(Config().packages) == 0
|
|
135
|
+
|
|
136
|
+
def test_empty_path(self, data_dir, caplog):
|
|
137
|
+
_appmap.initialize(env={"APPMAP_CONFIG": "appmap-empty-path.yml"}, cwd=data_dir)
|
|
138
|
+
Config.current._load_config(show_warnings=True)
|
|
139
|
+
assert (
|
|
140
|
+
"Missing path value in configuration file."
|
|
141
|
+
in caplog.text
|
|
142
|
+
)
|
|
143
|
+
|
|
123
144
|
|
|
124
145
|
class DefaultHelpers:
|
|
125
146
|
def check_default_packages(self, actual_packages):
|
|
@@ -129,7 +150,7 @@ class DefaultHelpers:
|
|
|
129
150
|
def check_default_config(self, expected_name):
|
|
130
151
|
assert appmap.enabled()
|
|
131
152
|
|
|
132
|
-
default_config = Config
|
|
153
|
+
default_config = Config.current
|
|
133
154
|
assert default_config.name == expected_name
|
|
134
155
|
self.check_default_packages(default_config.packages)
|
|
135
156
|
assert default_config.default["appmap_dir"] == "tmp/appmap"
|
|
@@ -160,7 +181,7 @@ class TestDefaultConfig(DefaultHelpers):
|
|
|
160
181
|
"APPMAP_CONFIG": "/tmp/appmap.yml",
|
|
161
182
|
}
|
|
162
183
|
)
|
|
163
|
-
assert not Config
|
|
184
|
+
assert not Config.current.name
|
|
164
185
|
assert not appmap.enabled()
|
|
165
186
|
|
|
166
187
|
def test_exclusions(self, data_dir, tmpdir, mocker, monkeypatch):
|
|
@@ -186,7 +207,7 @@ class TestDefaultConfig(DefaultHelpers):
|
|
|
186
207
|
# pylint: disable=protected-access
|
|
187
208
|
_appmap.initialize(cwd=repo_root)
|
|
188
209
|
|
|
189
|
-
Config
|
|
210
|
+
Config.current # write the file as a side-effect
|
|
190
211
|
assert path.is_file()
|
|
191
212
|
with open(path, encoding="utf-8") as cfg:
|
|
192
213
|
actual_config = yaml.safe_load(cfg)
|
|
@@ -206,7 +227,7 @@ class TestDefaultConfig(DefaultHelpers):
|
|
|
206
227
|
# pylint: disable=protected-access
|
|
207
228
|
_appmap.initialize(cwd=repo_root, env={"_APPMAP": "false"})
|
|
208
229
|
|
|
209
|
-
c = Config
|
|
230
|
+
c = Config.current
|
|
210
231
|
assert not path.is_file()
|
|
211
232
|
|
|
212
233
|
|
|
@@ -257,7 +278,7 @@ class TestSearchConfig:
|
|
|
257
278
|
|
|
258
279
|
# pylint: disable=protected-access
|
|
259
280
|
_appmap.initialize(cwd=project_root)
|
|
260
|
-
assert Config
|
|
281
|
+
assert Config.current.name == "config-up-name"
|
|
261
282
|
assert str(Env.current.output_dir).endswith(str(tmpdir / "tmp" / "appmap"))
|
|
262
283
|
|
|
263
284
|
def test_config_not_found_until_repo_root(self, data_dir, tmpdir, git_directory, monkeypatch):
|
|
@@ -272,7 +293,7 @@ class TestSearchConfig:
|
|
|
272
293
|
# It should stop searching at repo_root.
|
|
273
294
|
# Check that it did not find appmap.yml
|
|
274
295
|
# in config-up folder.
|
|
275
|
-
assert Config
|
|
296
|
+
assert Config.current.name != "config-up-name"
|
|
276
297
|
# It should go on with default config
|
|
277
298
|
assert Env.current.enabled
|
|
278
299
|
|
|
@@ -286,6 +307,6 @@ class TestSearchConfig:
|
|
|
286
307
|
cwd=project_root,
|
|
287
308
|
env={"APPMAP_CONFIG": "notfound.yml"},
|
|
288
309
|
)
|
|
289
|
-
Config
|
|
310
|
+
Config.current
|
|
290
311
|
# No default config since we specified APPMAP_CONFIG
|
|
291
312
|
assert not Env.current.enabled
|
|
@@ -10,6 +10,7 @@ from sqlalchemy import (
|
|
|
10
10
|
MetaData,
|
|
11
11
|
String,
|
|
12
12
|
Table,
|
|
13
|
+
text,
|
|
13
14
|
create_engine,
|
|
14
15
|
)
|
|
15
16
|
|
|
@@ -23,7 +24,10 @@ from .appmap_test_base import AppMapTestBase
|
|
|
23
24
|
class TestSQLAlchemy(AppMapTestBase):
|
|
24
25
|
@staticmethod
|
|
25
26
|
def test_sql_capture(connection, events):
|
|
26
|
-
|
|
27
|
+
# Passing a string to execute is deprecated in 1.4
|
|
28
|
+
# and removed in 2.0. We wrap it with text().
|
|
29
|
+
# https://docs.sqlalchemy.org/en/14/core/connections.html#sqlalchemy.engine.Connection.execute
|
|
30
|
+
connection.execute(text("SELECT 1"))
|
|
27
31
|
assert events[0].sql_query == DictIncluding(
|
|
28
32
|
{"sql": "SELECT 1", "database_type": "sqlite"}
|
|
29
33
|
)
|
|
@@ -38,25 +42,27 @@ class TestSQLAlchemy(AppMapTestBase):
|
|
|
38
42
|
assert "CREATE TABLE addresses" in events[-2].sql_query["sql"]
|
|
39
43
|
|
|
40
44
|
# pylint: disable=unused-argument
|
|
41
|
-
def test_capture_insert(self,
|
|
45
|
+
def test_capture_insert(self, engine, schema, events):
|
|
42
46
|
ins = self.users.insert().values(name="jack", fullname="Jack Jones")
|
|
43
|
-
|
|
47
|
+
with engine.begin() as conn:
|
|
48
|
+
conn.execute(ins)
|
|
44
49
|
assert (
|
|
45
50
|
events[-2].sql_query["sql"]
|
|
46
51
|
== "INSERT INTO users (name, fullname) VALUES (?, ?)"
|
|
47
52
|
)
|
|
48
53
|
|
|
49
54
|
# pylint: disable=unused-argument
|
|
50
|
-
def test_capture_insert_many(self,
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
55
|
+
def test_capture_insert_many(self, engine, schema, events):
|
|
56
|
+
with engine.begin() as conn:
|
|
57
|
+
conn.execute(
|
|
58
|
+
self.addresses.insert(),
|
|
59
|
+
[
|
|
60
|
+
{"user_id": 1, "email_address": "jack@yahoo.com"},
|
|
61
|
+
{"user_id": 1, "email_address": "jack@msn.com"},
|
|
62
|
+
{"user_id": 2, "email_address": "www@www.org"},
|
|
63
|
+
{"user_id": 2, "email_address": "wendy@aol.com"},
|
|
64
|
+
],
|
|
65
|
+
)
|
|
60
66
|
assert (
|
|
61
67
|
events[-2].sql_query["sql"]
|
|
62
68
|
== "-- 4 times\nINSERT INTO addresses (user_id, email_address) VALUES (?, ?)"
|
|
@@ -106,7 +106,7 @@ class session: # pylint: disable=too-few-public-methods
|
|
|
106
106
|
metadata = item.metadata
|
|
107
107
|
metadata.update(
|
|
108
108
|
{
|
|
109
|
-
"app": configuration.Config
|
|
109
|
+
"app": configuration.Config.current.name,
|
|
110
110
|
"recorder": {
|
|
111
111
|
"name": self.name,
|
|
112
112
|
"type": self.recorder_type,
|
|
@@ -15,7 +15,7 @@ from _appmap.recorder import Recorder
|
|
|
15
15
|
@event.listens_for(Engine, "before_cursor_execute")
|
|
16
16
|
# pylint: disable=too-many-arguments,unused-argument
|
|
17
17
|
def capture_sql_call(conn, cursor, statement, parameters, context, executemany):
|
|
18
|
-
"""Capture SQL query
|
|
18
|
+
"""Capture SQL query call into appmap."""
|
|
19
19
|
if is_instrumentation_disabled():
|
|
20
20
|
# We must be in the middle of fetching object representation.
|
|
21
21
|
# Don't record this query in the appmap.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "appmap"
|
|
3
|
-
version = "1.
|
|
3
|
+
version = "1.23.0"
|
|
4
4
|
description = "Create AppMap files by recording a Python application."
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
authors = [
|
|
@@ -51,7 +51,6 @@ packaging = ">=19.0"
|
|
|
51
51
|
# install it and the rest of the dev dependencies.
|
|
52
52
|
|
|
53
53
|
[tool.poetry.group.dev.dependencies]
|
|
54
|
-
SQLAlchemy = "^1.4.11"
|
|
55
54
|
Twisted = "^22.4.0"
|
|
56
55
|
asgiref = "^3.7.2"
|
|
57
56
|
black = "^24.2.0"
|
|
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
|
{appmap-1.22.0 → appmap-1.23.0}/_appmap/test/data/config-exclude/.hide/hidden_mod/__init__.py
RENAMED
|
File without changes
|
{appmap-1.22.0 → appmap-1.23.0}/_appmap/test/data/config-exclude/node_modules/node_mod/__init__.py
RENAMED
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{appmap-1.22.0 → appmap-1.23.0}/_appmap/test/data/pytest/expected/status_errored.metadata.json
RENAMED
|
File without changes
|
{appmap-1.22.0 → appmap-1.23.0}/_appmap/test/data/pytest/expected/status_failed.metadata.json
RENAMED
|
File without changes
|
{appmap-1.22.0 → appmap-1.23.0}/_appmap/test/data/pytest/expected/status_xfailed.metadata.json
RENAMED
|
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
|
{appmap-1.22.0 → appmap-1.23.0}/_appmap/test/data/unittest/expected/status_errored.metadata.json
RENAMED
|
File without changes
|
{appmap-1.22.0 → appmap-1.23.0}/_appmap/test/data/unittest/expected/status_failed.metadata.json
RENAMED
|
File without changes
|
{appmap-1.22.0 → appmap-1.23.0}/_appmap/test/data/unittest/expected/status_xfailed.metadata.json
RENAMED
|
File without changes
|
{appmap-1.22.0 → appmap-1.23.0}/_appmap/test/data/unittest/expected/status_xsucceeded.metadata.json
RENAMED
|
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
|
|
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
|