Skip to content

Commit d9100bf

Browse files
committed
Added setup hints
1 parent 621580b commit d9100bf

File tree

8 files changed

+61
-17
lines changed

8 files changed

+61
-17
lines changed

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,22 @@ docker run -p 8555:8555 --name celery-insights ghcr.io/danyi1212/celery-insights
2323

2424
Next, navigate to http://localhost:8555/ and begin the welcome tour.
2525

26+
### Enabling Celery Events
27+
28+
Celery Insights relies on Celery events to monitor your Celery cluster.
29+
30+
The recommended configuration for using Celery Insights are:
31+
```python
32+
app = Celery("myapp")
33+
app.conf.worker_send_task_events = True # Enables task events
34+
app.conf.task_send_sent_event = True # Enables sent events
35+
app.conf.task_track_started = True # (opt) Update task result state to STARTED
36+
app.conf.result_extended = True # (opt) Store args and kwargs in the result
37+
```
38+
Other events-related configurations should be left as default.
39+
40+
For more information on Celery events configurations, please refer to the [Celery documentation](https://docs.celeryq.dev/en/stable/userguide/configuration.html#events).
41+
2642
### Advanced setup
2743

2844
Celery Insights comes pre-configured for localhost Redis as Result Backend and RabbitMQ as Broker.

frontend/src/components/common/CodeBlock.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,11 @@ import { PrismLight as SyntaxHighlighter, SyntaxHighlighterProps } from "react-s
44
import darkStyle from "react-syntax-highlighter/dist/esm/styles/prism/material-dark"
55
import lightStyle from "react-syntax-highlighter/dist/esm/styles/prism/material-light"
66

7-
interface CodeBlockProps extends Omit<SyntaxHighlighterProps, "children"> {
8-
code: string
9-
}
10-
11-
const CodeBlock: React.FC<CodeBlockProps> = ({ code, ...props }) => {
7+
const CodeBlock: React.FC<SyntaxHighlighterProps> = ({ children, ...props }) => {
128
const theme = useTheme()
139
return (
1410
<SyntaxHighlighter style={theme.palette.mode === "dark" ? darkStyle : lightStyle} {...props}>
15-
{code}
11+
{children}
1612
</SyntaxHighlighter>
1713
)
1814
}

frontend/src/components/task/RecentTasksPanel.tsx

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
import AnimatedList from "@components/common/AnimatedList"
22
import AnimatedListItem from "@components/common/AnimatedListItem"
3+
import CodeBlock from "@components/common/CodeBlock"
34
import Panel, { PanelProps } from "@components/common/Panel"
45
import TaskAvatar from "@components/task/TaskAvatar"
56
import ReadMoreIcon from "@mui/icons-material/ReadMore"
7+
import Box from "@mui/material/Box"
68
import Button from "@mui/material/Button"
9+
import Link from "@mui/material/Link"
710
import ListItemAvatar from "@mui/material/ListItemAvatar"
811
import ListItemButton from "@mui/material/ListItemButton"
912
import ListItemSecondaryAction from "@mui/material/ListItemSecondaryAction"
@@ -13,7 +16,7 @@ import Typography from "@mui/material/Typography"
1316
import { useStateStore } from "@stores/useStateStore"
1417
import { format } from "date-fns"
1518
import React, { useCallback } from "react"
16-
import { Link as RouterLink, Link } from "react-router-dom"
19+
import { Link as RouterLink } from "react-router-dom"
1720

1821
const RecentTaskListItem: React.FC<{ taskId: string }> = ({ taskId }) => {
1922
const task = useStateStore(useCallback((store) => store.tasks.get(taskId), [taskId]))
@@ -57,9 +60,35 @@ const RecentTasksPanel: React.FC<Omit<PanelProps, "title">> = (props) => {
5760
))}
5861
</AnimatedList>
5962
) : (
60-
<Typography variant="h3" align="center" my={5}>
61-
No recent tasks
62-
</Typography>
63+
<Box textAlign="center" my={5}>
64+
<Typography variant="h4" gutterBottom>
65+
No recent tasks
66+
</Typography>
67+
<span>Make sure you have Celery Events enabled:</span>
68+
<Box maxWidth="30em" mx="auto">
69+
<CodeBlock language="python">
70+
{[
71+
'app = Celery("myapp")',
72+
"app.conf.worker_send_task_events = True",
73+
"app.conf.task_send_sent_event = True",
74+
"app.conf.task_track_started = True",
75+
"app.conf.result_extended = True",
76+
"app.conf.enable_utc = True",
77+
].join("\n")}
78+
</CodeBlock>
79+
</Box>
80+
<span>
81+
For more information, see the{" "}
82+
<Link
83+
href="https://github.com/danyi1212/celery-insights?tab=readme-ov-file#enabling-celery-events"
84+
target="_blank"
85+
rel="noopener noreferrer"
86+
>
87+
Installation docs
88+
</Link>
89+
.
90+
</span>
91+
</Box>
6392
)}
6493
</Panel>
6594
)

frontend/src/components/task/alerts/ExceptionAlert.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ const ExceptionTraceback: React.FC<ExceptionTracebackProps> = ({ exception, trac
7070
Traceback
7171
</Button>
7272
<Collapse in={expanded} unmountOnExit>
73-
<CodeBlock language="python" code={traceback} />
73+
<CodeBlock language="python">{traceback}</CodeBlock>
7474
</Collapse>
7575
</>
7676
)}

frontend/src/components/worker/WorkersSummaryStack.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,12 @@ const WorkersSummaryStack: React.FC = () => {
2323
))}
2424
</Stack>
2525
) : (
26-
<Typography variant="h4" align="center" my={5}>
27-
No online workers
28-
</Typography>
26+
<Box textAlign="center" my={5}>
27+
<Typography variant="h4" gutterBottom>
28+
No online workers
29+
</Typography>
30+
<span>Start a Celery worker to see it here</span>
31+
</Box>
2932
)}
3033
</Box>
3134
)

poetry.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ aiopath = "^0"
2121
pydantic = "^2"
2222
pydantic-settings = "^2"
2323
colorlog = "*"
24+
redis = "^5.0.8"
2425

2526
[tool.poetry.group.all]
2627
optional = true

test_project/producer.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ async def main():
3131
stop_signal = asyncio.Event()
3232

3333
logger.info("Starting producer...")
34-
async with asyncio.TaskGroup() as tg:
35-
tg.create_task(timer(10, lambda: publish(order_workflow.si()), stop_signal))
34+
await timer(10, lambda: publish(order_workflow.si()), stop_signal)
3635

3736

3837
if __name__ == "__main__":

0 commit comments

Comments
 (0)