Skip to content
This repository has been archived by the owner on Nov 10, 2024. It is now read-only.

[FEATURE] Support alternate output for timing middleware #252

Open
julyvee opened this issue Dec 14, 2023 · 1 comment
Open

[FEATURE] Support alternate output for timing middleware #252

julyvee opened this issue Dec 14, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@julyvee
Copy link

julyvee commented Dec 14, 2023

Is your feature request related to a problem? Please describe.
The timing middleware currently always outputs its information as a string, which is supposed to be logged for example. You can define any method that takes a string argument as the callable. But in my case I want to send the timing information to a metrics server and I have to write custom logic to parse this timing information out of the formatted string.

Describe the solution you'd like
I would like alternate options for outputs, for example a data class containing all the timing information and then I would specify a callable which takes this class as an argument.

Describe alternatives you've considered
Alternatively, a string output but in JSON format would be more easily parsable.

Additional context
The JSON format string and support for self defined message formatters was actually already implemented in the original repository, but the PR never got merged: fastapiutils#141

@julyvee julyvee added the enhancement New feature or request label Dec 14, 2023
@yuval9313
Copy link
Owner

Hey, I mostly agree with this solution. However, I wish the "formatting" would be extendable, which is not something doable in the current state

I wish I could integrate third-party tools, like otel, perhaps in those timers and not just change the way it's being parsed

This might be a little oos for your proposed feature but I want to have some time with the way this Middleware behaves optionally, avoiding BaseHTTPMiddleware upcoming depreciation

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants