microsoft/aspire · error
Dimension limit of reached.
Error message
Dimension limit of {TelemetryRepositoryLimits.MaxDimensionCount} reached. What it means
The repository limits the number of unique metric attribute (dimension) combinations per instrument to TelemetryRepositoryLimits.MaxDimensionCount. GetOrAddMetricDimension checks the per-instrument dimension count before adding a new one and throws InvalidOperationException when the cap is reached, guarding against unbounded high-cardinality storage.
Solutions
- Remove or bound high-cardinality attributes on your metrics; keep tag values from small fixed sets.
- Increase TelemetryRepositoryLimits.MaxInstrumentCount/MaxDimensionCount limits via dashboard configuration if your workload is legitimately dimensional.
- Restart the dashboard to clear in-memory ingestion state after fixing the emitter.
- Use OTel attribute-per-cardinality guidance (e.g. drop url, user id attributes from metrics).
Example fix
// before
counter.Add(1, new KeyValuePair<string, object?>("user.id", userId)); // unbounded
// after
counter.Add(1, new KeyValuePair<string, object?>("user.tier", userTier)); // bounded set Defensive patterns
Strategy: try-catch
Validate before calling
// audit metric attributes for unbounded values before export
foreach (var attr in attributes)
if (attr.Value is string s && IsHighCardinality(s))
logger.LogWarning("Attribute {Key} looks high-cardinality", attr.Key); Try / catch
try
{
await repo.AddMetricsAsync(request);
}
catch (InvalidOperationException ex) when (ex.Message.Contains("Dimension limit"))
{
logger.LogWarning(ex, "Metric cardinality limit reached for instrument.");
} Prevention
- Avoid ids, urls, emails, and timestamps as metric attributes.
- Keep attribute values in small fixed sets.
- Raise TelemetryRepositoryLimits deliberately and knowingly, not as a first resort.
- Load-test metric cardinality before production.
When it happens
Trigger: AddMetricToDatabase -> GetOrAddMetricDimension for an instrument whose ingestionState.DimensionCounts[instrumentId] is already >= MaxDimensionCount while the incoming point has a new attribute combination.
Common situations: Metrics with high-cardinality attributes (user ids, urls, container ids, correlation ids); a service under attack or a load test hammering unique tag values; long dashboard sessions accumulating dimensions from many emitters.
Understand the failure class
Background: "value must be between 0 and 1" / "out of range" / "must not be negative" errors: fixing range-validation failures across open-source libraries — this error's family across 42 libraries.
Related errors
- Instrument limit of reached. Instrument ' ' will not be…
- Histogram data point bucket count length changed.
- Histogram data point has bucket counts without any explicit…
- Histogram data point sum must be finite.
- Instrument name is required.
AI-assisted analysis of microsoft/aspire@25830f84bd (2026-09-16).
Data as JSON: /api/errors/308bfd6566b47ba5.
Report an issue: GitHub.
Appendix: source
Thrown at src/Aspire.Dashboard/Otlp/Storage/SqliteTelemetryRepository.Metrics.Writes.cs:511
{
candidates = [];
ingestionState.Dimensions.Add(cacheKey, candidates);
}
foreach (var candidate in candidates)
{
if (candidate.Attributes.SequenceEqual(attributes))
{
return candidate;
}
}
var knownAttributeValues = ingestionState.KnownAttributeValues[instrumentId];
knownAttributeValues.ValidateDimension(attributes);
var dimensionCount = ingestionState.DimensionCounts[instrumentId];
if (dimensionCount >= TelemetryRepositoryLimits.MaxDimensionCount)
{
throw new InvalidOperationException($"Dimension limit of {TelemetryRepositoryLimits.MaxDimensionCount} reached.");
}
knownAttributeValues.AddDimension(attributes);
var dimension = new MetricDimensionState { Attributes = attributes };
ingestionState.PendingDimensions.Add(new PendingMetricDimension(instrumentId, attributeHash, dimension));
ingestionState.PendingDimensionAttributes.AddRange(attributes.Select((attribute, ordinal) => new PendingMetricDimensionAttribute(
dimension,
ordinal,
attribute.Key,
attribute.Value)));
candidates.Add(dimension);
ingestionState.DimensionCounts[instrumentId] = dimensionCount + 1;
return dimension;
}
private static void InsertMetricDimensions(
SqliteConnection connection,
IDbTransaction transaction,View on GitHub (pinned to 25830f84bd)