Skip to content

Commit 0b61051

Browse files
committed
Updating cacheSize to be alligned to MaxQuerySampleCount
1 parent 59c8520 commit 0b61051

File tree

3 files changed

+3
-9
lines changed

3 files changed

+3
-9
lines changed

receiver/oracledbreceiver/config.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,11 @@ var (
2626
errEmptyUsername = errors.New("username must be set")
2727
errMaxQuerySampleCount = errors.New("`max_query_sample_count` must be between 1 and 10000")
2828
errTopQueryCount = errors.New("`top_query_count` must be between 1 and 200 and less than or equal to `max_query_sample_count`")
29-
errQueryCacheSize = errors.New("`query_cache_size` must be strictly positive")
3029
)
3130

3231
type TopQueryCollection struct {
3332
MaxQuerySampleCount uint `mapstructure:"max_query_sample_count"`
3433
TopQueryCount uint `mapstructure:"top_query_count"`
35-
QueryCacheSize int `mapstructure:"query_cache_size"`
3634
}
3735

3836
type Config struct {
@@ -98,8 +96,5 @@ func (c Config) Validate() error {
9896
if c.TopQueryCount < 1 || c.TopQueryCount > 200 || c.TopQueryCount > c.MaxQuerySampleCount {
9997
allErrs = multierr.Append(allErrs, errTopQueryCount)
10098
}
101-
if c.QueryCacheSize <= 0 {
102-
allErrs = multierr.Append(allErrs, errQueryCacheSize)
103-
}
10499
return allErrs
105100
}

receiver/oracledbreceiver/factory.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ func createDefaultConfig() component.Config {
4747
TopQueryCollection: TopQueryCollection{
4848
MaxQuerySampleCount: 1000,
4949
TopQueryCount: 200,
50-
QueryCacheSize: 5000,
5150
},
5251
}
5352
}
@@ -111,8 +110,9 @@ func createLogsReceiverFunc(sqlOpenerFunc sqlOpenerFunc, clientProviderFunc clie
111110
return nil, hostNameErr
112111
}
113112

114-
cacheSize := sqlCfg.QueryCacheSize
115-
metricCache, err := lru.New[string, map[string]int64](cacheSize)
113+
// cacheSize is kept at 2 times MaxQuerySampleCount to keep queries of adjacent collections available for delta calculation.
114+
cacheSize := sqlCfg.MaxQuerySampleCount * 2
115+
metricCache, err := lru.New[string, map[string]int64](int(cacheSize))
116116
if err != nil {
117117
settings.Logger.Error("Failed to create LRU cache, skipping the current scraper", zap.Error(err))
118118
return nil, err

receiver/oracledbreceiver/testdata/config.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ oracledb:
99
top_query_collection:
1010
max_query_sample_count: 222
1111
top_query_count: 200
12-
query_cache_size: 1000
1312
metrics:
1413
oracledb.exchange_deadlocks:
1514
enabled: false

0 commit comments

Comments
 (0)