Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(frontend): rearranged observability table columns #2161

Merged
90 changes: 55 additions & 35 deletions agenta-web/src/pages/apps/[app_id]/observability/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,32 +68,52 @@ const ObservabilityDashboard = ({}: Props) => {
const [selectedTraceId, setSelectedTraceId] = useQueryParam("trace", "")
const [searchQuery, setSearchQuery] = useState("")
const [traceTabs, setTraceTabs] = useState<TraceTabTypes>("tree")
const [editColumns, setEditColumns] = useState<string[]>(["span_type"])
const [editColumns, setEditColumns] = useState<string[]>(["span_type", "key", "usage"])
const [filters, setFilters] = useState<Filter[]>([])
const [sort, setSort] = useState<SortResult>({} as SortResult)
const [isFilterColsDropdownOpen, setIsFilterColsDropdownOpen] = useState(false)
const [pagination, setPagination] = useState({current: 1, page: 10})
const [columns, setColumns] = useState<ColumnsType<_AgentaRootsResponse>>([
{
title: "ID",
dataIndex: ["key"],
dataIndex: ["node", "id"],
key: "key",
width: 200,
onHeaderCell: () => ({
style: {minWidth: 200},
}),
fixed: "left",
render: (_, record) => {
return <ResultTag value1={`# ${record.node.id.split("-")[0]}`} />
},
},
{
title: "Name",
dataIndex: ["node", "name"],
key: "name",
ellipsis: true,
width: 200,
onHeaderCell: () => ({
style: {minWidth: 200},
}),
fixed: "left",
render: (_, record) => {
const {icon: Icon} = nodeTypeStyles[record.node.type ?? "default"]

return !record.parent ? (
<ResultTag value1={`# ${record.key.split("-")[0]}`} />
) : (
return (
<Space align="center" size={4}>
<div className="grid place-items-center">
<Icon size={16} />
</div>
<Typography>{record.node.name}</Typography>
<Typography>
{record.node.name.length >= 15 ? (
<Tooltip title={record.node.name} placement="bottom">
{record.node.name.slice(0, 15)}...
</Tooltip>
) : (
record.node.name
)}
</Typography>
</Space>
)
},
Expand All @@ -110,18 +130,6 @@ const ObservabilityDashboard = ({}: Props) => {
return <div>{record.node.type}</div>
},
},
{
title: "Timestamp",
key: "timestamp",
dataIndex: ["time", "start"],
width: 200,
onHeaderCell: () => ({
style: {minWidth: 200},
}),
render: (_, record) => {
return <div>{dayjs(record.time.start).format("HH:mm:ss DD MMM YYYY")}</div>
},
},
{
title: "Inputs",
key: "inputs",
Expand Down Expand Up @@ -156,16 +164,6 @@ const ObservabilityDashboard = ({}: Props) => {
)
},
},
{
title: "Status",
key: "status",
dataIndex: ["status", "code"],
width: 160,
onHeaderCell: () => ({
style: {minWidth: 160},
}),
render: (_, record) => StatusRenderer({status: record.status, showMore: true}),
},
{
title: "Latency",
key: "latency",
Expand All @@ -176,6 +174,16 @@ const ObservabilityDashboard = ({}: Props) => {
}),
render: (_, record) => <div>{formatLatency(record?.metrics?.acc?.duration.total)}</div>,
},
{
title: "Cost",
key: "cost",
dataIndex: ["metrics", "acc", "costs", "total"],
width: 80,
onHeaderCell: () => ({
style: {minWidth: 80},
}),
render: (_, record) => <div>{formatCurrency(record.metrics?.acc?.costs?.total)}</div>,
},
{
title: "Usage",
key: "usage",
Expand All @@ -189,17 +197,28 @@ const ObservabilityDashboard = ({}: Props) => {
),
},
{
title: "Total cost",
key: "total_cost",
dataIndex: ["metrics", "acc", "costs", "total"],
width: 80,
title: "Start time",
key: "start_time",
dataIndex: ["time", "start"],
width: 200,
onHeaderCell: () => ({
style: {minWidth: 80},
style: {minWidth: 200},
}),
render: (_, record) => <div>{formatCurrency(record.metrics?.acc?.costs?.total)}</div>,
render: (_, record) => {
return <div>{dayjs(record.time.start).format("HH:mm:ss DD MMM YYYY")}</div>
},
},
{
title: "Status",
key: "status",
dataIndex: ["status", "code"],
width: 160,
onHeaderCell: () => ({
style: {minWidth: 160},
}),
render: (_, record) => StatusRenderer({status: record.status, showMore: true}),
},
])

const activeTraceIndex = useMemo(
() =>
traces?.findIndex((item) =>
Expand Down Expand Up @@ -329,6 +348,7 @@ const ObservabilityDashboard = ({}: Props) => {
// Helper function to create a trace object
const createTraceObject = (trace: any) => ({
"Trace ID": trace.key,
Name: trace.node.name,
Timestamp: dayjs(trace.time.start).format("HH:mm:ss DD MMM YYYY"),
Inputs: trace?.data?.inputs?.topic || "N/A",
Outputs: convertToStringOrJson(trace?.data?.outputs) || "N/A",
Expand Down