Skip to content

Conversation

@sv-splunk
Copy link
Contributor

@sv-splunk sv-splunk commented Nov 11, 2025

Description

Issue area -1
Based on current implementation the EffectiveLookbackTime is calculated as 2 x cfg.ControllerConfig.CollectionInterval which is wrong.

Below are the default values,

ControllerConfig's CollectionInterval = 10 * time.Second
TopQueryCollection's CollectionInterval = 1 minute.

With the existing logic the EffectiveLookbackTime will be calculated as 20 seconds (2 x 10 =20), and this will not cover the previous 1 minute collection window of top_query.

Issue area -2
And the logic to determine the window slot needs to be fixed too.
The collection latency (mostly a few milliseconds) is not taken into account when the next check is done. As a result when the top_query is configured to collect at 60 seconds, practically the collection is done only by next cycle at 80 seconds.

Fix Proposal

The logic should have been 2 X TopQueryCollection's CollectionInterval to effectively cover the collection period.

And to determine the window,

current check: if s.lastExecutionTimestamp.Add(s.config.TopQueryCollection.CollectionInterval).After(time.Now()) {...}

proposed fix: if int(math.Ceil(time.Since(s.lastExecutionTimestamp).Seconds())) < int(s.config.TopQueryCollection.CollectionInterval.Seconds()) {...}

Link to tracking issue

Fixes #44162

Testing

Documentation

@sv-splunk sv-splunk requested review from a team and crobert-1 as code owners November 11, 2025 14:16
@github-actions github-actions bot added receiver/sqlserver Run Windows Enable running windows test on a PR labels Nov 11, 2025
@github-actions github-actions bot requested a review from sincejune November 11, 2025 14:17
@dmitryax dmitryax merged commit 1f6032c into open-telemetry:main Nov 12, 2025
225 checks passed
@github-actions github-actions bot added this to the next release milestone Nov 12, 2025
@otelbot
Copy link
Contributor

otelbot bot commented Nov 12, 2025

Thank you for your contribution @sv-splunk! 🎉 We would like to hear from you about your experience contributing to OpenTelemetry by taking a few minutes to fill out this survey. If you are getting started contributing, you can also join the CNCF Slack channel #opentelemetry-new-contributors to ask for guidance and get help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

receiver/sqlserver Run Windows Enable running windows test on a PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Flawed logic in calculation of top query metrics collection window

3 participants