diff --git a/acceptance_tests/out/tests/c2c-auth-dark.expected.png b/acceptance_tests/out/tests/c2c-auth-dark.expected.png index c63c985c6..04014c6c8 100644 Binary files a/acceptance_tests/out/tests/c2c-auth-dark.expected.png and b/acceptance_tests/out/tests/c2c-auth-dark.expected.png differ diff --git a/acceptance_tests/out/tests/c2c-auth.expected.png b/acceptance_tests/out/tests/c2c-auth.expected.png index 853d2e6f8..a2e4f2ba8 100644 Binary files a/acceptance_tests/out/tests/c2c-auth.expected.png and b/acceptance_tests/out/tests/c2c-auth.expected.png differ diff --git a/acceptance_tests/out/tests/c2c.expected.png b/acceptance_tests/out/tests/c2c.expected.png index 0e5eca170..541e4261c 100644 Binary files a/acceptance_tests/out/tests/c2c.expected.png and b/acceptance_tests/out/tests/c2c.expected.png differ diff --git a/acceptance_tests/out/tests/test_image_check.py b/acceptance_tests/out/tests/test_image_check.py index 0c2e8a7e5..c487a2e1e 100644 --- a/acceptance_tests/out/tests/test_image_check.py +++ b/acceptance_tests/out/tests/test_image_check.py @@ -12,14 +12,14 @@ pytest.param( "c2c-auth.expected.png", 650, - 2000, + 2500, {"X-API-Key": "changeme"}, [{"name": "prefers-color-scheme", "value": "light"}], ), pytest.param( "c2c-auth-dark.expected.png", 650, - 2000, + 2500, {"X-API-Key": "changeme"}, [ {"name": "prefers-color-scheme", "value": "dark"}, diff --git a/c2c-auth-dark.actual-masked.png b/c2c-auth-dark.actual-masked.png deleted file mode 100644 index c63c985c6..000000000 Binary files a/c2c-auth-dark.actual-masked.png and /dev/null differ diff --git a/c2c-auth.actual-masked.png b/c2c-auth.actual-masked.png deleted file mode 100644 index 853d2e6f8..000000000 Binary files a/c2c-auth.actual-masked.png and /dev/null differ diff --git a/c2c.actual-masked.png b/c2c.actual-masked.png deleted file mode 100644 index 0e5eca170..000000000 Binary files a/c2c.actual-masked.png and /dev/null differ diff --git a/c2cwsgiutils/debug/_listeners.py b/c2cwsgiutils/debug/_listeners.py index 1696806ac..771e15d37 100644 --- a/c2cwsgiutils/debug/_listeners.py +++ b/c2cwsgiutils/debug/_listeners.py @@ -68,12 +68,7 @@ def _dump_memory_impl( and not (FILES_FIELDS - set(obj["globals"].keys())) ): python_internal = True - if ( - python_internal - and not python_internals_map - or not python_internal - and python_internals_map - ): + if python_internal != python_internals_map: continue size = get_size(obj) / 1024 if len(biggest_objects) < limit or size > biggest_objects[0][0]: diff --git a/c2cwsgiutils/debug/_views.py b/c2cwsgiutils/debug/_views.py index 649a60735..904d8b933 100644 --- a/c2cwsgiutils/debug/_views.py +++ b/c2cwsgiutils/debug/_views.py @@ -47,7 +47,7 @@ def _dump_memory(request: pyramid.request.Request) -> list[Mapping[str, Any]]: auth.auth_view(request) limit = int(request.params.get("limit", "30")) analyze_type = request.params.get("analyze_type") - python_internals_map = request.params.get("python_internals_map", "0").lower() in ("", "1", "true", "on") + python_internals_map = request.params.get("python_internals_map", "0").lower() in ("1", "true", "on") result = broadcast.broadcast( "c2c_dump_memory", params={"limit": limit, "analyze_type": analyze_type, "python_internals_map": python_internals_map}, @@ -75,7 +75,7 @@ def _dump_memory_diff(request: pyramid.request.Request) -> list[Any]: # warm-up run try: - if "no_warmup" not in request.params: + if request.params.get("no_warmup", "0").lower() in ("1", "true", "on"): request.invoke_subrequest(sub_request) except Exception: # nosec # pylint: disable=broad-except pass diff --git a/c2cwsgiutils/index.py b/c2cwsgiutils/index.py index e0016c236..688f46cdc 100644 --- a/c2cwsgiutils/index.py +++ b/c2cwsgiutils/index.py @@ -122,8 +122,20 @@ def input_( if type_ is None: if isinstance(value, int): type_ = "number" + elif isinstance(value, bool): + type_ = "checkbox" else: type_ = "text" + if type_ == "checkbox": + checked = " checked" if value else "" + return f""" +
+ + +
""" + result = "" if label is not None: result += f'
' @@ -201,7 +213,7 @@ def _index(request: pyramid.request.Request) -> dict[str, str]: def _versions(request: pyramid.request.Request) -> str: versions_url = _url(request, "c2c_versions") if versions_url: - return section("Versions", paragraph(link(versions_url, "Get")), sep=False) + return section("Versions " + link(versions_url, "Get"), sep=False) else: return "" @@ -280,6 +292,7 @@ def _logging(request: pyramid.request.Request) -> str: def _debug(request: pyramid.request.Request) -> str: dump_memory_url = _url(request, "c2c_debug_memory") if dump_memory_url: + as_dot = 'as dot diagram, can be open with xdot' return section( " ".join( [ @@ -289,32 +302,42 @@ def _debug(request: pyramid.request.Request) -> str: link(_url(request, "c2c_debug_memory_maps"), "Mapped memory"), ] ), + '

Memory usage, with objgraph

', + "

Runs the garbage collector and dumps the memory usage as JSON.

", form( dump_memory_url, input_("limit", value=30), input_("analyze_type"), + input_("python_internals_map", type_="checkbox"), button("Dump memory usage"), ), + f"

Runs the garbage collector and dumps the memory refs {as_dot}.

", form( _url(request, "c2c_debug_show_refs"), input_("analyze_type", value="gunicorn.app.wsgiapp.WSGIApplication"), - input_("max_depth", value=3), - input_("too_many", value=10), + input_("analyze_id", type_="number"), + input_("max_depth", type_="number", value=3), + input_("too_many", type_="number", value=10), input_("min_size_kb", type_="number"), button("Object refs"), ), + "

Runs the garbage collector, query the path, runs the garbage collector again, get the memory diff as JSON.

", form( _url(request, "c2c_debug_memory_diff"), input_("path"), input_("limit", value=30), + input_("no_warmup", type_="checkbox"), button("Memory diff"), ), + "

Sleep

", form( _url(request, "c2c_debug_sleep"), input_("time", value=1), button("Sleep"), ), - form(_url(request, "c2c_debug_time"), button("Time")), + "

Server times

", + form(_url(request, "c2c_debug_time"), button("Get")), + "

HTTP error

", form( _url(request, "c2c_debug_error"), input_("status", value=500), diff --git a/c2cwsgiutils/templates/index.html.mako b/c2cwsgiutils/templates/index.html.mako index 3f6a46e78..a1c966462 100644 --- a/c2cwsgiutils/templates/index.html.mako +++ b/c2cwsgiutils/templates/index.html.mako @@ -24,7 +24,7 @@ crossorigin="anonymous" referrerpolicy="no-referrer" /> - c2cwsgiutils tools + C2C WSGI Utils tools