Skip to content

Commit d2f0825

Browse files
committed
Adds dashboard and query limits to the Limits page
1 parent fe93b6d commit d2f0825

File tree

2 files changed

+62
-7
lines changed

2 files changed

+62
-7
lines changed

apps/webapp/app/presenters/v3/LimitsPresenter.server.ts

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@ export type LimitsResult = {
6868
batchProcessingConcurrency: QuotaInfo;
6969
devQueueSize: QuotaInfo;
7070
deployedQueueSize: QuotaInfo;
71+
metricDashboards: QuotaInfo | null;
72+
metricWidgetsPerDashboard: QuotaInfo | null;
73+
queryPeriodDays: QuotaInfo | null;
7174
};
7275
features: {
7376
hasStagingEnvironment: FeatureInfo;
@@ -155,6 +158,11 @@ export class LimitsPresenter extends BasePresenter {
155158
},
156159
});
157160

161+
// Get metric dashboard count for this org
162+
const metricDashboardCount = await this._replica.metricsDashboard.count({
163+
where: { organizationId },
164+
});
165+
158166
// Get current rate limit tokens for this environment's API key
159167
const apiRateLimitTokens = await getRateLimitRemainingTokens(
160168
"api",
@@ -174,6 +182,9 @@ export class LimitsPresenter extends BasePresenter {
174182
const branchesLimit = limits?.branches?.number ?? null;
175183
const logRetentionDaysLimit = limits?.logRetentionDays?.number ?? null;
176184
const realtimeConnectionsLimit = limits?.realtimeConcurrentConnections?.number ?? null;
185+
const metricDashboardsLimit = limits?.metricDashboards?.number ?? null;
186+
const metricWidgetsPerDashboardLimit = limits?.metricWidgetsPerDashboard?.number ?? null;
187+
const queryPeriodDaysLimit = limits?.queryPeriodDays?.number ?? null;
177188
const includedUsage = limits?.includedUsage ?? null;
178189
const hasStagingEnvironment = limits?.hasStagingEnvironment ?? false;
179190
const supportLevel = limits?.support ?? "community";
@@ -296,6 +307,40 @@ export class LimitsPresenter extends BasePresenter {
296307
currentUsage: 0, // Would need to query Redis for this
297308
source: organization.maximumDeployedQueueSize ? "override" : "default",
298309
},
310+
metricDashboards:
311+
metricDashboardsLimit !== null
312+
? {
313+
name: "Metric dashboards",
314+
description: "Maximum number of custom metric dashboards per organization",
315+
limit: metricDashboardsLimit,
316+
currentUsage: metricDashboardCount,
317+
source: "plan",
318+
canExceed: limits?.metricDashboards?.canExceed,
319+
isUpgradable: true,
320+
}
321+
: null,
322+
metricWidgetsPerDashboard:
323+
metricWidgetsPerDashboardLimit !== null
324+
? {
325+
name: "Charts per dashboard",
326+
description: "Maximum number of charts per metrics dashboard",
327+
limit: metricWidgetsPerDashboardLimit,
328+
currentUsage: 0, // Varies per dashboard
329+
source: "plan",
330+
canExceed: limits?.metricWidgetsPerDashboard?.canExceed,
331+
isUpgradable: true,
332+
}
333+
: null,
334+
queryPeriodDays:
335+
queryPeriodDaysLimit !== null
336+
? {
337+
name: "Query period",
338+
description: "Maximum number of days a query can look back",
339+
limit: queryPeriodDaysLimit,
340+
currentUsage: 0, // Not applicable - this is a duration, not a count
341+
source: "plan",
342+
}
343+
: null,
299344
},
300345
features: {
301346
hasStagingEnvironment: {

apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.limits/route.tsx

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,11 @@ function QuotasSection({
511511
if (quotas.devQueueSize.limit !== null) quotaRows.push(quotas.devQueueSize);
512512
if (quotas.deployedQueueSize.limit !== null) quotaRows.push(quotas.deployedQueueSize);
513513

514+
// Metric & query quotas
515+
if (quotas.metricDashboards) quotaRows.push(quotas.metricDashboards);
516+
if (quotas.metricWidgetsPerDashboard) quotaRows.push(quotas.metricWidgetsPerDashboard);
517+
if (quotas.queryPeriodDays) quotaRows.push(quotas.queryPeriodDays);
518+
514519
return (
515520
<div className="flex flex-col gap-3">
516521
<Header2 className="flex items-center gap-1">
@@ -555,13 +560,16 @@ function QuotaRow({
555560
isOnTopPlan: boolean;
556561
billingPath: string;
557562
}) {
558-
// For log retention, we don't show current usage as it's a duration, not a count
559-
const isRetentionQuota = quota.name === "Log retention";
563+
// For log retention and query period, we don't show current usage as it's a duration, not a count
564+
// For widgets per dashboard, the usage varies per dashboard so we don't show a single number
565+
const isDurationQuota = quota.name === "Log retention" || quota.name === "Query period";
566+
const isPerItemQuota = quota.name === "Charts per dashboard";
567+
const isRetentionQuota = isDurationQuota || isPerItemQuota;
560568
const percentage =
561569
!isRetentionQuota && quota.limit && quota.limit > 0 ? quota.currentUsage / quota.limit : null;
562570

563-
// Special handling for Log retention
564-
if (quota.name === "Log retention") {
571+
// Special handling for duration-based quotas (Log retention, Query period)
572+
if (isDurationQuota) {
565573
const canUpgrade = !isOnTopPlan;
566574
return (
567575
<TableRow>
@@ -570,7 +578,9 @@ function QuotaRow({
570578
<InfoIconTooltip content={quota.description} disableHoverableContent />
571579
</TableCell>
572580
<TableCell alignment="right" className="font-medium tabular-nums">
573-
{quota.limit !== null ? `${formatNumber(quota.limit)} days` : "Unlimited"}
581+
{quota.limit !== null
582+
? `${formatNumber(quota.limit)} ${quota.limit === 1 ? "day" : "days"}`
583+
: "Unlimited"}
574584
</TableCell>
575585
<TableCell alignment="right" className="tabular-nums text-text-dimmed">
576586
@@ -648,8 +658,8 @@ function QuotaRow({
648658
</TableCell>
649659
<TableCell alignment="right" className="font-medium tabular-nums">
650660
{quota.limit !== null
651-
? isRetentionQuota
652-
? `${formatNumber(quota.limit)} days`
661+
? isDurationQuota
662+
? `${formatNumber(quota.limit)} ${quota.limit === 1 ? "day" : "days"}`
653663
: formatNumber(quota.limit)
654664
: "Unlimited"}
655665
</TableCell>

0 commit comments

Comments
 (0)