Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

feat: add tooltip to latency tables (#1313)

Max Deichmanne96a3bbf6ea6
diff --git a/web/src/components/layouts/doc-popup.tsx b/web/src/components/layouts/doc-popup.tsx
index 2e4e0accdb..829dc8bab2 100644
--- a/web/src/components/layouts/doc-popup.tsx
+++ b/web/src/components/layouts/doc-popup.tsx
@@ -75,3 +75,28 @@ export default function DocPopup({
</HoverCard>
);
}
+
+export type PopupProps = {
+ triggerContent: React.ReactNode;
+ description: React.ReactNode;
+};
+
+export function Popup({ triggerContent, description }: PopupProps) {
+ console.log("triggerContent", triggerContent, description);
+ return (
+ <HoverCard openDelay={200}>
+ <HoverCardTrigger className="mx-1 cursor-pointer" asChild>
+ <div>{triggerContent}</div>
+ </HoverCardTrigger>
+ <HoverCardContent>
+ {typeof description === "string" ? (
+ <div className="whitespace-break-spaces text-xs font-normal text-gray-800 sm:pl-0">
+ {description}
+ </div>
+ ) : (
+ description
+ )}
+ </HoverCardContent>
+ </HoverCard>
+ );
+}
diff --git a/web/src/features/dashboard/components/SpanLatencyTable.tsx b/web/src/features/dashboard/components/SpanLatencyTable.tsx
index 283919ed94..2935904325 100644
--- a/web/src/features/dashboard/components/SpanLatencyTable.tsx
+++ b/web/src/features/dashboard/components/SpanLatencyTable.tsx
@@ -8,6 +8,7 @@ import { type DatabaseRow } from "@/src/server/api/services/query-builder";
import { formatIntervalSeconds } from "@/src/utils/dates";
import { createTracesTimeFilter } from "@/src/features/dashboard/lib/dashboard-utils";
import { truncate } from "@/src/utils/string";
+import { Popup } from "@/src/components/layouts/doc-popup";
export const LatencyTables = ({
projectId,
@@ -115,7 +116,12 @@ export const LatencyTables = ({
? data
.filter((item) => item.name !== null)
.map((item, i) => [
- truncate(item.name as string),
+ <div key={`${item.name as string}-${i}`}>
+ <Popup
+ triggerContent={truncate(item.name as string)}
+ description={item.name as string}
+ />
+ </div>,
...[
"percentile50Duration",
"percentile90Duration",
diff --git a/web/src/utils/string.ts b/web/src/utils/string.ts
index 1efce89279..88892c3121 100644
--- a/web/src/utils/string.ts
+++ b/web/src/utils/string.ts
@@ -2,7 +2,7 @@ export function lastCharacters(str: string, n: number) {
return str.substring(str.length - n);
}
-export function truncate(str: string, n: number = 10) {
+export function truncate(str: string, n: number = 16) {
// '...' suffix if the string is longer than n
if (str.length > n) {
return str.substring(0, n) + "...";