microsoft/aspire · error · InvalidOperationException

Resource view limit of

Error message

Resource view limit of {TelemetryRepositoryLimits.MaxResourceViewCount} reached.

What it means

Each OtlpResource in the Dashboard caches a bounded number of distinct resource views (combinations of view properties) via TelemetryRepositoryLimits.MaxResourceViewCount. GetView throws this InvalidOperationException when a request for a new view variant arrives and the cache is already at that limit. This prevents unbounded memory growth if a resource accumulates endlessly many distinct property combinations.

Solutions

  1. Ensure resource attributes are stable for the process lifetime and don't include per-request or high-cardinality values.
  2. Reduce the variety of view property combinations requested for a single resource.
  3. Restart the Dashboard session to clear cached resource views if a run legitimately accumulated many views.

Example fix

// before: high-cardinality value in resource attributes
.AddTag("request.id", requestId)
// after: keep resource tags stable
.AddTag("service.instance.id", instanceId)
Defensive patterns

Strategy: try-catch

Try / catch

try
{
    var view = resource.GetView(properties);
}
catch (InvalidOperationException ex) when (ex.Message.Contains("Resource view limit"))
{
    logger.LogWarning(ex, "Falling back to default resource view.");
    view = resource.GetView(Array.Empty<KeyValuePair<string, string>>());
}

Prevention

When it happens

Trigger: GetView on OtlpResource throws when _resourceViews.Count >= TelemetryRepositoryLimits.MaxResourceViewCount and a view with a previously unseen Properties combination is requested. Triggered during telemetry ingestion/UI lookup when many distinct attribute-subset views are derived for the same resource.

Common situations: Resources whose attributes churn constantly (e.g. per-request attributes leaking into resource attributes); dashboards or extensions requesting many different view property sets; high-cardinality resource attributes evolving over a long session.

Related errors


AI-assisted analysis of microsoft/aspire@25830f84bd (2026-09-16). Data as JSON: /api/errors/88fa5c0e11c48a78. Report an issue: GitHub.

Appendix: source

Thrown at src/Aspire.Dashboard/Otlp/Model/OtlpResource.cs:88

    }

    internal OtlpResourceView GetViewFromProperties(KeyValuePair<string, string>[] properties)
    {
        return GetView(new OtlpResourceView(this, properties));
    }

    private OtlpResourceView GetView(OtlpResourceView view)
    {
        // Inefficient to create this to possibly throw it away.

        if (_resourceViews.TryGetValue(view.Properties, out var resourceView))
        {
            return resourceView;
        }

        if (_resourceViews.Count >= TelemetryRepositoryLimits.MaxResourceViewCount)
        {
            throw new InvalidOperationException($"Resource view limit of {TelemetryRepositoryLimits.MaxResourceViewCount} reached.");
        }

        return _resourceViews.GetOrAdd(view.Properties, view);
    }

    internal void SetUninstrumentedPeer(bool uninstrumentedPeer)
    {
        // An app could initially be created for an uninstrumented peer and then telemetry is received from it.
        // This method "upgrades" the resource to not be for an uninstrumented peer when appropriate.
        if (UninstrumentedPeer && !uninstrumentedPeer)
        {
            UninstrumentedPeer = uninstrumentedPeer;
        }
    }

    /// <summary>
    /// Resource views are equal when all properties are equal.
    /// </summary>

View on GitHub (pinned to 25830f84bd)