-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Elapsed and timestamp values are not available to filename_format function #2775
Milestone
Comments
joshwilson-dbx
added a commit
to joshwilson-dbx/werkzeug
that referenced
this issue
Aug 31, 2023
This allows one to provide a `filename_format()` function to `ProfileMiddleware` that receives as much info as is provided to the format string option. Prior to this change, one could not replicate the format string format, much less modify how it would render the timestamp or elapsed time values. Addresses pallets#2775
joshwilson-dbx
added a commit
to joshwilson-dbx/werkzeug
that referenced
this issue
Aug 31, 2023
This allows one to provide a `filename_format()` function to `ProfileMiddleware` that receives as much info as is provided to the format string option. Prior to this change, one could not replicate the format string format, much less modify how it would render the timestamp or elapsed time values. Addresses pallets#2775
6 tasks
joshwilson-dbx
added a commit
to joshwilson-dbx/werkzeug
that referenced
this issue
Sep 20, 2023
This provides the `elapsed` and `time` values to the `ProfileMiddleware(filename_format=...)` function. Prior to this change, one could not replicate the format string format, much less modify how it would render the timestamp or elapsed time values. These new values can be found under the `werkzeug.profiler` key in the WSGI environ dict passed into the `filename_format()` function. Addresses pallets#2775
I think I addressed all the comments and concerns on that PR. Let me know if you'd like any further changes! |
pgjones
pushed a commit
that referenced
this issue
Sep 24, 2023
This provides the `elapsed` and `time` values to the `ProfileMiddleware(filename_format=...)` function. Prior to this change, one could not replicate the format string format, much less modify how it would render the timestamp or elapsed time values. These new values can be found under the `werkzeug.profiler` key in the WSGI environ dict passed into the `filename_format()` function. Addresses #2775
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
When the
ProfilerMiddleware
filename_format
argument is a callable, the callable will only receive the WSGI environ variable. However, the default format string can use theelapsed
andtime
values. This means that one using a format function cannot recreate a similar output pattern. In my case, I'd like to use both, but format the timestamp differently.Example: I'd like a filename of the form
2023-08-21:14:05:05.POST.myurl.13ms.prof
. I can get the timestamp by doing my owndatetime.now()
call, but the elapsed time is not available.This problem is solvable by subclassing
ProfilerMiddleware
or writing ones own profiling middleware, but this seems like a useful thing to have in the core library so library users don't need to duplicate the__call__()
code in their own projects.I can submit a PR if this change is welcome.
The text was updated successfully, but these errors were encountered: