Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions diag/app/build/asset-manifest.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"files": {
"main.css": "./static/css/main.8b0db0ad.css",
"main.js": "./static/js/main.92464401.js",
"main.js": "./static/js/main.05d86c95.js",
"index.html": "./index.html",
"main.8b0db0ad.css.map": "./static/css/main.8b0db0ad.css.map",
"main.92464401.js.map": "./static/js/main.92464401.js.map"
"main.05d86c95.js.map": "./static/js/main.05d86c95.js.map"
},
"entrypoints": [
"static/css/main.8b0db0ad.css",
"static/js/main.92464401.js"
"static/js/main.05d86c95.js"
]
}
2 changes: 1 addition & 1 deletion diag/app/build/index.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!doctype html><html lang="en"><head><meta charset="utf-8"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><title>go-workflows</title><script defer="defer" src="./static/js/main.92464401.js"></script><link href="./static/css/main.8b0db0ad.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
<!doctype html><html lang="en"><head><meta charset="utf-8"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><title>go-workflows</title><script defer="defer" src="./static/js/main.05d86c95.js"></script><link href="./static/css/main.8b0db0ad.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions diag/app/build/static/js/main.05d86c95.js.map

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion diag/app/build/static/js/main.92464401.js.map

This file was deleted.

77 changes: 73 additions & 4 deletions diag/app/src/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import React from "react";
import useFetch from "react-fetch-hook";
import { LinkContainer } from "react-router-bootstrap";
import { WorkflowInstance, WorkflowInstanceState } from "./Components";
import { WorkflowInstanceRef } from "./client";
import { WorkflowInstanceRef, Stats } from "./client";

function useQuery() {
const { search } = useLocation();
Expand All @@ -26,11 +26,76 @@ function Home() {
(afterId ? `&after=${afterId}` : "")
);

const { data: stats } = useFetch<Stats>(
document.location.pathname + "api/stats"
);

return (
<div className="App">
<header className="App-header">
<h2>Instances</h2>
</header>
<h2>Queues</h2>

{stats && (
<div className="mb-3">
<div className="row">
<div className="col-md-6">
<h6>Workflow Queues</h6>
{Object.keys(stats.PendingWorkflowTasks || {}).length > 0 ? (
<Table striped bordered size="sm">
<thead>
<tr>
<th>Queue Name</th>
<th>Pending Tasks</th>
</tr>
</thead>
<tbody>
{Object.entries(stats.PendingWorkflowTasks || {}).map(
([queue, count]) => (
<tr key={queue}>
<td>
<code>{queue}</code>
</td>
<td>{count}</td>
</tr>
)
)}
</tbody>
</Table>
) : (
<p className="text-muted">No workflow queues</p>
)}
</div>
<div className="col-md-6">
<h6>Activity Queues</h6>
{Object.keys(stats.PendingActivityTasks || {}).length > 0 ? (
<Table striped bordered size="sm">
<thead>
<tr>
<th>Queue Name</th>
<th>Pending Tasks</th>
</tr>
</thead>
<tbody>
{Object.entries(stats.PendingActivityTasks || {}).map(
([queue, count]) => (
<tr key={queue}>
<td>
<code>{queue}</code>
</td>
<td>{count}</td>
</tr>
)
)}
</tbody>
</Table>
) : (
<p className="text-muted">No activity queues</p>
)}
</div>
</div>
</div>
)}

<h2 className="mt-4">Instances</h2>

{isLoading && <div>Loading...</div>}

Expand All @@ -41,6 +106,7 @@ function Home() {
<tr>
<th>Instance ID</th>
<th>Parent Instance ID</th>
<th>Queue</th>
<th>Created At</th>
<th>Completed At</th>
<th style={{ textAlign: "center" }}>State</th>
Expand All @@ -65,6 +131,9 @@ function Home() {
</Link>
)}
</td>
<td>
<code>{i.queue}</code>
</td>
<td>
<code>{i.created_at}</code>
</td>
Expand Down
10 changes: 10 additions & 0 deletions diag/app/src/Instance.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,16 @@ function Instance() {
<code>{event.attributes?.name}</code>
</div>
)}
{(event.type === "ActivityScheduled" && event.attributes?.queue) && (
<div className="flex-grow-1 text-secondary small">
Queue: <code>{event.attributes.queue}</code>
</div>
)}
{(event.type === "SubWorkflowScheduled" && event.attributes?.sub_workflow_queue) && (
<div className="flex-grow-1 text-secondary small">
Queue: <code>{event.attributes.sub_workflow_queue}</code>
</div>
)}
<div>{event.timestamp}</div>
</h5>
</Accordion.Header>
Expand Down
6 changes: 6 additions & 0 deletions diag/app/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,9 @@ export type WorkflowInstanceTree = WorkflowInstanceRef & {
error?: boolean;
children: WorkflowInstanceTree[];
};

export interface Stats {
ActiveWorkflowInstances: number;
PendingActivityTasks: Record<string, number>;
PendingWorkflowTasks: Record<string, number>;
}
17 changes: 17 additions & 0 deletions diag/diag.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,23 @@ func NewServeMux(backend Backend) *http.ServeMux {

relativeURL := strings.TrimPrefix(r.URL.Path, "/api/")

// /api/stats
if relativeURL == "stats" {
stats, err := backend.GetStats(r.Context())
if err != nil {
w.WriteHeader(http.StatusInternalServerError)
return
}

w.Header().Add("Content-Type", "application/json")
if err := json.NewEncoder(w).Encode(stats); err != nil {
w.WriteHeader(http.StatusInternalServerError)
return
}

return
}

// /api/
if relativeURL == "" {
// Index
Expand Down
Binary file added web
Binary file not shown.
Loading