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

[wip] experimental: tracing panel #3168

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
4 changes: 2 additions & 2 deletions frontend/src/components/editor/cell/CellStatus.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ export const CellStatusComponent: React.FC<CellStatusComponentProps> = ({
return null;
};

const ElapsedTime = (props: { elapsedTime: string }) => {
export const ElapsedTime = (props: { elapsedTime: string }) => {
return (
<span className="tracking-wide font-semibold">{props.elapsedTime}</span>
);
Expand All @@ -346,7 +346,7 @@ const LastRanTime = (props: { lastRanTime: number }) => {
);
};

function formatElapsedTime(elapsedTime: number | null) {
export function formatElapsedTime(elapsedTime: number | null) {
if (elapsedTime === null) {
return "";
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/* Copyright 2024 Marimo. All rights reserved. */
import { Tracing } from "@/components/tracing/tracing";
import React from "react";

export const TracingPanel: React.FC = () => {
return <Tracing />;
};
9 changes: 9 additions & 0 deletions frontend/src/components/editor/chrome/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
NotebookPenIcon,
BoxIcon,
BotMessageSquareIcon,
ActivityIcon,
} from "lucide-react";

export type PanelType =
Expand All @@ -22,6 +23,7 @@ export type PanelType =
| "variables"
| "outline"
| "dependencies"
| "tracing"
| "packages"
| "documentation"
| "snippets"
Expand Down Expand Up @@ -94,6 +96,13 @@ export const PANELS: PanelDescriptor[] = [
tooltip: "Notebook logs",
position: "sidebar",
},
{
type: "tracing",
Icon: ActivityIcon,
tooltip: "Tracing",
position: "sidebar",
hidden: !getFeatureFlag("tracing"),
},
{
type: "snippets",
Icon: SquareDashedBottomCodeIcon,
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/components/editor/chrome/wrapper/app-chrome.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import { IfCapability } from "@/core/config/if-capability";
import { PackagesPanel } from "../panels/packages-panel";
import { ChatPanel } from "@/components/chat/chat-panel";
import { TooltipProvider } from "@radix-ui/react-tooltip";
import { TracingPanel } from "../panels/tracing-panel";

const LazyTerminal = React.lazy(() => import("@/components/terminal/terminal"));

Expand Down Expand Up @@ -153,6 +154,7 @@ export const AppChrome: React.FC<PropsWithChildren> = ({ children }) => {
{selectedPanel === "scratchpad" && <ScratchpadPanel />}
{selectedPanel === "chat" && <ChatPanel />}
{selectedPanel === "logs" && <LogsPanel />}
{selectedPanel === "tracing" && <TracingPanel />}
</TooltipProvider>
</div>
</Suspense>
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/components/editor/dynamic-favicon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ import { useEventListener } from "@/hooks/useEventListener";
import { usePrevious } from "@dnd-kit/utilities";
import { useEffect } from "react";

const FAVICONS = {
export const FAVICONS = {
idle: "./favicon.ico",
success: "./circle-check.ico",
running: "./circle-play.ico",
error: "./circle-x.ico",
queued: "./favicon.ico",
};

interface Props {
Expand Down
17 changes: 17 additions & 0 deletions frontend/src/components/tracing/tracing.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/* Copyright 2024 Marimo. All rights reserved. */
import { describe, it, expect } from "vitest";
import { formatChartTime } from "./tracing";

describe("formatUTCTime", () => {
it("should format a timestamp correctly", () => {
const timestamp = 1_700_000_000; // Example timestamp
const formattedTime = formatChartTime(timestamp);
expect(formattedTime).toBe("2023-11-15 06:13:20.000");
});

it("should return an empty string for invalid timestamp", () => {
const invalidTimestamp = Number.NaN;
const formattedTime = formatChartTime(invalidTimestamp);
expect(formattedTime).toBe("");
});
});
Loading
Loading