import Link from 'next/link' import { Button, Card, CardContent, CardFooter, CardHeader, CardTitle, cn, Loading } from 'ui' import { LogsBarChart } from 'ui-patterns/LogsBarChart' import type { LogsBarChartDatum } from '../ProjectHome/ProjectUsage.metrics' import { getHealthStatus, type ServiceKey } from './ObservabilityOverview.utils' import NoDataPlaceholder from '@/components/ui/Charts/NoDataPlaceholder' const colorClassMap: Record = { muted: 'bg-muted', destructive: 'bg-destructive', warning: 'bg-warning', brand: 'bg-brand', } export type ServiceHealthCardProps = { serviceName: string serviceKey: ServiceKey total: number errorRate: number errorCount: number warningCount: number chartData: LogsBarChartDatum[] reportUrl?: string // undefined if feature flag disabled or no report available logsUrl: string isLoading: boolean onBarClick: (datum: any) => void datetimeFormat: string } export const ServiceHealthCard = ({ serviceName, serviceKey: _serviceKey, total, errorRate, errorCount, warningCount, chartData, reportUrl, logsUrl, isLoading, onBarClick, datetimeFormat, }: ServiceHealthCardProps) => { const { color } = getHealthStatus(errorRate, total) return (
{serviceName}
{total.toLocaleString()} requests
{errorRate.toFixed(1)}% error rate
Warn
{warningCount.toLocaleString()}
Err
{errorCount.toLocaleString()}
} /> {reportUrl && ( )} ) }