Description
Component(s)
connector/spanmetrics
Describe the issue you're reporting
The DimensionsCacheSize
is the limit of the metricKeyToDimensions cache size:
It's use to keep the attributes build from span and try to improve collectors memory usage.
As the code of spanconnector iterates, spanconnector uses ResourceMetrics
to maintain the intermediate state of metrics:
Below is an example of the SumMetrics struct. Please note the signature of the GetOrCreate function.
GetOrCreate(key Key, attributes pcommon.Map, startTimestamp pcommon.Timestamp) *Sum
I found that https://pkg.go.dev/go.opentelemetry.io/collector/pdata/pcommon#Map is also a struct, so the attributes variable is passed by value when GetOrCreate is invoked.
It means that the attributes var in Sum
struct have no relationship with the attributes value in metricKeyToDimensionsCache
.
As per the analysis above, I believe that metricKeyToDimensionsCache can no longer help improve the collector's memory usage. We can use aggregation_cardinality_limit instead.