Skip to content

[receiver/postgresql] collect query samples only after the newest query sample #40622

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

Merged

Conversation

cuichenli
Copy link
Contributor

Description

the current implementation scrape query samples from all the time, which is not very efficiency. this pr changes it to only scrape the query that is newer than the previous oldest query.

Link to tracking issue

Fixes

Testing

Documentation

@cuichenli cuichenli requested a review from a team as a code owner June 11, 2025 01:23
@cuichenli cuichenli requested a review from songy23 June 11, 2025 01:23
@atoulme
Copy link
Contributor

atoulme commented Jun 16, 2025

@antonblock please review as codeowner

@antonblock
Copy link
Contributor

@cuichenli Could you please merge/rebase to resolve the conflicts?

…tor-contrib into only-query-after-last-result
@github-actions github-actions bot requested a review from antonblock June 24, 2025 03:01
@cuichenli
Copy link
Contributor Author

@cuichenli Could you please merge/rebase to resolve the conflicts?

updated

@github-actions github-actions bot requested a review from ishleenk17 June 25, 2025 08:39
Copy link
Contributor

@sincejune sincejune left a comment

Choose a reason for hiding this comment

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

Actually, I'm wondering if this is the correct thing to do. The query sample collection should collect the current activities, right? even if it has been running for a long time. In this assumption, I think probably duplicated events are expected?

@cuichenli
Copy link
Contributor Author

The query sample collection should collect the current activities, right? even if it has been running for a long time. In this assumption, I think probably duplicated events are expected?

Yes that is correct, but not what this PR tries to achieve. It is to address that in certain cases we have some idle sessions, those should not be included in the query sample.

query_id bigint
Identifier of this backend's most recent query. If state is active this field shows the identifier of the currently executing query. In all other states, it shows the identifier of last query that was executed.

https://www.postgresql.org/docs/current/monitoring-stats.html#MONITORING-PG-STAT-ACTIVITY-VIEW

@andrzej-stencel andrzej-stencel added ready to merge Code review completed; ready to merge by maintainers and removed waiting-for-code-owners labels Jul 8, 2025
@andrzej-stencel andrzej-stencel merged commit e0a025f into open-telemetry:main Jul 8, 2025
191 of 196 checks passed
@github-actions github-actions bot added this to the next release milestone Jul 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready to merge Code review completed; ready to merge by maintainers receiver/postgresql
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants