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

chore: cache the instance status page for 60 seconds #17539

Merged
Merged
Show file tree
Hide file tree
Changes from 5 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
9 changes: 7 additions & 2 deletions frontend/src/scenes/instance/SystemStatus/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { systemStatusLogic, InstanceStatusTabName } from './systemStatusLogic'
import { useActions, useValues } from 'kea'
import { PageHeader } from 'lib/components/PageHeader'
import { preflightLogic } from 'scenes/PreflightCheck/preflightLogic'
import { IconOpenInNew } from 'lib/lemon-ui/icons'
import { IconInfo, IconOpenInNew } from 'lib/lemon-ui/icons'
import { OverviewTab } from 'scenes/instance/SystemStatus/OverviewTab'
import { InternalMetricsTab } from 'scenes/instance/SystemStatus/InternalMetricsTab'
import { SceneExport } from 'scenes/sceneTypes'
Expand All @@ -17,6 +17,7 @@ import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
import { FEATURE_FLAGS } from 'lib/constants'
import { KafkaInspectorTab } from './KafkaInspectorTab'
import { LemonTab, LemonTabs } from 'lib/lemon-ui/LemonTabs'
import { Tooltip } from 'lib/lemon-ui/Tooltip'

export const scene: SceneExport = {
component: SystemStatus,
Expand All @@ -33,7 +34,11 @@ export function SystemStatus(): JSX.Element {
let tabs = [
{
key: 'overview',
label: 'System overview',
label: (
<Tooltip title={<>System overview is cached for 60 seconds</>}>
System overview <IconInfo />
</Tooltip>
),
content: <OverviewTab />,
},
] as LemonTab<InstanceStatusTabName>[]
Expand Down
3 changes: 3 additions & 0 deletions posthog/api/instance_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

from django.conf import settings
from django.db import connection
from django.utils.decorators import method_decorator
from django.views.decorators.cache import cache_page
from rest_framework import viewsets
from rest_framework.decorators import action
from rest_framework.permissions import IsAuthenticated
Expand Down Expand Up @@ -33,6 +35,7 @@ class InstanceStatusViewSet(viewsets.ViewSet):

permission_classes = [IsAuthenticated, SingleTenancyOrAdmin]

@method_decorator(cache_page(60))
def list(self, request: Request) -> Response:
redis_alive = is_redis_alive()
postgres_alive = is_postgres_alive()
Expand Down
1 change: 1 addition & 0 deletions posthog/settings/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,7 @@ def add_recorder_js_headers(headers, path, url):
"^/api/organizations/@current/plugins/?$",
"^api/projects/@current/feature_flags/my_flags/?$",
"^/?api/projects/\\d+/query/?$",
"^/?api/instance_status/?$",
]
),
)
Expand Down
Loading