Skip to content

Commit

Permalink
fix: lint error
Browse files Browse the repository at this point in the history
  • Loading branch information
povilasv committed Nov 20, 2024
1 parent 843b04b commit 3f48f7f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
11 changes: 7 additions & 4 deletions packages/sdk-metrics/src/state/DeltaMetricProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,15 @@ export class DeltaMetricProcessor<T extends Maybe<Accumulation>> {
// https://github.com/open-telemetry/opentelemetry-specification/pull/2208
private _cumulativeMemoStorage = new AttributeHashMap<T>();
private _cardinalityLimit: number;
private _overflowAttributes = { 'otel.metric.overflow': true };
private _overflowHashCode: string;

constructor(
private _aggregator: Aggregator<T>,
aggregationCardinalityLimit?: number
) {
this._cardinalityLimit = (aggregationCardinalityLimit ?? 2000) - 1;
this._overflowHashCode = hashAttributes(this._overflowAttributes);
}

record(
Expand All @@ -49,9 +53,8 @@ export class DeltaMetricProcessor<T extends Maybe<Accumulation>> {

if (!accumulation) {
if (this._activeCollectionStorage.size >= this._cardinalityLimit) {
const overflowAttributes = { 'otel.metric.overflow': true };
const overflowAccumulation = this._activeCollectionStorage.getOrDefault(
overflowAttributes,
this._overflowAttributes,
() => this._aggregator.createAccumulation(collectionTime)
);
overflowAccumulation?.record(value);
Expand Down Expand Up @@ -87,8 +90,8 @@ export class DeltaMetricProcessor<T extends Maybe<Accumulation>> {
} else {
// If the cardinality limit is reached, we need to change the attributes
if (this._cumulativeMemoStorage.size >= this._cardinalityLimit) {
attributes = { 'otel.metric.overflow': true };
hashCode = hashAttributes(attributes);
attributes = this._overflowAttributes;
hashCode = this._overflowHashCode;
if (this._cumulativeMemoStorage.has(attributes, hashCode)) {
const previous = this._cumulativeMemoStorage.get(
attributes,
Expand Down
2 changes: 1 addition & 1 deletion packages/sdk-metrics/src/state/MetricCollector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export class MetricCollector implements MetricProducer {
* collector.
*/
selectCardinalityLimit(instrumentType: InstrumentType): number {
return this._metricReader.selectCardinalityLimit.?(instrumentType) ?? 2000;
return this._metricReader.selectCardinalityLimit?.(instrumentType) ?? 2000;
}
}

Expand Down

0 comments on commit 3f48f7f

Please sign in to comment.