{"record":{"id":"88fa5c0e11c48a78","repo":"microsoft/aspire","slug":"resource-view-limit-of-telemetryrepositorylimits","errorCode":null,"errorMessage":"Resource view limit of {TelemetryRepositoryLimits.MaxResourceViewCount} reached.","messagePattern":"Resource view limit of (.+?) reached\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Dashboard/Otlp/Model/OtlpResource.cs","lineNumber":88,"sourceCode":"    }\n\n    internal OtlpResourceView GetViewFromProperties(KeyValuePair<string, string>[] properties)\n    {\n        return GetView(new OtlpResourceView(this, properties));\n    }\n\n    private OtlpResourceView GetView(OtlpResourceView view)\n    {\n        // Inefficient to create this to possibly throw it away.\n\n        if (_resourceViews.TryGetValue(view.Properties, out var resourceView))\n        {\n            return resourceView;\n        }\n\n        if (_resourceViews.Count >= TelemetryRepositoryLimits.MaxResourceViewCount)\n        {\n            throw new InvalidOperationException($\"Resource view limit of {TelemetryRepositoryLimits.MaxResourceViewCount} reached.\");\n        }\n\n        return _resourceViews.GetOrAdd(view.Properties, view);\n    }\n\n    internal void SetUninstrumentedPeer(bool uninstrumentedPeer)\n    {\n        // An app could initially be created for an uninstrumented peer and then telemetry is received from it.\n        // This method \"upgrades\" the resource to not be for an uninstrumented peer when appropriate.\n        if (UninstrumentedPeer && !uninstrumentedPeer)\n        {\n            UninstrumentedPeer = uninstrumentedPeer;\n        }\n    }\n\n    /// <summary>\n    /// Resource views are equal when all properties are equal.\n    /// </summary>","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Dashboard/Otlp/Model/OtlpResource.cs#L70-L106","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Ensure resource attributes are stable for the process lifetime and don't include per-request or high-cardinality values.","Reduce the variety of view property combinations requested for a single resource.","Restart the Dashboard session to clear cached resource views if a run legitimately accumulated many views."],"exampleFix":"// before: high-cardinality value in resource attributes\n.AddTag(\"request.id\", requestId)\n// after: keep resource tags stable\n.AddTag(\"service.instance.id\", instanceId)","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try\n{\n    var view = resource.GetView(properties);\n}\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"Resource view limit\"))\n{\n    logger.LogWarning(ex, \"Falling back to default resource view.\");\n    view = resource.GetView(Array.Empty<KeyValuePair<string, string>>());\n}","preventionTips":["Keep resource attributes fixed for the process lifetime.","Avoid high-cardinality values (request ids, timestamps) in resource attributes.","Limit the number of distinct view property combinations your tooling requests."],"tags":["opentelemetry","limits","resource","dashboard","memory"],"backgroundTag":"resource-limit-exceeded","analyzedSha":"25830f84bd145686607ad00c057b3f84e2e51d43","analyzedAt":"2026-09-16T11:10:06.193Z","contentChangedAt":"2026-09-16T11:10:06.193Z","schemaVersion":2},"datasetVersion":"2026-09-21T04:17:39.646Z"}