[Synthetics] Remove unused sync telemetry (#141349) (#142468)

(cherry picked from commit 31a688049d)

Co-authored-by: Shahzad <shahzad.muhammad@elastic.co>
This commit is contained in:
Kibana Machine 2022-10-03 07:55:54 -06:00 committed by GitHub
parent 65a2b68e18
commit 504f3a3a88
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 0 additions and 93 deletions

View file

@ -22,11 +22,8 @@ import {
MONITOR_UPDATE_CHANNEL,
MONITOR_CURRENT_CHANNEL,
MONITOR_ERROR_EVENTS_CHANNEL,
MONITOR_SYNC_STATE_CHANNEL,
MONITOR_SYNC_EVENTS_CHANNEL,
} from '../../legacy_uptime/lib/telemetry/constants';
import { MonitorErrorEvent } from '../../legacy_uptime/lib/telemetry/types';
import { MonitorSyncEvent } from '../../legacy_uptime/lib/telemetry/types';
export interface UpgradeError {
key?: string;
@ -50,23 +47,6 @@ export function sendTelemetryEvents(
}
}
export function sendSyncTelemetryEvents(
logger: Logger,
eventsTelemetry: TelemetryEventsSender | undefined,
updateEvent: MonitorSyncEvent
) {
if (eventsTelemetry === undefined) {
return;
}
try {
eventsTelemetry.queueTelemetryEvents(MONITOR_SYNC_STATE_CHANNEL, [updateEvent]);
eventsTelemetry.queueTelemetryEvents(MONITOR_SYNC_EVENTS_CHANNEL, [updateEvent]);
} catch (exc) {
logger.error(`queuing telemetry events failed ${exc}`);
}
}
export function sendErrorTelemetryEvents(
logger: Logger,
eventsTelemetry: TelemetryEventsSender | undefined,
@ -180,8 +160,6 @@ export function formatTelemetryDeleteEvent(
});
}
export function formatTelemetrySyncEvent() {}
function getScriptType(
attributes: Partial<MonitorFields>,
isInlineScript: boolean

View file

@ -16,8 +16,6 @@ import {
TaskInstance,
} from '@kbn/task-manager-plugin/server';
import { sendErrorTelemetryEvents } from '../routes/telemetry/monitor_upgrade_sender';
import { MonitorSyncEvent } from '../legacy_uptime/lib/telemetry/types';
import { sendSyncTelemetryEvents } from '../routes/telemetry/monitor_upgrade_sender';
import { UptimeServerSetup } from '../legacy_uptime/lib/adapters';
import { installSyntheticsIndexTemplates } from '../routes/synthetics_service/install_index_templates';
import { SyntheticsServiceApiKey } from '../../common/runtime_types/synthetics_service_api_key';
@ -317,11 +315,6 @@ export class SyntheticsService {
return null;
}
if (!configs && monitorConfigs.length > 0) {
const telemetry = this.getSyncTelemetry(monitorConfigs);
sendSyncTelemetryEvents(this.logger, this.server.telemetry, telemetry);
}
this.apiKey = await this.getApiKey();
if (!this.apiKey) {
@ -490,70 +483,6 @@ export class SyntheticsService {
formatMonitorConfig(Object.keys(config) as ConfigKey[], config as Partial<MonitorFields>)
);
}
getSyncTelemetry(monitors: SyntheticsMonitorWithId[]): MonitorSyncEvent {
let totalRuns = 0;
let browserTestRuns = 0;
let httpTestRuns = 0;
let icmpTestRuns = 0;
let tcpTestRuns = 0;
const locationRuns: Record<string, number> = {};
const locationMonitors: Record<string, number> = {};
const testRunsInDay = (schedule: string) => {
return (24 * 60) / Number(schedule);
};
const monitorsByType: Record<string, number> = {
browser: 0,
http: 0,
tcp: 0,
icmp: 0,
};
monitors.forEach((monitor) => {
if (monitor.schedule.number) {
totalRuns += testRunsInDay(monitor.schedule.number);
}
switch (monitor.type) {
case 'browser':
browserTestRuns += testRunsInDay(monitor.schedule.number);
break;
case 'http':
httpTestRuns += testRunsInDay(monitor.schedule.number);
break;
case 'icmp':
icmpTestRuns += testRunsInDay(monitor.schedule.number);
break;
case 'tcp':
tcpTestRuns += testRunsInDay(monitor.schedule.number);
break;
default:
break;
}
monitorsByType[monitor.type] = (monitorsByType[monitor.type] ?? 0) + 1;
monitor.locations.forEach(({ id }) => {
locationRuns[id + 'Tests'] =
(locationRuns[id + 'Tests'] ?? 0) + testRunsInDay(monitor.schedule.number);
locationMonitors[id + 'Monitors'] = (locationMonitors[id + 'Monitors'] ?? 0) + 1;
});
});
return {
total: monitors.length,
totalTests: totalRuns,
browserTests24h: browserTestRuns,
httpTests24h: httpTestRuns,
icmpTests24h: icmpTestRuns,
tcpTests24h: tcpTestRuns,
...locationRuns,
...locationMonitors,
...monitorsByType,
};
}
}
class IndexTemplateInstallationError extends Error {