Chore: added heartbeat for monitoring (#36704)
## Description > [!TIP] > _Add a TL;DR when the description is longer than 500 words or extremely technical (helps the content, marketing, and DevRel team)._ > > _Please also include relevant motivation and context. List any dependencies that are required for this change. Add links to Notion, Figma or any other documents that might be relevant to the PR._ EE conflist resolve fix - https://github.com/appsmithorg/appsmith-ee/pull/5291 Fixes #`Issue Number` _or_ Fixes `Issue URL` > [!WARNING] > _If no issue exists, please create an issue first, and check with the maintainers if the issue is valid._ ## Automation /ok-to-test tags="@tag.All" ### 🔍 Cypress test results <!-- This is an auto-generated comment: Cypress test results --> > [!TIP] > 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉 > Workflow run: <https://github.com/appsmithorg/appsmith/actions/runs/11211380166> > Commit: 3aea136f5e06144594d99e54c1309dda35d96fad > <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=11211380166&attempt=1" target="_blank">Cypress dashboard</a>. > Tags: `@tag.All` > Spec: > <hr>Mon, 07 Oct 2024 09:21:06 UTC <!-- end of auto-generated comment: Cypress test results --> ## Communication Should the DevRel and Marketing teams inform users about this change? - [ ] Yes - [ ] No <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Introduced a `Heartbeat` component for periodic monitoring, sending signals every 30 seconds. - Enhanced application monitoring capabilities by conditionally rendering the `Heartbeat` component in production environments. - **Bug Fixes** - Improved New Relic configuration for better telemetry and monitoring. - **Documentation** - Updated comments and documentation to reflect the new functionality and configuration changes. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
parent
71963b5bf9
commit
2cb50e95a0
34
app/client/src/Heartbeat.tsx
Normal file
34
app/client/src/Heartbeat.tsx
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
import { useEffect } from "react";
|
||||
import log from "loglevel";
|
||||
const Heartbeat = () => {
|
||||
const heartbeatUrl =
|
||||
"https://uptime.betterstack.com/api/v1/heartbeat/71SZmsvAVW73QvEPQzLvxwEL";
|
||||
const interval = 30 * 1000; // 30 secs in milliseconds
|
||||
|
||||
const sendHeartbeat = async () => {
|
||||
try {
|
||||
const response = await fetch(heartbeatUrl);
|
||||
|
||||
if (response.ok) {
|
||||
log.info("Heartbeat sent successfully");
|
||||
} else {
|
||||
log.error("Failed to send heartbeat", response.status);
|
||||
}
|
||||
} catch (error) {
|
||||
log.error("Error sending heartbeat:", error);
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
const heartbeatInterval = setInterval(() => {
|
||||
sendHeartbeat();
|
||||
}, interval);
|
||||
|
||||
// Cleanup the interval when the component is unmounted
|
||||
return () => clearInterval(heartbeatInterval);
|
||||
}, []); // Empty dependency array ensures this runs once on mount
|
||||
|
||||
return null; // This component doesn't render anything
|
||||
};
|
||||
|
||||
export default Heartbeat;
|
||||
|
|
@ -30,7 +30,7 @@ import { PageViewTiming } from "@newrelic/browser-agent/features/page_view_timin
|
|||
import { PageViewEvent } from "@newrelic/browser-agent/features/page_view_event";
|
||||
import { Agent } from "@newrelic/browser-agent/loaders/agent";
|
||||
import { getCommonTelemetryAttributes } from "UITelemetry/generateTraces";
|
||||
|
||||
import Heartbeat from "Heartbeat";
|
||||
const { newRelic } = getAppsmithConfigs();
|
||||
const { enableNewRelic } = newRelic;
|
||||
|
||||
|
|
@ -73,8 +73,12 @@ if (enableNewRelic) {
|
|||
newRelicBrowserAgent.setCustomAttribute("appMode", appMode);
|
||||
}
|
||||
|
||||
const { cloudHosting } = getAppsmithConfigs();
|
||||
|
||||
const shouldAutoFreeze = process.env.NODE_ENV === "development";
|
||||
|
||||
const isProduction = process.env.NODE_ENV === "production";
|
||||
|
||||
setAutoFreeze(shouldAutoFreeze);
|
||||
runSagaMiddleware();
|
||||
|
||||
|
|
@ -96,6 +100,7 @@ function App() {
|
|||
<Sentry.ErrorBoundary fallback={"An error has occured"}>
|
||||
<Provider store={store}>
|
||||
<LayersContext.Provider value={Layers}>
|
||||
{cloudHosting && isProduction && <Heartbeat />}
|
||||
<ThemedAppWithProps />
|
||||
</LayersContext.Provider>
|
||||
</Provider>
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user