comparison roundup/cgi/wsgi_handler.py @ 8487:b09ef85f0da6

feat: add nanoid pkg trace_id gen and decorator for setting processName nanoid is a shorter unique id generator and faster than uuid. I truncate nanoid id's to 12 chars to make it more readable. Also added decorator to allow setting the default processName definition in the logging module. admin.py and wsgi_handler now set processName. configuration.py knows how to overide the processName if set to the default MainProcess. Updated install docs to add nanoid as optional, how to switch to different trace_id output. pydoc generated docs include logcontext module and are referenced from admin.py.
author John Rouillard <rouilj@ieee.org>
date Mon, 08 Dec 2025 00:23:14 -0500
parents 617d55f1d518
children f80c566f5726
comparison
equal deleted inserted replaced
8478:ed4ef394d5d6 8487:b09ef85f0da6
11 from roundup.anypy import http_ 11 from roundup.anypy import http_
12 from roundup.anypy.html import html_escape 12 from roundup.anypy.html import html_escape
13 from roundup.anypy.strings import s2b 13 from roundup.anypy.strings import s2b
14 from roundup.cgi import TranslationService 14 from roundup.cgi import TranslationService
15 from roundup.cgi.client import BinaryFieldStorage 15 from roundup.cgi.client import BinaryFieldStorage
16 from roundup.logcontext import gen_trace_id, store_trace_reason 16 from roundup.logcontext import gen_trace_id, set_processName, store_trace_reason
17 17
18 BaseHTTPRequestHandler = http_.server.BaseHTTPRequestHandler 18 BaseHTTPRequestHandler = http_.server.BaseHTTPRequestHandler
19 DEFAULT_ERROR_MESSAGE = http_.server.DEFAULT_ERROR_MESSAGE 19 DEFAULT_ERROR_MESSAGE = http_.server.DEFAULT_ERROR_MESSAGE
20 20
21 try: 21 try:
105 def use_cached_tracker(self): 105 def use_cached_tracker(self):
106 return ( 106 return (
107 "cache_tracker" not in self.feature_flags or 107 "cache_tracker" not in self.feature_flags or
108 self.feature_flags["cache_tracker"] is not False) 108 self.feature_flags["cache_tracker"] is not False)
109 109
110 @set_processName("wsgi_handler")
110 @gen_trace_id() 111 @gen_trace_id()
111 @store_trace_reason("wsgi") 112 @store_trace_reason("wsgi")
112 def __call__(self, environ, start_response): 113 def __call__(self, environ, start_response):
113 """Initialize with `apache.Request` object""" 114 """Initialize with `apache.Request` object"""
114 request = RequestHandler(environ, start_response) 115 request = RequestHandler(environ, start_response)

Roundup Issue Tracker: http://roundup-tracker.org/