hwmarkcheng commented on code in PR #26443:
URL: https://github.com/apache/superset/pull/26443#discussion_r1452737727


##########
superset/utils/decorators.py:
##########
@@ -61,6 +65,82 @@ def wrapped(*args: Any, **kwargs: Any) -> Any:
     return decorate
 
 
+def logs_context(
+    context_func: Callable[..., dict[Any, Any]] | None = None,
+    **ctx_kwargs: int | str | UUID | None,
+) -> Callable[..., Any]:
+    """
+    Takes arguments and adds them to the global logs_context.
+    This is for logging purposes only and values should not be relied on or 
mutated
+    """
+
+    def decorate(f: Callable[..., Any]) -> Callable[..., Any]:
+        def wrapped(*args: Any, **kwargs: Any) -> Any:
+            if not hasattr(g, "logs_context"):
+                g.logs_context = {}
+
+            # limit data that can be saved to logs_context
+            # in order to prevent antipatterns
+            available_logs_context_keys = [

Review Comment:
   Would it make sense for this to be a parameter? Right now this is hard coded 
for query related logging, but it might be useful for other logging purposes. 
   
   If we add the `available_logs_context_keys` as a parameter when the 
decorator is called we can still keep the functionality of limiting data but 
for that specific function.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to