Files
zeekay 1b367e2b62 chore: rebase the tree onto upstream master
The tree was a debranded snapshot of upstream taken around 2026-02-20, and
upstream has moved about five months since. This replaces it with upstream
master, mechanically re-derived: bin/debrand does the rename, and the
pipeline and squashed migrations are restored from the shipped tree.

Not a merge. The previous import replaced the tree wholesale in a single
commit, so there is no shared content history to merge against. Reproducing
the rename on the new tree is what actually converges.

What survives: .hanzo/workflows, the Dockerfiles and bin/docker* entrypoints,
compose files, LLM.md, and insights/migrations. The squashed initial
migration is load-bearing — the live database records it by name, so
upstream's ~918 individual migrations cannot come back.

Nine products are dropped as unreferenced. Twenty-one more that we do not run
are kept anyway because the core app still imports them; unpicking those is a
refactor and does not belong in a rebase.

This base does not build yet, and the reasons are not in the rename:
upstream now wants Python 3.13.13 against our 3.12.12 and Django 5.2 against
our 4.2, and the dependency manifests still name upstream packages that we
republish under our own names. Those are decisions, not renames.
2026-08-01 15:44:40 -07:00

126 lines
5.1 KiB
TypeScript

import { useValues } from 'kea'
import { useMemo } from 'react'
import { Link } from 'lib/elements/Link'
import { humanFriendlyDuration } from 'lib/utils/durations'
import { humanFriendlyNumber, humanizeBytes } from 'lib/utils/numbers'
import { urls } from 'scenes/urls'
import { Query } from '~/queries/Query/Query'
import { DataTableNode, NodeKind } from '~/queries/schema/schema-general'
import { QueryContext } from '~/queries/types'
import { EndpointsUsageFilters } from './EndpointsUsageFilters'
import { endpointsUsageLogic } from './endpointsUsageLogic'
export function EndpointsUsage(): JSX.Element {
const {
overviewQuery,
requestsTrendsQuery,
bytesReadTrendsQuery,
cpuSecondsTrendsQuery,
queryDurationTrendsQuery,
errorRateTrendsQuery,
endpointTableQuery,
refreshKey,
activeEndpointNames,
} = useValues(endpointsUsageLogic)
const tableContext: QueryContext<DataTableNode> = useMemo(
() => ({
columns: {
endpoint: {
title: 'Endpoint',
render: ({ value }) => {
if (!value || typeof value !== 'string') {
return <>{value}</>
}
if (activeEndpointNames.has(value)) {
return <Link to={urls.endpoint(value)}>{value}</Link>
}
return <span className="text-muted">{value} (deleted)</span>
},
},
requests: {
title: 'Executions',
render: ({ value }) => <>{humanFriendlyNumber(value as number)}</>,
},
bytes_read: {
title: 'Bytes read',
render: ({ value }) => <>{humanizeBytes(value as number)}</>,
},
cpu_seconds: {
title: 'CPU time',
render: ({ value }) => <>{humanFriendlyDuration(value as number)}</>,
},
avg_query_duration_ms: {
title: 'Avg query duration',
render: ({ value }) => <>{humanFriendlyDuration((value as number) / 1000)}</>,
},
error_rate: {
title: 'Error rate',
render: ({ value }) => <>{((value as number) * 100).toFixed(2)}%</>,
},
},
}),
[activeEndpointNames]
)
return (
<>
<EndpointsUsageFilters />
<div className="mt-4 grid grid-cols-1 md:grid-cols-4 gap-x-4 gap-y-8">
<div className="col-span-1 md:col-span-4 flex flex-col">
<h2 className="mb-3">Overview</h2>
<Query key={`overview-${refreshKey}`} query={overviewQuery} readOnly />
</div>
{/* Row 1: Executions, Error rate, Query duration */}
<div className="col-span-1 md:col-span-4 grid grid-cols-1 md:grid-cols-3 gap-4">
<div className="flex flex-col">
<h2 className="mb-3">Executions over time</h2>
<Query key={`requests-${refreshKey}`} query={requestsTrendsQuery} readOnly />
</div>
<div className="flex flex-col">
<h2 className="mb-3">Error rate over time</h2>
<Query key={`error-rate-${refreshKey}`} query={errorRateTrendsQuery} readOnly />
</div>
<div className="flex flex-col">
<h2 className="mb-3">Query duration over time</h2>
<Query key={`query-duration-${refreshKey}`} query={queryDurationTrendsQuery} readOnly />
</div>
</div>
{/* Row 2: CPU time, Bytes read */}
<div className="col-span-1 md:col-span-2 flex flex-col">
<h2 className="mb-3">CPU time over time</h2>
<Query key={`cpu-seconds-${refreshKey}`} query={cpuSecondsTrendsQuery} readOnly />
</div>
<div className="col-span-1 md:col-span-2 flex flex-col">
<h2 className="mb-3">Bytes read over time</h2>
<Query key={`bytes-read-${refreshKey}`} query={bytesReadTrendsQuery} readOnly />
</div>
<div className="col-span-1 md:col-span-4 flex flex-col">
<h2 className="mb-3">Endpoints breakdown</h2>
<Query
key={`table-${refreshKey}`}
query={
{
kind: NodeKind.DataTableNode,
source: endpointTableQuery,
full: true,
showActions: false,
embedded: false,
} as DataTableNode
}
context={tableContext}
readOnly
/>
</div>
</div>
</>
)
}