chore(database_observability): Use Fanout, Consume and Drain#5866
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR migrates database_observability (MySQL + Postgres) components to use the shared Loki pipeline helpers (Fanout, Consume, Drain, NewEntry) to reduce shutdown deadlocks and align with the repo’s evolving Loki pipeline architecture.
Changes:
- Replace manual receiver-forwarding loops with
loki.Fanout+loki.Consumein MySQL/PostgresRun. - Add
loki.Drain(..., loki.DefaultDrainTimeout, ...)to ensure logs are drained/forwarded while collectors stop during shutdown. - Switch
BuildLokiEntryWithTimestamptoloki.NewEntryto ensure entry “created” timestamps are set; update affected tests for the newfanoutfield.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| internal/component/database_observability/postgres/component.go | Use Fanout/Consume for forwarding and Drain during shutdown; add fanout field. |
| internal/component/database_observability/postgres/component_test.go | Update component construction to initialize fanout. |
| internal/component/database_observability/mysql/component.go | Use Fanout/Consume for forwarding and Drain during shutdown; add fanout field. |
| internal/component/database_observability/mysql/component_test.go | Update component construction to initialize fanout. |
| internal/component/database_observability/loki_entry.go | Build entries via loki.NewEntry to set internal created timestamp. |
kalleep
commented
Mar 24, 2026
| defer c.mut.Unlock() | ||
|
|
||
| c.args = args.(Arguments) | ||
| c.fanout.UpdateChildren(c.args.ForwardTo) |
Contributor
Author
There was a problem hiding this comment.
Before both of these components stored both args and receivers but never actually updated the second one. So if a config change was made with new receivers that would not work and we would keep sending logs to the old receiver list causing all kinds of problems.
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Pull Request Details
We have added some shared functionallity for working with loki pipelines and should use them in our
database_observability. This will make it easier in the future to start to migrate to new architecture for loki pipelines and avoid common pitfalls.I did not review all
collectorsbut just did a sample and e.g. explain_plan can cause a deadlock when component is stopping and in turn preventing alloy from stopping because nothing is consuming from handler.Changes:
LogsReceiverand will exit when context is canceled.createdtimestramp of entries so they can be properly tracked byloki_write_entry_propagation_latency_seconds.Issue(s) fixed by this Pull Request
Part of: #5826
Notes to the Reviewer
PR Checklist