Skip to content

[receiver/postgresql] Update explainQuery client method to also include context#49472

Draft
kartikgola wants to merge 7 commits into
open-telemetry:mainfrom
kartikgola:fix-postgresql-explain-context
Draft

[receiver/postgresql] Update explainQuery client method to also include context#49472
kartikgola wants to merge 7 commits into
open-telemetry:mainfrom
kartikgola:fix-postgresql-explain-context

Conversation

@kartikgola

@kartikgola kartikgola commented Jul 5, 2026

Copy link
Copy Markdown

Description

Noticed this issue (while working on #49352) where explainQuery API in client.go doesn't take in context unlike the rest of the interface functions, and uses background context instead.
This can be problematic since if the context is cancelled, the explainQuery API will not honor it and could keep on going. Some problems that can arise -

  1. EXPLAIN query would ignore the scrape timeouts and cancellations
  2. Collector shutdown won't be honored by the receiver
  3. Breaks client interface established conventions
    As part of the fix, I added the context back in the API and updated the function.

There's a small caveat with DEALLOCATE PREPARE though; In the original code it was using global context and was unbounded, I have now added it with a timed out context since DEALLOCATE PREPARE must be called even if the parent context is cancelled to stop polluting the shared connection pool.

Testing

Unit tests

Documentation

N/A

Authorship

  • I, a human, wrote this pull request description myself.

@github-actions github-actions Bot added the first-time contributor PRs made by new contributors label Jul 5, 2026
@github-actions

github-actions Bot commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Welcome, contributor! Thank you for your contribution to opentelemetry-collector-contrib.

Important reminders:

  • Read our Contributing Guidelines.
  • Sign the CLA if you haven't already.
  • First-time contributors should have at most one PR not marked as draft until their first PR is merged.
  • If your change isn't one of our priority components, reviews may take more time.
  • Give reviewers at least a few days before pinging them for feedback.
  • If you need help or struggle to move your PR forward:

@kartikgola kartikgola marked this pull request as ready for review July 5, 2026 06:34
@kartikgola kartikgola requested a review from a team as a code owner July 5, 2026 06:34
@kartikgola kartikgola requested a review from codeboten July 5, 2026 06:34
@kartikgola kartikgola marked this pull request as draft July 5, 2026 06:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant