-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[RFC] Add a way to disable logging and profiler at runtime #60037
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
Comments
i tend to agree on this for both profiler/logger just for profiling at runtime in dev, how will it be different from https://symfony.com/doc/current/profiler.html#enabling-the-profiler-conditionally ? |
|
Disabling the profiler from collecting data does not directly impact all the traceable decorator services (it will only disabling the fact that we call The same is true for the logger: it will require a feature in the logger implementation itself to make it a no-op. |
Should be fixed by #60243 |
This PR was merged into the 7.3 branch. Discussion ---------- [HttpClient] Improve memory consumption | Q | A | ------------- | --- | Branch? | 7.3 | Bug fix? | no | New feature? | no | Deprecations? | no | Issues | Partially #60037 | License | MIT On the CLI, even if the profiler is not enabled by default, the underlying infrastructure is still in place. In this PR, I'm targeting TraceableHttpClient, which collects requests and responses for nothing. To fix this, I'm adding an "enabled" flag on TraceableHttpClient, so that we can enable the tracing only when the profiler is enabled. In addition, I'm augmenting option `extra.trace_content` so that when disabled, we don't collect request's bodies, which can be huge when uploading. And last but not least, I'm fixing the implementation of curl's debug info collection, which currently relies on allocating new strings all the time instead of reusing the already created zval when debug info didn't change. Commits ------- 0e865e6 [HttpClient] Improve memory consumption
…er][Validator][Workflow] Don't enable tracing unless the profiler is enabled (nicolas-grekas) This PR was merged into the 7.3 branch. Discussion ---------- [Cache][EventDispatcher][HttpClient][HttpKernel][Messenger][Validator][Workflow] Don't enable tracing unless the profiler is enabled | Q | A | ------------- | --- | Branch? | 7.3 | Bug fix? | no | New feature? | no | Deprecations? | no | Issues | #60037 | License | MIT This PR ensures traceable decorators are enabled only if the profiler is also enabled. The way it works is by adding a new argument to all traceable decorators: `?\Closure $disabled`. When a closure is given and when the closure returns true, tracing should be skipped. Calling the closure should be done before every decorated method to cope for dynamically enabled/disabled states. Then, this argument is wired using dependency injection so that a closure is passed that returns the current state of the profiler. If the profiler is not instantiated yet (eg because we're on the CLI, or because we're before ProfilerListener enabled it), then a default state is used (disabled on the CLI, enabled on the web). This allows collecting data on the web even if the profiler didn't start yet (as happens when a request comes in, before ProfilerListener is triggered). Note that I didn't change all `Traceable*` decorators: the remaining ones look inoffensive to me. Of course, this could be wrong and fixed in follow up PRs. Commits ------- d5a3769 Don't enable tracing unless the profiler is enabled
…er][Validator][Workflow] Don't enable tracing unless the profiler is enabled (nicolas-grekas) This PR was merged into the 7.3 branch. Discussion ---------- [Cache][EventDispatcher][HttpClient][HttpKernel][Messenger][Validator][Workflow] Don't enable tracing unless the profiler is enabled | Q | A | ------------- | --- | Branch? | 7.3 | Bug fix? | no | New feature? | no | Deprecations? | no | Issues | symfony/symfony#60037 | License | MIT This PR ensures traceable decorators are enabled only if the profiler is also enabled. The way it works is by adding a new argument to all traceable decorators: `?\Closure $disabled`. When a closure is given and when the closure returns true, tracing should be skipped. Calling the closure should be done before every decorated method to cope for dynamically enabled/disabled states. Then, this argument is wired using dependency injection so that a closure is passed that returns the current state of the profiler. If the profiler is not instantiated yet (eg because we're on the CLI, or because we're before ProfilerListener enabled it), then a default state is used (disabled on the CLI, enabled on the web). This allows collecting data on the web even if the profiler didn't start yet (as happens when a request comes in, before ProfilerListener is triggered). Note that I didn't change all `Traceable*` decorators: the remaining ones look inoffensive to me. Of course, this could be wrong and fixed in follow up PRs. Commits ------- d5a3769bd05 Don't enable tracing unless the profiler is enabled
…er][Validator][Workflow] Don't enable tracing unless the profiler is enabled (nicolas-grekas) This PR was merged into the 7.3 branch. Discussion ---------- [Cache][EventDispatcher][HttpClient][HttpKernel][Messenger][Validator][Workflow] Don't enable tracing unless the profiler is enabled | Q | A | ------------- | --- | Branch? | 7.3 | Bug fix? | no | New feature? | no | Deprecations? | no | Issues | symfony/symfony#60037 | License | MIT This PR ensures traceable decorators are enabled only if the profiler is also enabled. The way it works is by adding a new argument to all traceable decorators: `?\Closure $disabled`. When a closure is given and when the closure returns true, tracing should be skipped. Calling the closure should be done before every decorated method to cope for dynamically enabled/disabled states. Then, this argument is wired using dependency injection so that a closure is passed that returns the current state of the profiler. If the profiler is not instantiated yet (eg because we're on the CLI, or because we're before ProfilerListener enabled it), then a default state is used (disabled on the CLI, enabled on the web). This allows collecting data on the web even if the profiler didn't start yet (as happens when a request comes in, before ProfilerListener is triggered). Note that I didn't change all `Traceable*` decorators: the remaining ones look inoffensive to me. Of course, this could be wrong and fixed in follow up PRs. Commits ------- d5a3769bd05 Don't enable tracing unless the profiler is enabled
Description
Problem
When I work on long running process I often face the same situation where
Symfony leaks. It usually does not happen in production, but in development it
is a real pain. I have already worked hard on Symfony to mitigate this issue,
but it is still there.
Now, I think the remaining pain point is the Profiler + Logger debug infrastructure.
To ease the debug, we store a lot of information in the profiler and in the
logs.
However, when the process runs for a long time, the profiler and the logs grow
and grow and grow. More over, we usually don't need all that information.
For example, when we import huge CSV, as a developer we does tons of SQL or
HTTP queries.
In the past, we used to "mute" the SQL logger :
But this does not work anymore since DBAL4. More over, Symfony still collect a
lof a data in the profiler.
There a some workarounds, but they are so not satisfying. And it makes me wonder
if Symfony can't do better.
Proposal
I think Symfony should provide a way to "mute" the profiler and the logger, programmatically.
So I think we could introduce a new interface and its implementation:
I think we need to make a difference between the logger and the profiler, because
we may want to disable one and not the other.
For example, in production we want to keep logs (since we usually have a buffer
with eviction) and in dev we want to remove everything.
Example
No response
The text was updated successfully, but these errors were encountered: