Add PREFECT_CLIENT_EMIT_EVENTS setting to disable client-side event emission#21032
Open
zionts wants to merge 1 commit intoPrefectHQ:mainfrom
Open
Add PREFECT_CLIENT_EMIT_EVENTS setting to disable client-side event emission#21032zionts wants to merge 1 commit intoPrefectHQ:mainfrom
zionts wants to merge 1 commit intoPrefectHQ:mainfrom
Conversation
…mission Adds a new `client.emit_events` boolean setting (env var `PREFECT_CLIENT_EMIT_EVENTS`) that controls whether the client emits events to the Prefect server. Defaults to `True` (no behavior change). When set to `False`, `should_emit_events()` short-circuits and returns `False` before checking API URL/key configuration, preventing any events from being created or queued. This is useful for long-running flows that don't rely on event-driven features (automations, triggers) and want to reduce memory usage from the EventsWorker queue. Closes PrefectHQ#21030
desertaxle
requested changes
Mar 9, 2026
Member
desertaxle
left a comment
There was a problem hiding this comment.
This is a PR that we likely won't accept because large portions of Prefect rely on events being emitted client-side. In particular, task state changes are reported via events, so there would be no task observability with events turned off.
It seems this PR is motivated by other issues you were having with event emission, so let's see if we can find a different way to address them.
This was referenced Mar 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #21030
Summary
Adds a
PREFECT_CLIENT_EMIT_EVENTSboolean setting that controls whether the client emits events to the Prefect server. Defaults toTrue(no behavior change).Currently,
should_emit_events()is hardcoded to returnTruewheneverPREFECT_API_URLis set — there's no way to disable client-side event emission via configuration. This PR adds a clean opt-out for deployments that don't use event-driven features (automations, triggers).Changes
src/prefect/settings/models/client.py— newemit_eventsfield onClientSettingswith env varPREFECT_CLIENT_EMIT_EVENTSsrc/prefect/events/worker.py—should_emit_events()checks the setting first, short-circuiting before API URL/key checkstests/events/client/test_emit_events_setting.py— 5 tests covering default behavior, override, and interaction with cloud configtests/test_settings.py— added to parametrized settings validationUsage
export PREFECT_CLIENT_EMIT_EVENTS=falseOr in Python:
Checklist
True)