Skip to content

The only tool you need to know what is happening and how to fix it.

3.3 KB
Raw Blame
import{s as c}from"./DGFc8hah.js";const d=[{id:"fast",label:"Fast",longWindowMinutes:60,shortWindowMinutes:5,burnRateThreshold:14.4},{id:"slow",label:"Slow",longWindowMinutes:360,shortWindowMinutes:30,burnRateThreshold:6},{id:"long",label:"Long",longWindowMinutes:4320,shortWindowMinutes:360,burnRateThreshold:1}],h=120,f=[1,5,15,30,60,120,240,480,720,1440];function p(e){return e.filter(t=>t.total>0).map(t=>({timestamp:new Date(t.bucket),value:t.good/t.total*100}))}function b(e,t){const n=e.reduce((o,a)=>o+a.total,0),r=(1-t/100)*n;if(n===0||r<=0)return[];let s=0;return e.map(o=>(s+=o.total-o.good,{timestamp:new Date(o.bucket),value:s/r*100}))}function T(e){return e===null?"neutral":e<0?"danger":e<25?"warning":"success"}function w(e){return e===null?"neutral":e>=d[0].burnRateThreshold?"danger":e>=1?"warning":"success"}function M(e){switch(e){case"success":return"text-green-600 dark:text-green-400";case"warning":return"text-amber-600 dark:text-amber-400";case"danger":return"text-red-600 dark:text-red-400";default:return"text-muted-foreground"}}function $(e){switch(e){case"success":return"bg-green-500";case"warning":return"bg-amber-500";case"danger":return"bg-red-500";default:return"bg-muted-foreground/40"}}function g(e){const t=String(e),n=t.indexOf(".");return n===-1?0:t.length-n-1}function x(e,t){if(e===null||Number.isNaN(e))return"—";const n=Math.max(2,g(t)),r=10**n;return`${(Math.floor(e*r+1e-6)/r).toFixed(n)}%`}function S(e){return e===null?"—":`${e.toFixed(e>=10?0:1)}x`}function N(e){return e<=7?"7d":e<=30?"1M":"3M"}function v(e,t,n,r){const s=n*24*60*60*1e3;let o=!1;const a=t.getTime()>r.getTime()?r:t;let i=e;const u=new Date(a.getTime()-s);return i.getTime()<u.getTime()&&(i=u,o=!0),{from:i,to:a,clamped:o}}function R(e,t,n){const r=(t.getTime()-e.getTime())/6e4/150;for(const s of f)if(s>=r-.05&&s>=n)return s;return 1440}function k(e,t){let n=t;for(const s of e)s.value<n&&(n=s.value);const r=Math.max(.05,(100-n)*.15);return[Math.max(0,n-r),100]}function B(e){let t=100;for(const n of e)n.value>t&&(t=n.value);return[0,Math.min(t,250)*1.05]}function l(e,t){return e==="latency"?`latency ≤ ${t}ms`:"availability"}function E(e){const t=e.sliConfig;switch(e.sliKind){case"endpoint":return`${t.endpoint||"all endpoints"} · ${l(t.good,t.latencyThresholdMs)}`;case"span":{const n=[];t.serviceName&&n.push(t.serviceName),t.name&&n.push(`name ~ ${t.name}`),t.kind!==null&&t.kind!==void 0&&n.push(c(t.kind));const r=t.attributes??[];return r.length===1?n.push(`${r[0].key}=${r[0].value}`):r.length>1&&n.push(`${r.length} attributes`),n.length===0&&n.push("all spans"),n.push(l(t.good,t.latencyThresholdMs)),n.join(" · ")}case"task":return t.taskName||"all tasks";case"monitor":{const n=t.checkIds??[];return n.length===1?"1 monitor":`${n.length} monitors`}case"session":return`${t.appVersion||"all versions"} · crash-free sessions${t.includeMessages?" (messages count)":""}`;case"metric":{const n={gt:">",gte:"≥",lt:"<",lte:"≤"}[t.operator]??t.operator;return`${t.aggregation}(${t.metricName}) ${n} ${t.threshold} · ${e.bucketMinutes}m slices`}}return e.sliKind}function W(e){return e===null||Number.isNaN(e)?"—":e<=-100?`${Math.round(e).toLocaleString("en-US")}%`:`${e.toFixed(1)}%`}export{d as B,h as S,S as a,W as b,w as c,T as d,$ as e,x as f,N as g,v as h,R as i,k as j,B as k,p as l,b as m,E as s,M as t};