refactor: Update logging in CheckHeartbeat.ts and Telemetry.ts

This commit is contained in:
Simon Larsen 2024-08-20 20:57:33 +01:00
parent fe8aa54f1c
commit adfb3e1db4
No known key found for this signature in database
GPG Key ID: 96C5DCA24769DBCA
4 changed files with 29 additions and 6 deletions

View File

@ -17,7 +17,12 @@ RunCron(
"IncomingRequestMonitor:CheckHeartbeat",
{ schedule: EVERY_THIRTY_SECONDS, runOnStartup: false },
async () => {
logger.debug("Checking IncomingRequestMonitor:CheckHeartbeat");
logger.debug(
"Checking IncomingRequestMonitor:CheckHeartbeat at " +
OneUptimeDate.getDateAsLocalFormattedString(
OneUptimeDate.getCurrentDate(),
),
);
const newIncomingRequestMonitors: Array<Monitor> =
await MonitorService.findBy({
@ -87,6 +92,10 @@ RunCron(
for (const monitor of totalIncomingRequestMonitors) {
try {
logger.debug(
`Processing incoming request monitor: ${monitor.id?.toString()}`,
);
if (!monitor.monitorSteps) {
logger.debug("Monitor has no steps. Skipping...");
continue;
@ -103,6 +112,10 @@ RunCron(
},
});
logger.debug(
`Updated incoming request monitor heartbeat checked at: ${monitor.id?.toString()}`,
);
const processRequest: boolean = shouldProcessRequest(monitor);
logger.debug(
@ -123,7 +136,15 @@ RunCron(
onlyCheckForIncomingRequestReceivedAt: true,
};
logger.debug(
`Processing incoming request monitor: ${monitor.id?.toString()}`,
);
await MonitorResourceUtil.monitorResource(incomingRequest);
logger.debug(
`Processed incoming request monitor: ${monitor.id?.toString()}`,
);
} catch (error) {
logger.error(
`Error while processing incoming request monitor: ${monitor.id?.toString()}`,

View File

@ -5,7 +5,6 @@ import {
Histogram,
MetricOptions,
} from "@opentelemetry/api/build/src/metrics/Metric";
import { getNodeAutoInstrumentations } from "@opentelemetry/auto-instrumentations-node";
import { OTLPLogExporter } from "@opentelemetry/exporter-logs-otlp-http";
import { OTLPMetricExporter } from "@opentelemetry/exporter-metrics-otlp-proto";
import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-proto";
@ -152,7 +151,11 @@ export default class Telemetry {
const nodeSdkConfiguration: Partial<opentelemetry.NodeSDKConfiguration> =
{
idGenerator: new AWSXRayIdGenerator(),
instrumentations: hasHeaders ? [getNodeAutoInstrumentations()] : [],
instrumentations: hasHeaders
? [
// Add instrumentations here
]
: [],
resource: this.getResource({
serviceName: data.serviceName,
}),

View File

@ -51,7 +51,6 @@
"@nivo/line": "^0.87.0",
"@opentelemetry/api": "^1.9.0",
"@opentelemetry/api-logs": "^0.52.1",
"@opentelemetry/auto-instrumentations-node": "^0.49.1",
"@opentelemetry/context-zone": "^1.25.0",
"@opentelemetry/exporter-logs-otlp-http": "^0.52.1",
"@opentelemetry/exporter-metrics-otlp-proto": "^0.52.1",

View File

@ -57,7 +57,7 @@ const getMonitorFetchQuery: GetMonitorFetchQueryFunction = (
};
router.get(
"/monitor/pending-list/:probeId",
"/monitor/pending-list/by-probe/:probeId",
ClusterKeyAuthorization.isAuthorizedServiceMiddleware,
async (
req: ExpressRequest,
@ -201,7 +201,7 @@ router.get(
// This API returns the count of the monitor waiting to be monitored.
router.get(
"/monitor/pending-count/:probeId",
"/monitor/pending-count/by-probe/:probeId",
ClusterKeyAuthorization.isAuthorizedServiceMiddleware,
async (
req: ExpressRequest,