microsoft/aspire · error

Resource limit of reached. Resource ' ' will not be added.

Error message

Resource limit of {_otlpContext.Options.MaxResourceCount} reached. Resource '{resourceKey}' will not be added.

What it means

The SQLite-backed telemetry repository caps the number of distinct telemetry resources it persists via _otlpContext.Options.MaxResourceCount. GetOrAddCachedResource throws this InvalidOperationException when inserting a new resource would exceed that limit; the resource (and its telemetry) is not added. The limit protects Dashboard memory/storage from hosts generating unbounded numbers of unique resources.

Solutions

  1. Raise the MaxResourceCount option in the Dashboard/OTLP context configuration if the workload legitimately needs more resources.
  2. Stabilize resource attributes (service.name, instance ids) so processes are not counted as new resources on every restart.
  3. Filter or reduce the number of distinct services/instances exporting to this Dashboard (e.g. via collector filtering).

Example fix

// before: default or lowered limit
options.MaxResourceCount = 500;
// after: accommodate the fleet size
options.MaxResourceCount = 5000;
Defensive patterns

Strategy: try-catch

Try / catch

try
{
    await repository.AddTracesToDatabaseAsync(batch);
}
catch (InvalidOperationException ex) when (ex.Message.Contains("Resource limit of"))
{
    logger.LogWarning(ex, "Resource limit reached; resource '{Key}' dropped.", resourceKey);
}

Prevention

When it happens

Trigger: GetOrAddCachedResource throws when SELECT COUNT(*) FROM telemetry_resources equals or exceeds MaxResourceCount and a resource key not yet in the cache is added from AddLogsToDatabaseAsync, AddMetricsToDatabaseAsync, or AddTracesToDatabaseAsync. Triggered on OTLP ingestion when telemetry arrives identifying more unique resources than the configured maximum.

Common situations: Applications emitting resource attributes with per-instance/per-deploy unique values so every restart looks like a new resource; very large service fleets pointed at one Dashboard instance; one-off ephemeral jobs each creating a distinct resource; deployment with a lowered MaxResourceCount option.

Related errors


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

Appendix: source

Thrown at src/Aspire.Dashboard/Otlp/Storage/SqliteTelemetryRepository.Caching.cs:82

                    """, new { ResourceName = resourceKey.Name, resourceKey.InstanceId }, transaction);
                if (record is not null)
                {
                    cachedResource = GetOrAddCachedResource(record);
                    if (cachedResource.Resource.UninstrumentedPeer && !uninstrumentedPeer)
                    {
                        connection.Execute(
                            "UPDATE telemetry_resources SET uninstrumented_peer = 0 WHERE resource_id = @ResourceId;",
                            new { cachedResource.ResourceId },
                            transaction);
                    }
                    cachedResource.Resource.SetUninstrumentedPeer(uninstrumentedPeer);
                }
                else
                {
                    var resourceCount = connection.QuerySingle<int>("SELECT COUNT(*) FROM telemetry_resources;", transaction: transaction);
                    if (resourceCount >= _otlpContext.Options.MaxResourceCount)
                    {
                        throw new InvalidOperationException($"Resource limit of {_otlpContext.Options.MaxResourceCount} reached. Resource '{resourceKey}' will not be added.");
                    }

                    var resourceId = connection.QuerySingle<long>("""
                        INSERT INTO telemetry_resources (resource_name, instance_id)
                        VALUES (@ResourceName, @InstanceId)
                        RETURNING resource_id;
                        """, new { ResourceName = resourceKey.Name, resourceKey.InstanceId }, transaction);
                    cachedResource = CreateCachedResource(resourceId, resourceKey, uninstrumentedPeer);
                }
            }

            GetOrAddCachedResourceView(connection, transaction, cachedResource, []);
            return cachedResource;
        }
    }

    private CachedResourceView GetOrAddCachedResourceView(
        SqliteConnection connection,

View on GitHub (pinned to 25830f84bd)