Skip to content

Commit 693effc

Browse files
committed
cleanup
1 parent e61577d commit 693effc

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

receiver/oracledbreceiver/scraper.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -533,10 +533,11 @@ func (s *oracleScraper) scrapeLogs(ctx context.Context) (plog.Logs, error) {
533533

534534
if s.logsBuilderConfig.Events.DbServerTopQuery.Enabled {
535535
currentCollectionTime := time.Now()
536-
if int(math.Ceil(currentCollectionTime.Sub(s.lastExecutionTimestamp).Seconds())) < int(s.topQueryCollectCfg.CollectionInterval.Seconds()) {
536+
lookbackTimeCounter := s.calculateLookbackSeconds()
537+
if lookbackTimeCounter < int(s.topQueryCollectCfg.CollectionInterval.Seconds()) {
537538
s.logger.Debug("Skipping the collection of top queries because collection interval not yet elapsed.")
538539
} else {
539-
topNCollectionErrors := s.collectTopNMetricData(ctx, logs, currentCollectionTime)
540+
topNCollectionErrors := s.collectTopNMetricData(ctx, logs, currentCollectionTime, lookbackTimeCounter)
540541
if topNCollectionErrors != nil {
541542
scrapeErrors = append(scrapeErrors, topNCollectionErrors)
542543
}
@@ -553,11 +554,9 @@ func (s *oracleScraper) scrapeLogs(ctx context.Context) (plog.Logs, error) {
553554
return logs, errors.Join(scrapeErrors...)
554555
}
555556

556-
func (s *oracleScraper) collectTopNMetricData(ctx context.Context, logs plog.Logs, collectionTime time.Time) error {
557+
func (s *oracleScraper) collectTopNMetricData(ctx context.Context, logs plog.Logs, collectionTime time.Time, lookbackTimeSeconds int) error {
557558
var errs []error
558559
// get metrics and query texts from DB
559-
lookbackTimeSeconds := s.calculateLookbackSeconds()
560-
561560
s.oracleQueryMetricsClient = s.clientProviderFunc(s.db, oracleQueryMetricsSQL, s.logger)
562561
metricRows, metricError := s.oracleQueryMetricsClient.metricRows(ctx, lookbackTimeSeconds, s.topQueryCollectCfg.MaxQuerySampleCount)
563562

0 commit comments

Comments
 (0)