Skip to content

database_observability: Always log an explain_plan_output for each query, showing status and reason.#4969

Merged
rgeyer merged 11 commits intomainfrom
rgeyer/dbo11y/explain-always-report
Dec 3, 2025
Merged

database_observability: Always log an explain_plan_output for each query, showing status and reason.#4969
rgeyer merged 11 commits intomainfrom
rgeyer/dbo11y/explain-always-report

Conversation

@rgeyer
Copy link
Contributor

@rgeyer rgeyer commented Dec 1, 2025

PR Description

This ensures that there is always a log message emitted for each query from the explain plan collector, no matter what the outcome of that explain plan collection was.

This can be used to inform the UI when a query was skipped because it contained a reserved word, for example.

Which issue(s) this PR fixes

Resolves grafana/grafana-dbo11y-app#1735

PR Checklist

  • CHANGELOG.md updated
  • Tests updated

@rgeyer rgeyer requested a review from a team as a code owner December 1, 2025 21:14
Warning *string `json:"warning,omitempty"`
}

func ExtractExplainPlanOutputFromLogMsg(lokiEntry loki.Entry) (ExplainPlanOutput, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is used only for testing, maybe could be moved to a shared _test.go file, or we could add a comment that says it's here just for testing.

@rgeyer rgeyer requested a review from cristiangreco December 3, 2025 01:32
}

return output, nil
return &planNode, nil
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that this method has been cut down a lot, perhaps we could just return parseTopLevelPlanNode(logger, qblock)?

@rgeyer rgeyer requested a review from a team as a code owner December 3, 2025 18:55
@rgeyer rgeyer merged commit 03a5a20 into main Dec 3, 2025
42 checks passed
@rgeyer rgeyer deleted the rgeyer/dbo11y/explain-always-report branch December 3, 2025 19:15
dehaansa pushed a commit to madhub/alloy that referenced this pull request Dec 10, 2025
…ery, showing status and reason. (grafana#4969)

* Expand the explain plan output struct

* Add extended explain plan output metadata for mysql explain plan collector

* Move explain plan output logfmt parser to shared package.
Add extended explain plan output metadata for postgres explain plan collector.

* Linting, as usual

* Fix botched main merge
Refactor sending explain_plan_output

* Make the purpose of database_observability.ExtractExplainPlanOutputFromLogMsg more apparent

* Linting, but it was actually catching some of my bad refactoring

* Not necessary to check an error state before returning an err (or nil)

* Add changelog update
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 18, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants