diff --git a/lib/cjs/Synchronizer.js b/lib/cjs/Synchronizer.js index 1ba1571..b4aee70 100644 --- a/lib/cjs/Synchronizer.js +++ b/lib/cjs/Synchronizer.js @@ -37,25 +37,14 @@ class Synchronizer { exitCode: 0 }; try { - const errorPromises = this.config.errors.map((errorConfig) => __awaiter(this, void 0, void 0, function* () { - try { - this.runForErrorProvider(errorConfig, finalResult); - } - catch (e) { - finalResult.exitCode = 1; - finalResult.errors.push({ - message: e.message || e, - }); - console.error(e); - } - })); + const errorPromises = yield this.config.errors.map((errorConfig) => this.runForErrorProvider(errorConfig, finalResult)); const providerResults = yield Promise.allSettled(errorPromises); for (const [index, providerResult] of providerResults.entries()) { if (providerResult.status === 'rejected') { const providerName = this.config.errors[index].name; - console.error('An unexpected exception occurred while trying to synchronize errors for the ' + + console.error('An exception occurred while trying to synchronize errors for the ' + `provider named "${providerName}":`, providerResult.reason); - finalResult.exitCode = 2; + finalResult.exitCode = 1; finalResult.errors.push({ message: providerResult.reason.message || providerResult.reason, }); @@ -63,17 +52,17 @@ class Synchronizer { } } catch (e) { - finalResult.exitCode = 3; + finalResult.exitCode = 2; finalResult.errors.push({ message: e.message || e, }); console.error('An unexpected exception occurred while running the error synchronizations', e); } try { - this.config.cacheProvider.saveAllCaches(); + yield this.config.cacheProvider.saveAllCaches(); } catch (e) { - finalResult.exitCode = 4; + finalResult.exitCode = 3; finalResult.errors.push({ message: e.message || e, }); @@ -81,7 +70,7 @@ class Synchronizer { } if (finalResult.errors.length > 0) { console.error('Some errors were not synchronized to the ticketing and/or alerting system. Please see errors above.'); - finalResult.exitCode = finalResult.exitCode || 5; + finalResult.exitCode = finalResult.exitCode || 4; } return finalResult; }); @@ -93,7 +82,7 @@ class Synchronizer { errors.forEach((error) => this.addToErrorGroups(error, errorGroups, errorConfig.name)); for (const errorGroup of errorGroups) { try { - this.syncErrorGroup(errorGroup, errorConfig); + yield this.syncErrorGroup(errorGroup, errorConfig); result.completedErrorGroups.push(errorGroup); } catch (e) { @@ -110,7 +99,9 @@ class Synchronizer { } syncErrorGroup(errorGroup, errorConfig) { return __awaiter(this, void 0, void 0, function* () { - errorGroup.priority = yield errorConfig.prioritizationProvider.determinePriority(errorGroup); + const { priority, priorityReason } = yield errorConfig.prioritizationProvider.determinePriority(errorGroup); + errorGroup.priority = priority; + errorGroup.priorityReason = priorityReason; errorGroup.ticket = yield this.config.cacheProvider.getObject(errorGroup.clientId, models_1.CacheName.Tickets); errorGroup.alert = yield this.config.cacheProvider.getObject(errorGroup.clientId, models_1.CacheName.Alerts); if (!errorGroup.ticket) { @@ -131,7 +122,7 @@ class Synchronizer { errorGroup.ticket = yield this.config.ticketProvider.reopenTicket(errorGroup.ticket); isTicketReopened = true; } - this.config.cacheProvider.setObject(errorGroup.ticket.id, errorGroup.ticket, models_1.CacheName.Tickets, false); + yield this.config.cacheProvider.setObject(errorGroup.clientId, errorGroup.ticket, models_1.CacheName.Tickets, false); if (!errorGroup.alert) { errorGroup.alert = yield this.config.alertProvider.findAlert(errorGroup.clientId); } @@ -142,24 +133,27 @@ class Synchronizer { Object.assign(errorGroup.alert, freshAlertContent); errorGroup.alert = yield this.config.alertProvider.updateAlert(errorGroup.alert); } - this.config.cacheProvider.setObject(errorGroup.alert.id, errorGroup.alert, models_1.CacheName.Alerts, false); + yield this.config.cacheProvider.setObject(errorGroup.clientId, errorGroup.alert, models_1.CacheName.Alerts, false); }); } createErrorGroup(error, sourceName) { const maxNameLength = 500; - error.name = `[${sourceName}] ${error.name}`.substr(0, maxNameLength); + error.name = error.name.substr(0, maxNameLength); let normalizedName = error.name; normalizedName = normalizedName.replace(/\.(js|jsx|ts|tsx|php|py|go|java|cpp|h|c|cs|ex|exs|rb)[:@]\d+/i, '.$1:XXX'); normalizedName = normalizedName.replace(/(TypeError:\s*)/i, ''); - const hash = crypto_1.default.createHash('md5').update(normalizedName).digest('hex'); + const clientIdInput = `${sourceName}:${normalizedName}`; + const clientId = crypto_1.default.createHash('md5').update(clientIdInput).digest('hex'); return { name: normalizedName, sourceName, type: error.type, priority: models_1.ErrorPriority.P5, - clientId: hash, + priorityReason: 'Unknown', + clientId, count: error.count, countType: error.countType, + countPeriodHours: error.countPeriodHours, ticket: null, alert: null, instances: [error], diff --git a/lib/cjs/Synchronizer.js.map b/lib/cjs/Synchronizer.js.map index d09d944..f714544 100644 --- a/lib/cjs/Synchronizer.js.map +++ b/lib/cjs/Synchronizer.js.map @@ -1 +1 @@ -{"version":3,"file":"Synchronizer.js","sourceRoot":"","sources":["../../src/Synchronizer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,oDAA4B;AAC5B,qCAAmH;AAQnH,2CAA+D;AA4B/D,MAAa,YAAY;IAGvB,YAAmB,MAA0B;;QAC3C,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QAGrB,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE;YACnC,MAAM,IAAI,KAAK,CAAC,oEAAoE,CAAC,CAAC;SACvF;QAGD,KAAK,MAAM,QAAQ,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE;YACzC,MAAA,QAAQ,CAAC,aAAa,oCAAtB,QAAQ,CAAC,aAAa,GAAK,EAAE,EAAC;YAC9B,MAAA,QAAQ,CAAC,SAAS,oCAAlB,QAAQ,CAAC,SAAS,GAAK,IAAI,EAAC;YAC5B,MAAA,QAAQ,CAAC,sBAAsB,oCAA/B,QAAQ,CAAC,sBAAsB,GAAK,IAAI,4CAAgC,EAAE,EAAC;SAC5E;IACH,CAAC;IAEY,GAAG;;YACd,MAAM,WAAW,GAAuB;gBACtC,oBAAoB,EAAE,EAAE;gBACxB,MAAM,EAAE,EAAE;gBACV,QAAQ,EAAE,CAAC;aACZ,CAAC;YAGF,IAAI;gBACF,MAAM,aAAa,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAO,WAAW,EAAE,EAAE;oBACjE,IAAI;wBACF,IAAI,CAAC,mBAA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CAAC,CAAC;gBACzC,OAAO;aACR;SACF;QAGD,WAAW,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IAClC,CAAC;IAEO,uBAAuB,CAAC,cAAsB;QACpD,IAAI,cAAc,CAAC,MAAM,EAAE;YACzB,OAAO,KAAK,CAAC;SACd;QAGD,MAAM,WAAW,GAAG,IAAI,IAAI,EAAE,CAAC;QAC/B,MAAM,cAAc,GAAG,IAAI,IAAI,CAAC,cAAc,CAAC,cAAc,CAAC,CAAC;QAC/D,MAAM,WAAW,GAAG,CAAC,WAAW,CAAC,OAAO,EAAE,GAAG,cAAc,CAAC,OAAO,EAAE,CAAC,GAAG,IAAI,CAAC;QAC9E,OAAO,CAAC,WAAW,IAAI,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC;IACzC,CAAC;IAEO,oBAAoB,CAAC,cAAsB,EAAE,kBAAiC;QACpF,OAAO,cAAc,CAAC,OAAO,KAAK,kBAAkB,CAAC,OAAO;YAC1D,cAAc,CAAC,WAAW,KAAK,kBAAkB,CAAC,WAAW;YAC7D,cAAc,CAAC,QAAQ,KAAK,kBAAkB,CAAC,QAAQ,CAAC;IAC5D,CAAC;IAEO,mBAAmB,CAAC,aAAoB,EAAE,iBAA+B;QAC/E,OAAO,aAAa,CAAC,OAAO,KAAK,iBAAiB,CAAC,OAAO;YACxD,aAAa,CAAC,WAAW,KAAK,iBAAiB,CAAC,WAAW;YAC3D,aAAa,CAAC,QAAQ,KAAK,iBAAiB,CAAC,QAAQ;YACrD,aAAa,CAAC,SAAS,KAAK,iBAAiB,CAAC,SAAS,CAAC;IAC5D,CAAC;CACF;AAjOD,oCAiOC"} \ No newline at end of file diff --git a/lib/cjs/interfaces/AlertProviderInterface.d.ts b/lib/cjs/interfaces/AlertProviderInterface.d.ts index 2111cda..86c1029 100644 --- a/lib/cjs/interfaces/AlertProviderInterface.d.ts +++ b/lib/cjs/interfaces/AlertProviderInterface.d.ts @@ -1,6 +1,6 @@ import { ErrorGroup, Alert, AlertContent } from '../models'; export interface AlertProviderInterface { - findAlert(clientId: string): Promise; + findAlert(clientId: string): Promise; createAlert(alertContent: AlertContent): Promise; updateAlert(alert: Alert): Promise; generateAlertContent(errorGroup: ErrorGroup): Promise; diff --git a/lib/cjs/interfaces/PrioritizationProviderInterface.d.ts b/lib/cjs/interfaces/PrioritizationProviderInterface.d.ts index 2464163..d697ecf 100644 --- a/lib/cjs/interfaces/PrioritizationProviderInterface.d.ts +++ b/lib/cjs/interfaces/PrioritizationProviderInterface.d.ts @@ -1,4 +1,8 @@ import { ErrorGroup, ErrorPriority } from '../models'; +export declare type ErrorPrioritizationResult = { + priority: ErrorPriority; + priorityReason: string; +}; export interface PrioritizationProviderInterface { - determinePriority(errorGroup: ErrorGroup): Promise; + determinePriority(errorGroup: ErrorGroup): Promise; } diff --git a/lib/cjs/models/Error.d.ts b/lib/cjs/models/Error.d.ts index c5a5934..a0e2dfe 100644 --- a/lib/cjs/models/Error.d.ts +++ b/lib/cjs/models/Error.d.ts @@ -8,28 +8,31 @@ export declare enum ErrorPriority { P5 = "P5" } export declare enum ErrorCountType { - USERS = "Users", - TRX = "Transactions" + USERS = "users", + TRX = "transactions" } export declare enum ErrorType { - CLIENT = "Client", - SERVER = "Server" + CLIENT = "client", + SERVER = "server" } export declare type Error = { - name: any; - type: any; - count: any; - countType: any; - debugUrl: any; + name: string; + type: ErrorType; + count: number; + countType: ErrorCountType; + countPeriodHours: number; + debugUrl: string; }; export declare type ErrorGroup = { name: string; sourceName: string; type: ErrorType; priority: string; + priorityReason: string; clientId: string; count: number; countType: ErrorCountType; + countPeriodHours: number; ticket: Ticket; alert: Alert; instances: Error[]; diff --git a/lib/cjs/models/Error.js b/lib/cjs/models/Error.js index c8eb6c7..c9d8fad 100644 --- a/lib/cjs/models/Error.js +++ b/lib/cjs/models/Error.js @@ -11,12 +11,12 @@ var ErrorPriority; })(ErrorPriority = exports.ErrorPriority || (exports.ErrorPriority = {})); var ErrorCountType; (function (ErrorCountType) { - ErrorCountType["USERS"] = "Users"; - ErrorCountType["TRX"] = "Transactions"; + ErrorCountType["USERS"] = "users"; + ErrorCountType["TRX"] = "transactions"; })(ErrorCountType = exports.ErrorCountType || (exports.ErrorCountType = {})); var ErrorType; (function (ErrorType) { - ErrorType["CLIENT"] = "Client"; - ErrorType["SERVER"] = "Server"; + ErrorType["CLIENT"] = "client"; + ErrorType["SERVER"] = "server"; })(ErrorType = exports.ErrorType || (exports.ErrorType = {})); //# sourceMappingURL=Error.js.map \ No newline at end of file diff --git a/lib/cjs/providers/ErrorCountPrioritizationProvider.d.ts b/lib/cjs/providers/ErrorCountPrioritizationProvider.d.ts index a767ea8..248bb95 100644 --- a/lib/cjs/providers/ErrorCountPrioritizationProvider.d.ts +++ b/lib/cjs/providers/ErrorCountPrioritizationProvider.d.ts @@ -1,5 +1,5 @@ import { ErrorGroup, ErrorPriority } from '../models'; -import { PrioritizationProviderInterface } from '../interfaces'; +import { ErrorPrioritizationResult, PrioritizationProviderInterface } from '../interfaces'; export declare type ErrorCountPrioritizationProviderThreshold = { threshold: number; priority: ErrorPriority; @@ -18,5 +18,5 @@ export declare const DefaultErrorCountPrioritizationProviderConfig: { export declare class ErrorCountPrioritizationProvider implements PrioritizationProviderInterface { private config; constructor(config?: ErrorCountPrioritizationProviderConfig); - determinePriority(errorGroup: ErrorGroup): Promise; + determinePriority(errorGroup: ErrorGroup): Promise; } diff --git a/lib/cjs/providers/ErrorCountPrioritizationProvider.js b/lib/cjs/providers/ErrorCountPrioritizationProvider.js index e8ea2bc..c0c2115 100644 --- a/lib/cjs/providers/ErrorCountPrioritizationProvider.js +++ b/lib/cjs/providers/ErrorCountPrioritizationProvider.js @@ -11,6 +11,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge Object.defineProperty(exports, "__esModule", { value: true }); exports.ErrorCountPrioritizationProvider = exports.DefaultErrorCountPrioritizationProviderConfig = void 0; const models_1 = require("../models"); +const ErrorUtil_1 = require("../util/ErrorUtil"); exports.DefaultErrorCountPrioritizationProviderConfig = { thresholds: [{ threshold: 1, @@ -42,7 +43,11 @@ class ErrorCountPrioritizationProvider { return __awaiter(this, void 0, void 0, function* () { for (const threshold of this.config.thresholds) { if (errorGroup.count < threshold.threshold) { - return threshold.priority; + const countPeriod = (0, ErrorUtil_1.getReadableErrorCountPeriod)(errorGroup.countPeriodHours); + return { + priority: threshold.priority, + priorityReason: `Affecting ${threshold.label} ${errorGroup.countType} per ${countPeriod}`, + }; } } }); diff --git a/lib/cjs/providers/ErrorCountPrioritizationProvider.js.map b/lib/cjs/providers/ErrorCountPrioritizationProvider.js.map index 0478449..67cb4f6 100644 --- a/lib/cjs/providers/ErrorCountPrioritizationProvider.js.map +++ b/lib/cjs/providers/ErrorCountPrioritizationProvider.js.map @@ -1 +1 @@ -{"version":3,"file":"ErrorCountPrioritizationProvider.js","sourceRoot":"","sources":["../../../src/providers/ErrorCountPrioritizationProvider.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,sCAAsD;AAazC,QAAA,6CAA6C,GAAG;IAC3D,UAAU,EAAE,CAAC;YAEX,SAAS,EAAE,CAAC;YACZ,QAAQ,EAAE,sBAAa,CAAC,EAAE;YAC1B,KAAK,EAAE,GAAG;SACX,EAAE;YAED,SAAS,EAAE,EAAE;YACb,QAAQ,EAAE,sBAAa,CAAC,EAAE;YAC1B,KAAK,EAAE,eAAe;SACvB,EAAE;YAED,SAAS,EAAE,EAAE;YACb,QAAQ,EAAE,sBAAa,CAAC,EAAE;YAC1B,KAAK,EAAE,gBAAgB;SACxB,EAAE;YAED,SAAS,EAAE,EAAE;YACb,QAAQ,EAAE,sBAAa,CAAC,EAAE;YAC1B,KAAK,EAAE,gBAAgB;SACxB,EAAE;YAED,SAAS,EAAE,MAAM,CAAC,gBAAgB;YAClC,QAAQ,EAAE,sBAAa,CAAC,EAAE;YAC1B,KAAK,EAAE,OAAO;SACf,CAAC;CACH,CAAC;AAEF,MAAa,gCAAgC;IAG3C,YAAmB,MAA+C;QAChE,IAAI,CAAC,MAAM,GAAG,MAAM,aAAN,MAAM,cAAN,MAAM,GAAI,qDAA6C,CAAC;IACxE,CAAC;IAEY,iBAAiB,CAAC,UAAsB;;YACnD,KAAK,MAAM,SAAS,IAAI,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE;gBAC9C,IAAI,UAAU,CAAC,KAAK,GAAG,SAAS,CAAC,SAAS,EAAE;oBAC1C,OAAO,SAAS,CAAC,QAAQ,CAAC;iBAC3B;aACF;QACH,CAAC;KAAA;CACF;AAdD,4EAcC"} \ No newline at end of file +{"version":3,"file":"ErrorCountPrioritizationProvider.js","sourceRoot":"","sources":["../../../src/providers/ErrorCountPrioritizationProvider.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,sCAAsD;AAEtD,iDAAgE;AAYnD,QAAA,6CAA6C,GAAG;IAC3D,UAAU,EAAE,CAAC;YAEX,SAAS,EAAE,CAAC;YACZ,QAAQ,EAAE,sBAAa,CAAC,EAAE;YAC1B,KAAK,EAAE,GAAG;SACX,EAAE;YAED,SAAS,EAAE,EAAE;YACb,QAAQ,EAAE,sBAAa,CAAC,EAAE;YAC1B,KAAK,EAAE,eAAe;SACvB,EAAE;YAED,SAAS,EAAE,EAAE;YACb,QAAQ,EAAE,sBAAa,CAAC,EAAE;YAC1B,KAAK,EAAE,gBAAgB;SACxB,EAAE;YAED,SAAS,EAAE,EAAE;YACb,QAAQ,EAAE,sBAAa,CAAC,EAAE;YAC1B,KAAK,EAAE,gBAAgB;SACxB,EAAE;YAED,SAAS,EAAE,MAAM,CAAC,gBAAgB;YAClC,QAAQ,EAAE,sBAAa,CAAC,EAAE;YAC1B,KAAK,EAAE,OAAO;SACf,CAAC;CACH,CAAC;AAEF,MAAa,gCAAgC;IAG3C,YAAmB,MAA+C;QAChE,IAAI,CAAC,MAAM,GAAG,MAAM,aAAN,MAAM,cAAN,MAAM,GAAI,qDAA6C,CAAC;IACxE,CAAC;IAEY,iBAAiB,CAAC,UAAsB;;YACnD,KAAK,MAAM,SAAS,IAAI,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE;gBAC9C,IAAI,UAAU,CAAC,KAAK,GAAG,SAAS,CAAC,SAAS,EAAE;oBAC1C,MAAM,WAAW,GAAG,IAAA,uCAA2B,EAAC,UAAU,CAAC,gBAAgB,CAAC,CAAC;oBAC7E,OAAO;wBACL,QAAQ,EAAE,SAAS,CAAC,QAAQ;wBAC5B,cAAc,EAAE,aAAa,SAAS,CAAC,KAAK,IAAI,UAAU,CAAC,SAAS,QAAQ,WAAW,EAAE;qBAC1F,CAAC;iBACH;aACF;QACH,CAAC;KAAA;CACF;AAlBD,4EAkBC"} \ No newline at end of file diff --git a/lib/cjs/providers/JiraTicketProvider.js b/lib/cjs/providers/JiraTicketProvider.js index e7d9562..1574864 100644 --- a/lib/cjs/providers/JiraTicketProvider.js +++ b/lib/cjs/providers/JiraTicketProvider.js @@ -135,13 +135,13 @@ class JiraTicketProvider { generateTicketContent(errorGroup) { return __awaiter(this, void 0, void 0, function* () { const maxInstances = 10; - const summary = `[${errorGroup.type}] ${errorGroup.name}`; - let description = errorGroup.name + - '\n\nh3.Frequency' + - `${errorGroup.count} ${errorGroup.countType} per day` + - '\n\nh3.Instances'; + const summary = `[${errorGroup.type}] [${errorGroup.sourceName}] ${errorGroup.name}`; + let description = `{noformat}${errorGroup.name}{noformat}` + + '\nh4.Priority Reason\n' + + `${errorGroup.priorityReason}` + + '\nh4.Instances\n'; for (const instance of errorGroup.instances.slice(0, maxInstances)) { - description += `${instance.name}\n\nTroubleshoot at: [${instance.debugUrl}]`; + description += `{noformat}${instance.name}{noformat}\n\nTroubleshoot at: [${instance.debugUrl}]`; } if (errorGroup.instances.length > 10) { const additional = (errorGroup.instances.length - maxInstances); @@ -152,7 +152,12 @@ class JiraTicketProvider { summary, description, priority: this.config.ticket.priorityMap[errorGroup.priority], - labels: ['error_sync', `error:${errorGroup.clientId}`], + labels: [ + 'error_sync', + `error:${errorGroup.clientId}`, + errorGroup.sourceName, + errorGroup.type, + ], }; }); } diff --git a/lib/cjs/providers/JiraTicketProvider.js.map b/lib/cjs/providers/JiraTicketProvider.js.map index d348d4e..55e9ab2 100644 --- a/lib/cjs/providers/JiraTicketProvider.js.map +++ b/lib/cjs/providers/JiraTicketProvider.js.map @@ -1 +1 @@ -{"version":3,"file":"JiraTicketProvider.js","sourceRoot":"","sources":["../../../src/providers/JiraTicketProvider.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,sCAA6E;AAC7E,8DAAkC;AA6BlC,MAAa,kBAAkB;IAI7B,YAAmB,MAAgC;QACjD,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC;QAGjD,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,WAAW,EAAE;YACnC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,WAAW,GAAG;gBAC/B,CAAC,sBAAa,CAAC,EAAE,CAAC,EAAE,SAAS;gBAC7B,CAAC,sBAAa,CAAC,EAAE,CAAC,EAAE,MAAM;gBAC1B,CAAC,sBAAa,CAAC,EAAE,CAAC,EAAE,QAAQ;gBAC5B,CAAC,sBAAa,CAAC,EAAE,CAAC,EAAE,KAAK;gBACzB,CAAC,sBAAa,CAAC,EAAE,CAAC,EAAE,QAAQ;aAC7B,CAAC;SACH;QAED,MAAM,gBAAgB,GAAQ;YAC5B,QAAQ,EAAE,OAAO;YACjB,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI;YACtB,UAAU,EAAE,GAAG;YACf,SAAS,EAAE,IAAI;SAChB,CAAC;QAEF,IAAI,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE;YACzB,gBAAgB,CAAC,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC;YAC3D,gBAAgB,CAAC,QAAQ,GAAG,IAAI,CAAC,MAAM,CAA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C,MAAM,GAAG,EAAE,EAAE;gBACpC,MAAM,UAAU,GAAG,CAAC,UAAU,CAAC,SAAS,CAAC,MAAM,GAAG,YAAY,CAAC,CAAC;gBAChE,WAAW,IAAI,WAAW,UAAU,6BAA6B,CAAC;aACnE;YAED,OAAO;gBACL,QAAQ,EAAE,UAAU,CAAC,QAAQ;gBAC7B,OAAO;gBACP,WAAW;gBACX,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,UAAU,CAAC,QAAQ,CAAC;gBAC7D,MAAM,EAAE,CAAC,YAAY,EAAE,SAAS,UAAU,CAAC,QAAQ,EAAE,CAAC;aACvD,CAAA;QACH,CAAC;KAAA;IAEO,aAAa,CAAC,GAAW;QAC/B,OAAO,WAAW,IAAI,CAAC,MAAM,CAAC,IAAI,WAAW,GAAG,EAAE,CAAA;IACpD,CAAC;CACF;AAjKD,gDAiKC"} \ No newline at end of file +{"version":3,"file":"JiraTicketProvider.js","sourceRoot":"","sources":["../../../src/providers/JiraTicketProvider.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,sCAA6E;AAC7E,8DAAkC;AA8BlC,MAAa,kBAAkB;IAI7B,YAAmB,MAAgC;QACjD,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC;QAGjD,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,WAAW,EAAE;YACnC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,WAAW,GAAG;gBAC/B,CAAC,sBAAa,CAAC,EAAE,CAAC,EAAE,SAAS;gBAC7B,CAAC,sBAAa,CAAC,EAAE,CAAC,EAAE,MAAM;gBAC1B,CAAC,sBAAa,CAAC,EAAE,CAAC,EAAE,QAAQ;gBAC5B,CAAC,sBAAa,CAAC,EAAE,CAAC,EAAE,KAAK;gBACzB,CAAC,sBAAa,CAAC,EAAE,CAAC,EAAE,QAA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AU,CAAC,IAAI,EAAE,CAAC;YAErF,IAAI,WAAW,GAAG,aAAa,UAAU,CAAC,IAAI,YAAY;gBACxD,wBAAwB;gBACxB,GAAG,UAAU,CAAC,cAAc,EAAE;gBAC9B,kBAAkB,CAAC;YAErB,KAAK,MAAM,QAAQ,IAAI,UAAU,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,EAAE,YAAY,CAAC,EAAE;gBAClE,WAAW,IAAI,aAAa,QAAQ,CAAC,IAAI,mCAAmC,QAAQ,CAAC,QAAQ,GAAG,CAAC;aAClG;YAED,IAAI,UAAU,CAAC,SAAS,CAAC,MAAM,GAAG,EAAE,EAAE;gBACpC,MAAM,UAAU,GAAG,CAAC,UAAU,CAAC,SAAS,CAAC,MAAM,GAAG,YAAY,CAAC,CAAC;gBAChE,WAAW,IAAI,WAAW,UAAU,6BAA6B,CAAC;aACnE;YAED,OAAO;gBACL,QAAQ,EAAE,UAAU,CAAC,QAAQ;gBAC7B,OAAO;gBACP,WAAW;gBACX,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,UAAU,CAAC,QAAQ,CAAC;gBAC7D,MAAM,EAAE;oBACN,YAAY;oBACZ,SAAS,UAAU,CAAC,QAAQ,EAAE;oBAC9B,UAAU,CAAC,UAAU;oBACrB,UAAU,CAAC,IAAI;iBAChB;aACF,CAAA;QACH,CAAC;KAAA;IAEO,aAAa,CAAC,GAAW;QAC/B,OAAO,WAAW,IAAI,CAAC,MAAM,CAAC,IAAI,WAAW,GAAG,EAAE,CAAA;IACpD,CAAC;CACF;AAtKD,gDAsKC"} \ No newline at end of file diff --git a/lib/cjs/providers/NewRelicServerErrorProvider.js b/lib/cjs/providers/NewRelicServerErrorProvider.js index de64fbe..e12c6c0 100644 --- a/lib/cjs/providers/NewRelicServerErrorProvider.js +++ b/lib/cjs/providers/NewRelicServerErrorProvider.js @@ -53,6 +53,7 @@ class NewRelicServerErrorProvider { newRelicError.type = models_1.ErrorType.SERVER; newRelicError.count = (newRelicError.uniqueCount > 0 ? newRelicError.uniqueCount : newRelicError.count); newRelicError.countType = newRelicError.uniqueCount > 0 ? models_1.ErrorCountType.USERS : models_1.ErrorCountType.TRX; + newRelicError.countPeriodHours = hoursBack; }); const appId = newRelicError.max; const filters = [{ diff --git a/lib/cjs/providers/NewRelicServerErrorProvider.js.map b/lib/cjs/providers/NewRelicServerErrorProvider.js.map index 935450a..e340427 100644 --- a/lib/cjs/providers/NewRelicServerErrorProvider.js.map +++ b/lib/cjs/providers/NewRelicServerErrorProvider.js.map @@ -1 +1 @@ -{"version":3,"file":"NewRelicServerErrorProvider.js","sourceRoot":"","sources":["../../../src/providers/NewRelicServerErrorProvider.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,sCAA6D;AAE7D,8EAA8C;AAW9C,MAAa,2BAA2B;IAItC,YAAmB,MAAyC;QAC1D,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAEY,SAAS,CAAC,SAAS,GAAE,EAAE,EAAE,KAAK,GAAG,IAAI;;YAChD,MAAM,IAAI,GAAG;;;;;;cAMH,SAAS;cACT,KAAK;KACd,CAAC;YAEF,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;gBACrC,6BAAW,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE;oBAClF,IAAI,KAAK,EAAE;wBACT,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;qBACtB;yBAAM,IAAI,QAAQ,CAAC,UAAU,IAAI,GAAG,EAAE;wBACrC,OAAO,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;qBAC9B;yBAAM,IAAI,QAAQ,CAAC,UAAU,GAAG,GAAG,EAAE;wBACpC,OAAO,OAAO,CAAC,EAAE,CAAC,CAAC;qBACpB;yBAA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,OAAO,CAAC,MAAM,CAAC,CAAC;gBAClB,CAAC,CAAC,CAAC;YACL,CAAC,CAAC,CAAC;QACL,CAAC;KAAA;CACF;AA/DD,kEA+DC"} \ No newline at end of file +{"version":3,"file":"NewRelicServerErrorProvider.js","sourceRoot":"","sources":["../../../src/providers/NewRelicServerErrorProvider.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,sCAA6D;AAE7D,8EAA8C;AAW9C,MAAa,2BAA2B;IAItC,YAAmB,MAAyC;QAC1D,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAEY,SAAS,CAAC,SAAS,GAAE,EAAE,EAAE,KAAK,GAAG,IAAI;;YAChD,MAAM,IAAI,GAAG;;;;;;cAMH,SAAS;cACT,KAAK;KACd,CAAC;YAEF,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;gBACrC,6BAAW,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE;oBAClF,IAAI,KAAK,EAAE;wBACT,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;qBACtB;yBAAM,IAAI,QAAQ,CAAC,UAAU,IAAI,GAAG,EAAE;wBACrC,OAAO,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;qBAC9B;yBAAM,IAAI,QAAQ,CAAC,UAAU,GAAG,GAAG,EAAE;wBACpC,OAAO,OAAO,CAAC,EAAE,CAAC,CAAC;qBACpB;yBAAM,IAAI,QAAQ,CAAC,IAAI,CAAC,KAAK,EAAE;wBAC9B,OAAO,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;qBAC3B;oBAED,MAAM,MAAM,GAAG,EAAE,CAAC;oBAElB,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,aAAa,EAAE,EAAE;wBACpC,aAAa,CAAC,OA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AlertProvider.d.ts index d216691..7e85524 100644 --- a/lib/cjs/providers/OpsGenieAlertProvider.d.ts +++ b/lib/cjs/providers/OpsGenieAlertProvider.d.ts @@ -8,7 +8,7 @@ export declare type OpsGenieAlertProviderConfig = { export declare class OpsGenieAlertProvider implements AlertProviderInterface { private config; constructor(config: OpsGenieAlertProviderConfig); - findAlert(clientId: string): Promise; + findAlert(clientId: string): Promise; createAlert(alertContent: AlertContent): Promise; updateAlert(alert: Alert): Promise; generateAlertContent(errorGroup: ErrorGroup): Promise; diff --git a/lib/cjs/providers/OpsGenieAlertProvider.js b/lib/cjs/providers/OpsGenieAlertProvider.js index 5a0eaa5..5346327 100644 --- a/lib/cjs/providers/OpsGenieAlertProvider.js +++ b/lib/cjs/providers/OpsGenieAlertProvider.js @@ -38,18 +38,34 @@ class OpsGenieAlertProvider { identifier: clientId, identifierType: 'alias', }, (error, response) => { - return (error ? reject(error) : resolve(response.data)); + if (!error) { + return resolve(response.data); + } + else if (error.httpStatusCode === 404) { + return resolve(undefined); + } + else if (error instanceof Error) { + return reject(error); + } + else { + return reject(new Error(error.message || error)); + } }); }); - return { - id: clientId, - clientId, - summary: opsgenieAlert.message, - description: opsgenieAlert.description, - priority: opsgenieAlert.priority, - labels: [], - ticketUrl: opsgenieAlert.details['Ticket Link'], - }; + if (!opsgenieAlert) { + return undefined; + } + else { + return { + id: clientId, + clientId, + summary: opsgenieAlert.message, + description: opsgenieAlert.description, + priority: opsgenieAlert.priority, + labels: [], + ticketUrl: opsgenieAlert.details['Ticket Link'], + }; + } }); } createAlert(alertContent) { @@ -89,7 +105,7 @@ class OpsGenieAlertProvider { generateAlertContent(errorGroup) { var _a; return __awaiter(this, void 0, void 0, function* () { - const summary = `[BUG] ${errorGroup.name}`.substr(0, 130); + const summary = `[${errorGroup.type}] [${errorGroup.sourceName}] ${errorGroup.name}`.substr(0, 130); return { clientId: errorGroup.clientId, summary, diff --git a/lib/cjs/providers/OpsGenieAlertProvider.js.map b/lib/cjs/providers/OpsGenieAlertProvider.js.map index f2f9e51..118a806 100644 --- a/lib/cjs/providers/OpsGenieAlertProvider.js.map +++ b/lib/cjs/providers/OpsGenieAlertProvider.js.map @@ -1 +1 @@ -{"version":3,"file":"OpsGenieAlertProvider.js","sourceRoot":"","sources":["../../../src/providers/OpsGenieAlertProvider.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,sCAA2E;AAE3E,gEAAoC;AAQpC,MAAa,qBAAqB;IAGhC,YAAY,MAAmC;QAC7C,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC;QAEjD,sBAAQ,CAAC,SAAS,CAAC;YACjB,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM;SAC5B,CAAC,CAAC;QAGH,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE;YAC5B,IAAI,CAAC,MAAM,CAAC,WAAW,GAAG;gBACxB,CAAC,sBAAa,CAAC,EAAE,CAAC,EAAE,IAAI;gBACxB,CAAC,sBAAa,CAAC,EAAE,CAAC,EAAE,IAAI;gBACxB,CAAC,sBAAa,CAAC,EAAE,CAAC,EAAE,IAAI;gBACxB,CAAC,sBAAa,CAAC,EAAE,CAAC,EAAE,IAAI;gBACxB,CAAC,sBAAa,CAAC,EAAE,CAAC,EAAE,IAAI;aACzB,CAAC;SACH;IACH,CAAC;IAEY,SAAS,CAAC,QAAgB;;YACrC,MAAM,aAAa,GAAQ,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;gBAC/D,sBAAQ,CAAC,OAAO,CAAC,GAAG,CAAC;oBACnB,UAAU,EAAE,QAAQ;oBACpB,cAAc,EAAE,OAAO;iBACxB,EAAE,CAAC,KAAK,EAAE,QAAQ,EAAE,EAAE;oBACrB,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC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AQ,EAAE,EAAE;oBACrB,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC;gBACrD,CAAC,CAAC,CAAC;YACL,CAAC,CAAC,CAAC;YAEH,OAAO,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;QACjC,CAAC;KAAA;IAEY,oBAAoB,CAAC,UAAsB;;;YACtD,MAAM,OAAO,GAAG,IAAI,UAAU,CAAC,IAAI,MAAM,UAAU,CAAC,UAAU,KAAK,UAAU,CAAC,IAAI,EAAE,CAAC,MAAM,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;YAEpG,OAAO;gBACL,QAAQ,EAAE,UAAU,CAAC,QAAQ;gBAC7B,OAAO;gBACP,WAAW,EAAE,UAAU,CAAC,IAAI;gBAC5B,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,UAAU,CAAC,QAAQ,CAAC;gBACtD,MAAM,EAAE,EAAE;gBACV,SAAS,EAAE,MAAA,UAAU,CAAC,MAAM,0CAAE,GAAG;aAClC,CAAA;;KACF;CACF;AAvGD,sDAuGC"} \ No newline at end of file diff --git a/lib/cjs/providers/S3CacheProvider.js b/lib/cjs/providers/S3CacheProvider.js index 8b9cb0b..0c1aa92 100644 --- a/lib/cjs/providers/S3CacheProvider.js +++ b/lib/cjs/providers/S3CacheProvider.js @@ -13,7 +13,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) { }; Object.defineProperty(exports, "__esModule", { value: true }); exports.S3CacheProvider = void 0; -const models_1 = require("../models"); const aws_sdk_1 = __importDefault(require("aws-sdk")); class S3CacheProvider { constructor(config) { @@ -41,7 +40,7 @@ class S3CacheProvider { saveAllCaches() { return __awaiter(this, void 0, void 0, function* () { for (const cacheName in this.caches) { - yield this.setCache(models_1.CacheName[cacheName], this.caches[cacheName]); + yield this.setCache(cacheName, this.caches[cacheName]); } }); } @@ -67,7 +66,6 @@ class S3CacheProvider { } setCache(name, data) { return __awaiter(this, void 0, void 0, function* () { - console.log('Saving', data); const s3 = new aws_sdk_1.default.S3(); const params = { Bucket: this.config.bucket, diff --git a/lib/cjs/providers/S3CacheProvider.js.map b/lib/cjs/providers/S3CacheProvider.js.map index 3a666bb..bf0816a 100644 --- a/lib/cjs/providers/S3CacheProvider.js.map +++ b/lib/cjs/providers/S3CacheProvider.js.map @@ -1 +1 @@ -{"version":3,"file":"S3CacheProvider.js","sourceRoot":"","sources":["../../../src/providers/S3CacheProvider.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,sCAAsC;AAEtC,sDAA0B;AAQ1B,MAAa,eAAe;IAI1B,YAAmB,MAA6B;QAFxC,WAAM,GAAwB,EAAE,CAAC;QAGvC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QAErB,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE;YACtB,iBAAG,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;SACnD;IACH,CAAC;IAEY,SAAS,CAAI,EAAU,EAAE,SAAoB;;YACxD,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;YAC7C,OAAO,KAAK,CAAC,EAAE,CAAC,CAAC;QACnB,CAAC;KAAA;IAEY,SAAS,CAAI,EAAU,EAAE,KAAQ,EAAE,SAAoB,EAAE,SAAS,GAAG,KAAK;;YACrF,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;YAC7C,KAAK,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC;YAElB,IAAI,SAAS,EAAE;gBACb,OAAO,MAAM,IAAI,CAAC,QAAQ,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;aAC9C;QACH,CAAC;KAAA;IAEY,aAAa;;YACxB,KAAK,MAAM,SAAS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,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;oBAC1D,CAAC,CAAC,CAAC;gBACL,CAAC,CAAC,CAAC;aACJ;YAED,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAC3B,CAAC;KAAA;IAEa,QAAQ,CAAC,IAAe,EAAE,IAAsB;;YAC5D,MAAM,EAAE,GAAG,IAAI,iBAAG,CAAC,EAAE,EAAE,CAAC;YACxB,MAAM,MAAM,GAAG;gBACb,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM;gBAC1B,GAAG,EAAE,GAAG,IAAI,CAAC,MAAM,CAAC,SAAS,GAAG,IAAI,OAAO;gBAC3C,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;gBAC1B,WAAW,EAAE,iCAAiC;aAC/C,CAAC;YAEF,OAAO,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;gBAC3C,EAAE,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;YAC/D,CAAC,CAAC,CAAC;QACL,CAAC;KAAA;CACF;AAnED,0CAmEC"} \ No newline at end of file diff --git a/lib/cjs/util/ErrorUtil.d.ts b/lib/cjs/util/ErrorUtil.d.ts new file mode 100644 index 0000000..48aae44 --- /dev/null +++ b/lib/cjs/util/ErrorUtil.d.ts @@ -0,0 +1,3 @@ +import { ErrorGroup } from "../models"; +export declare const getReadableErrorFrequency: (error: ErrorGroup) => string; +export declare const getReadableErrorCountPeriod: (countPeriodHours: number) => string; diff --git a/lib/cjs/util/ErrorUtil.js b/lib/cjs/util/ErrorUtil.js new file mode 100644 index 0000000..ac4c52d --- /dev/null +++ b/lib/cjs/util/ErrorUtil.js @@ -0,0 +1,26 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.getReadableErrorCountPeriod = exports.getReadableErrorFrequency = void 0; +const getReadableErrorFrequency = (error) => { + let countPeriod = (0, exports.getReadableErrorCountPeriod)(error.countPeriodHours); + return `${error.count} ${error.countType} ${countPeriod}`; +}; +exports.getReadableErrorFrequency = getReadableErrorFrequency; +const getReadableErrorCountPeriod = (countPeriodHours) => { + if (countPeriodHours === 1) { + return '1 hour'; + } + else if (countPeriodHours < 24) { + return `${countPeriodHours} hours`; + } + const days = Math.floor(countPeriodHours / 24); + const hours = countPeriodHours % 24; + if (hours === 0) { + return (days > 1 ? `${days} days` : 'day'); + } + else { + return `${days}d ${hours}h`; + } +}; +exports.getReadableErrorCountPeriod = getReadableErrorCountPeriod; +//# sourceMappingURL=ErrorUtil.js.map \ No newline at end of file diff --git a/lib/cjs/util/ErrorUtil.js.map b/lib/cjs/util/ErrorUtil.js.map new file mode 100644 index 0000000..508e76e --- /dev/null +++ b/lib/cjs/util/ErrorUtil.js.map @@ -0,0 +1 @@ +{"version":3,"file":"ErrorUtil.js","sourceRoot":"","sources":["../../../src/util/ErrorUtil.ts"],"names":[],"mappings":";;;AAEO,MAAM,yBAAyB,GAAG,CAAC,KAAiB,EAAE,EAAE;IAC7D,IAAI,WAAW,GAAG,IAAA,mCAA2B,EAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC;IACtE,OAAO,GAAG,KAAK,CAAC,KAAK,IAAI,KAAK,CAAC,SAAS,IAAI,WAAW,EAAE,CAAC;AAC5D,CAAC,CAAA;AAHY,QAAA,yBAAyB,6BAGrC;AAGM,MAAM,2BAA2B,GAAG,CAAC,gBAAwB,EAAE,EAAE;IACtE,IAAI,gBAAgB,KAAK,CAAC,EAAE;QAC1B,OAAO,QAAQ,CAAC;KACjB;SAAM,IAAI,gBAAgB,GAAG,EAAE,EAAE;QAChC,OAAO,GAAG,gBAAgB,QAAQ,CAAC;KACpC;IAED,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,gBAAgB,GAAG,EAAE,CAAC,CAAC;IAC/C,MAAM,KAAK,GAAG,gBAAgB,GAAG,EAAE,CAAC;IAEpC,IAAI,KAAK,KAAK,CAAC,EAAE;QACf,OAAO,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;KAC5C;SAAM;QACL,OAAO,GAAG,IAAI,KAAK,KAAK,GAAG,CAAC;KAC7B;AACH,CAAC,CAAA;AAfY,QAAA,2BAA2B,+BAevC"} \ No newline at end of file diff --git a/lib/esm/Synchronizer.js b/lib/esm/Synchronizer.js index 13ebbdf..17eda96 100644 --- a/lib/esm/Synchronizer.js +++ b/lib/esm/Synchronizer.js @@ -31,25 +31,14 @@ export class Synchronizer { exitCode: 0 }; try { - const errorPromises = this.config.errors.map((errorConfig) => __awaiter(this, void 0, void 0, function* () { - try { - this.runForErrorProvider(errorConfig, finalResult); - } - catch (e) { - finalResult.exitCode = 1; - finalResult.errors.push({ - message: e.message || e, - }); - console.error(e); - } - })); + const errorPromises = yield this.config.errors.map((errorConfig) => this.runForErrorProvider(errorConfig, finalResult)); const providerResults = yield Promise.allSettled(errorPromises); for (const [index, providerResult] of providerResults.entries()) { if (providerResult.status === 'rejected') { const providerName = this.config.errors[index].name; - console.error('An unexpected exception occurred while trying to synchronize errors for the ' + + console.error('An exception occurred while trying to synchronize errors for the ' + `provider named "${providerName}":`, providerResult.reason); - finalResult.exitCode = 2; + finalResult.exitCode = 1; finalResult.errors.push({ message: providerResult.reason.message || providerResult.reason, }); @@ -57,17 +46,17 @@ export class Synchronizer { } } catch (e) { - finalResult.exitCode = 3; + finalResult.exitCode = 2; finalResult.errors.push({ message: e.message || e, }); console.error('An unexpected exception occurred while running the error synchronizations', e); } try { - this.config.cacheProvider.saveAllCaches(); + yield this.config.cacheProvider.saveAllCaches(); } catch (e) { - finalResult.exitCode = 4; + finalResult.exitCode = 3; finalResult.errors.push({ message: e.message || e, }); @@ -75,7 +64,7 @@ export class Synchronizer { } if (finalResult.errors.length > 0) { console.error('Some errors were not synchronized to the ticketing and/or alerting system. Please see errors above.'); - finalResult.exitCode = finalResult.exitCode || 5; + finalResult.exitCode = finalResult.exitCode || 4; } return finalResult; }); @@ -87,7 +76,7 @@ export class Synchronizer { errors.forEach((error) => this.addToErrorGroups(error, errorGroups, errorConfig.name)); for (const errorGroup of errorGroups) { try { - this.syncErrorGroup(errorGroup, errorConfig); + yield this.syncErrorGroup(errorGroup, errorConfig); result.completedErrorGroups.push(errorGroup); } catch (e) { @@ -104,7 +93,9 @@ export class Synchronizer { } syncErrorGroup(errorGroup, errorConfig) { return __awaiter(this, void 0, void 0, function* () { - errorGroup.priority = yield errorConfig.prioritizationProvider.determinePriority(errorGroup); + const { priority, priorityReason } = yield errorConfig.prioritizationProvider.determinePriority(errorGroup); + errorGroup.priority = priority; + errorGroup.priorityReason = priorityReason; errorGroup.ticket = yield this.config.cacheProvider.getObject(errorGroup.clientId, CacheName.Tickets); errorGroup.alert = yield this.config.cacheProvider.getObject(errorGroup.clientId, CacheName.Alerts); if (!errorGroup.ticket) { @@ -125,7 +116,7 @@ export class Synchronizer { errorGroup.ticket = yield this.config.ticketProvider.reopenTicket(errorGroup.ticket); isTicketReopened = true; } - this.config.cacheProvider.setObject(errorGroup.ticket.id, errorGroup.ticket, CacheName.Tickets, false); + yield this.config.cacheProvider.setObject(errorGroup.clientId, errorGroup.ticket, CacheName.Tickets, false); if (!errorGroup.alert) { errorGroup.alert = yield this.config.alertProvider.findAlert(errorGroup.clientId); } @@ -136,24 +127,27 @@ export class Synchronizer { Object.assign(errorGroup.alert, freshAlertContent); errorGroup.alert = yield this.config.alertProvider.updateAlert(errorGroup.alert); } - this.config.cacheProvider.setObject(errorGroup.alert.id, errorGroup.alert, CacheName.Alerts, false); + yield this.config.cacheProvider.setObject(errorGroup.clientId, errorGroup.alert, CacheName.Alerts, false); }); } createErrorGroup(error, sourceName) { const maxNameLength = 500; - error.name = `[${sourceName}] ${error.name}`.substr(0, maxNameLength); + error.name = error.name.substr(0, maxNameLength); let normalizedName = error.name; normalizedName = normalizedName.replace(/\.(js|jsx|ts|tsx|php|py|go|java|cpp|h|c|cs|ex|exs|rb)[:@]\d+/i, '.$1:XXX'); normalizedName = normalizedName.replace(/(TypeError:\s*)/i, ''); - const hash = crypto.createHash('md5').update(normalizedName).digest('hex'); + const clientIdInput = `${sourceName}:${normalizedName}`; + const clientId = crypto.createHash('md5').update(clientIdInput).digest('hex'); return { name: normalizedName, sourceName, type: error.type, priority: ErrorPriority.P5, - clientId: hash, + priorityReason: 'Unknown', + clientId, count: error.count, countType: error.countType, + countPeriodHours: error.countPeriodHours, ticket: null, alert: null, instances: [error], diff --git a/lib/esm/Synchronizer.js.map b/lib/esm/Synchronizer.js.map index 45b790f..c36ab71 100644 --- a/lib/esm/Synchronizer.js.map +++ b/lib/esm/Synchronizer.js.map @@ -1 +1 @@ -{"version":3,"file":"Synchronizer.js","sourceRoot":"","sources":["../../src/Synchronizer.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAuB,SAAS,EAAqB,aAAa,EAAyB,MAAM,UAAU,CAAC;AAQnH,OAAO,EAAE,gCAAgC,EAAE,MAAM,aAAa,CAAC;AA4B/D,MAAM,OAAO,YAAY;IAGvB,YAAmB,MAA0B;;QAC3C,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QAGrB,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE;YACnC,MAAM,IAAI,KAAK,CAAC,oEAAoE,CAAC,CAAC;SACvF;QAGD,KAAK,MAAM,QAAQ,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE;YACzC,MAAA,QAAQ,CAAC,aAAa,oCAAtB,QAAQ,CAAC,aAAa,GAAK,EAAE,EAAC;YAC9B,MAAA,QAAQ,CAAC,SAAS,oCAAlB,QA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D,CAAC;IAEO,mBAAmB,CAAC,aAAoB,EAAE,iBAA+B;QAC/E,OAAO,aAAa,CAAC,OAAO,KAAK,iBAAiB,CAAC,OAAO;YACxD,aAAa,CAAC,WAAW,KAAK,iBAAiB,CAAC,WAAW;YAC3D,aAAa,CAAC,QAAQ,KAAK,iBAAiB,CAAC,QAAQ;YACrD,aAAa,CAAC,SAAS,KAAK,iBAAiB,CAAC,SAAS,CAAC;IAC5D,CAAC;CACF"} \ No newline at end of file diff --git a/lib/esm/interfaces/AlertProviderInterface.d.ts b/lib/esm/interfaces/AlertProviderInterface.d.ts index 2111cda..86c1029 100644 --- a/lib/esm/interfaces/AlertProviderInterface.d.ts +++ b/lib/esm/interfaces/AlertProviderInterface.d.ts @@ -1,6 +1,6 @@ import { ErrorGroup, Alert, AlertContent } from '../models'; export interface AlertProviderInterface { - findAlert(clientId: string): Promise; + findAlert(clientId: string): Promise; createAlert(alertContent: AlertContent): Promise; updateAlert(alert: Alert): Promise; generateAlertContent(errorGroup: ErrorGroup): Promise; diff --git a/lib/esm/interfaces/PrioritizationProviderInterface.d.ts b/lib/esm/interfaces/PrioritizationProviderInterface.d.ts index 2464163..d697ecf 100644 --- a/lib/esm/interfaces/PrioritizationProviderInterface.d.ts +++ b/lib/esm/interfaces/PrioritizationProviderInterface.d.ts @@ -1,4 +1,8 @@ import { ErrorGroup, ErrorPriority } from '../models'; +export declare type ErrorPrioritizationResult = { + priority: ErrorPriority; + priorityReason: string; +}; export interface PrioritizationProviderInterface { - determinePriority(errorGroup: ErrorGroup): Promise; + determinePriority(errorGroup: ErrorGroup): Promise; } diff --git a/lib/esm/models/Error.d.ts b/lib/esm/models/Error.d.ts index c5a5934..a0e2dfe 100644 --- a/lib/esm/models/Error.d.ts +++ b/lib/esm/models/Error.d.ts @@ -8,28 +8,31 @@ export declare enum ErrorPriority { P5 = "P5" } export declare enum ErrorCountType { - USERS = "Users", - TRX = "Transactions" + USERS = "users", + TRX = "transactions" } export declare enum ErrorType { - CLIENT = "Client", - SERVER = "Server" + CLIENT = "client", + SERVER = "server" } export declare type Error = { - name: any; - type: any; - count: any; - countType: any; - debugUrl: any; + name: string; + type: ErrorType; + count: number; + countType: ErrorCountType; + countPeriodHours: number; + debugUrl: string; }; export declare type ErrorGroup = { name: string; sourceName: string; type: ErrorType; priority: string; + priorityReason: string; clientId: string; count: number; countType: ErrorCountType; + countPeriodHours: number; ticket: Ticket; alert: Alert; instances: Error[]; diff --git a/lib/esm/models/Error.js b/lib/esm/models/Error.js index 07df695..bdd726d 100644 --- a/lib/esm/models/Error.js +++ b/lib/esm/models/Error.js @@ -8,12 +8,12 @@ export var ErrorPriority; })(ErrorPriority || (ErrorPriority = {})); export var ErrorCountType; (function (ErrorCountType) { - ErrorCountType["USERS"] = "Users"; - ErrorCountType["TRX"] = "Transactions"; + ErrorCountType["USERS"] = "users"; + ErrorCountType["TRX"] = "transactions"; })(ErrorCountType || (ErrorCountType = {})); export var ErrorType; (function (ErrorType) { - ErrorType["CLIENT"] = "Client"; - ErrorType["SERVER"] = "Server"; + ErrorType["CLIENT"] = "client"; + ErrorType["SERVER"] = "server"; })(ErrorType || (ErrorType = {})); //# sourceMappingURL=Error.js.map \ No newline at end of file diff --git a/lib/esm/providers/ErrorCountPrioritizationProvider.d.ts b/lib/esm/providers/ErrorCountPrioritizationProvider.d.ts index a767ea8..248bb95 100644 --- a/lib/esm/providers/ErrorCountPrioritizationProvider.d.ts +++ b/lib/esm/providers/ErrorCountPrioritizationProvider.d.ts @@ -1,5 +1,5 @@ import { ErrorGroup, ErrorPriority } from '../models'; -import { PrioritizationProviderInterface } from '../interfaces'; +import { ErrorPrioritizationResult, PrioritizationProviderInterface } from '../interfaces'; export declare type ErrorCountPrioritizationProviderThreshold = { threshold: number; priority: ErrorPriority; @@ -18,5 +18,5 @@ export declare const DefaultErrorCountPrioritizationProviderConfig: { export declare class ErrorCountPrioritizationProvider implements PrioritizationProviderInterface { private config; constructor(config?: ErrorCountPrioritizationProviderConfig); - determinePriority(errorGroup: ErrorGroup): Promise; + determinePriority(errorGroup: ErrorGroup): Promise; } diff --git a/lib/esm/providers/ErrorCountPrioritizationProvider.js b/lib/esm/providers/ErrorCountPrioritizationProvider.js index e94ef4d..882d9f4 100644 --- a/lib/esm/providers/ErrorCountPrioritizationProvider.js +++ b/lib/esm/providers/ErrorCountPrioritizationProvider.js @@ -8,6 +8,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge }); }; import { ErrorPriority } from '../models'; +import { getReadableErrorCountPeriod } from "../util/ErrorUtil"; export const DefaultErrorCountPrioritizationProviderConfig = { thresholds: [{ threshold: 1, @@ -39,7 +40,11 @@ export class ErrorCountPrioritizationProvider { return __awaiter(this, void 0, void 0, function* () { for (const threshold of this.config.thresholds) { if (errorGroup.count < threshold.threshold) { - return threshold.priority; + const countPeriod = getReadableErrorCountPeriod(errorGroup.countPeriodHours); + return { + priority: threshold.priority, + priorityReason: `Affecting ${threshold.label} ${errorGroup.countType} per ${countPeriod}`, + }; } } }); diff --git a/lib/esm/providers/ErrorCountPrioritizationProvider.js.map b/lib/esm/providers/ErrorCountPrioritizationProvider.js.map index 94c5b88..dce4b2d 100644 --- a/lib/esm/providers/ErrorCountPrioritizationProvider.js.map +++ b/lib/esm/providers/ErrorCountPrioritizationProvider.js.map @@ -1 +1 @@ -{"version":3,"file":"ErrorCountPrioritizationProvider.js","sourceRoot":"","sources":["../../../src/providers/ErrorCountPrioritizationProvider.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAc,aAAa,EAAE,MAAM,WAAW,CAAC;AAatD,MAAM,CAAC,MAAM,6CAA6C,GAAG;IAC3D,UAAU,EAAE,CAAC;YAEX,SAAS,EAAE,CAAC;YACZ,QAAQ,EAAE,aAAa,CAAC,EAAE;YAC1B,KAAK,EAAE,GAAG;SACX,EAAE;YAED,SAAS,EAAE,EAAE;YACb,QAAQ,EAAE,aAAa,CAAC,EAAE;YAC1B,KAAK,EAAE,eAAe;SACvB,EAAE;YAED,SAAS,EAAE,EAAE;YACb,QAAQ,EAAE,aAAa,CAAC,EAAE;YAC1B,KAAK,EAAE,gBAAgB;SACxB,EAAE;YAED,SAAS,EAAE,EAAE;YACb,QAAQ,EAAE,aAAa,CAAC,EAAE;YAC1B,KAAK,EAAE,gBAAgB;SACxB,EAAE;YAED,SAAS,EAAE,MAAM,CAAC,gBAAgB;YAClC,QAAQ,EAAE,aAAa,CAAC,EAAE;YAC1B,KAAK,EAAE,OAAO;SACf,CAAC;CACH,CAAC;AAEF,MAAM,OAAO,gCAAgC;IAG3C,YAAmB,MAA+C;QAChE,IAAI,CAAC,MAAM,GAAG,MAAM,aAAN,MAAM,cAAN,MAAM,GAAI,6CAA6C,CAAC;IACxE,CAAC;IAEY,iBAAiB,CAAC,UAAsB;;YACnD,KAAK,MAAM,SAAS,IAAI,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE;gBAC9C,IAAI,UAAU,CAAC,KAAK,GAAG,SAAS,CAAC,SAAS,EAAE;oBAC1C,OAAO,SAAS,CAAC,QAAQ,CAAC;iBAC3B;aACF;QACH,CAAC;KAAA;CACF"} \ No newline at end of file +{"version":3,"file":"ErrorCountPrioritizationProvider.js","sourceRoot":"","sources":["../../../src/providers/ErrorCountPrioritizationProvider.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAc,aAAa,EAAE,MAAM,WAAW,CAAC;AAEtD,OAAO,EAAE,2BAA2B,EAAE,MAAM,mBAAmB,CAAC;AAYhE,MAAM,CAAC,MAAM,6CAA6C,GAAG;IAC3D,UAAU,EAAE,CAAC;YAEX,SAAS,EAAE,CAAC;YACZ,QAAQ,EAAE,aAAa,CAAC,EAAE;YAC1B,KAAK,EAAE,GAAG;SACX,EAAE;YAED,SAAS,EAAE,EAAE;YACb,QAAQ,EAAE,aAAa,CAAC,EAAE;YAC1B,KAAK,EAAE,eAAe;SACvB,EAAE;YAED,SAAS,EAAE,EAAE;YACb,QAAQ,EAAE,aAAa,CAAC,EAAE;YAC1B,KAAK,EAAE,gBAAgB;SACxB,EAAE;YAED,SAAS,EAAE,EAAE;YACb,QAAQ,EAAE,aAAa,CAAC,EAAE;YAC1B,KAAK,EAAE,gBAAgB;SACxB,EAAE;YAED,SAAS,EAAE,MAAM,CAAC,gBAAgB;YAClC,QAAQ,EAAE,aAAa,CAAC,EAAE;YAC1B,KAAK,EAAE,OAAO;SACf,CAAC;CACH,CAAC;AAEF,MAAM,OAAO,gCAAgC;IAG3C,YAAmB,MAA+C;QAChE,IAAI,CAAC,MAAM,GAAG,MAAM,aAAN,MAAM,cAAN,MAAM,GAAI,6CAA6C,CAAC;IACxE,CAAC;IAEY,iBAAiB,CAAC,UAAsB;;YACnD,KAAK,MAAM,SAAS,IAAI,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE;gBAC9C,IAAI,UAAU,CAAC,KAAK,GAAG,SAAS,CAAC,SAAS,EAAE;oBAC1C,MAAM,WAAW,GAAG,2BAA2B,CAAC,UAAU,CAAC,gBAAgB,CAAC,CAAC;oBAC7E,OAAO;wBACL,QAAQ,EAAE,SAAS,CAAC,QAAQ;wBAC5B,cAAc,EAAE,aAAa,SAAS,CAAC,KAAK,IAAI,UAAU,CAAC,SAAS,QAAQ,WAAW,EAAE;qBAC1F,CAAC;iBACH;aACF;QACH,CAAC;KAAA;CACF"} \ No newline at end of file diff --git a/lib/esm/providers/JiraTicketProvider.js b/lib/esm/providers/JiraTicketProvider.js index bffe854..2383f8f 100644 --- a/lib/esm/providers/JiraTicketProvider.js +++ b/lib/esm/providers/JiraTicketProvider.js @@ -129,13 +129,13 @@ export class JiraTicketProvider { generateTicketContent(errorGroup) { return __awaiter(this, void 0, void 0, function* () { const maxInstances = 10; - const summary = `[${errorGroup.type}] ${errorGroup.name}`; - let description = errorGroup.name + - '\n\nh3.Frequency' + - `${errorGroup.count} ${errorGroup.countType} per day` + - '\n\nh3.Instances'; + const summary = `[${errorGroup.type}] [${errorGroup.sourceName}] ${errorGroup.name}`; + let description = `{noformat}${errorGroup.name}{noformat}` + + '\nh4.Priority Reason\n' + + `${errorGroup.priorityReason}` + + '\nh4.Instances\n'; for (const instance of errorGroup.instances.slice(0, maxInstances)) { - description += `${instance.name}\n\nTroubleshoot at: [${instance.debugUrl}]`; + description += `{noformat}${instance.name}{noformat}\n\nTroubleshoot at: [${instance.debugUrl}]`; } if (errorGroup.instances.length > 10) { const additional = (errorGroup.instances.length - maxInstances); @@ -146,7 +146,12 @@ export class JiraTicketProvider { summary, description, priority: this.config.ticket.priorityMap[errorGroup.priority], - labels: ['error_sync', `error:${errorGroup.clientId}`], + labels: [ + 'error_sync', + `error:${errorGroup.clientId}`, + errorGroup.sourceName, + errorGroup.type, + ], }; }); } diff --git a/lib/esm/providers/JiraTicketProvider.js.map b/lib/esm/providers/JiraTicketProvider.js.map index 8b59817..28aeff7 100644 --- a/lib/esm/providers/JiraTicketProvider.js.map +++ b/lib/esm/providers/JiraTicketProvider.js.map @@ -1 +1 @@ -{"version":3,"file":"JiraTicketProvider.js","sourceRoot":"","sources":["../../../src/providers/JiraTicketProvider.ts"],"names":[],"mappings":";;;;;;;;;AACA,OAAO,EAAc,aAAa,EAAyB,MAAM,WAAW,CAAC;AAC7E,OAAO,OAAO,MAAM,aAAa,CAAC;AA6BlC,MAAM,OAAO,kBAAkB;IAI7B,YAAmB,MAAgC;QACjD,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC;QAGjD,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,WAAW,EAAE;YACnC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,WAAW,GAAG;gBAC/B,CAAC,aAAa,CAAC,EAAE,CAAC,EAAE,SAAS;gBAC7B,CAAC,aAAa,CAAC,EAAE,CAAC,EAAE,MAAM;gBAC1B,CAAC,aAAa,CAAC,EAAE,CAAC,EAAE,QAAQ;gBAC5B,CAAC,aAAa,CA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AAM,OAAO,GAAG,IAAI,UAAU,CAAC,IAAI,KAAK,UAAU,CAAC,IAAI,EAAE,CAAC;YAE1D,IAAI,WAAW,GAAG,UAAU,CAAC,IAAI;gBAC/B,kBAAkB;gBAClB,GAAG,UAAU,CAAC,KAAK,IAAI,UAAU,CAAC,SAAS,UAAU;gBACrD,kBAAkB,CAAC;YAErB,KAAK,MAAM,QAAQ,IAAI,UAAU,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,EAAE,YAAY,CAAC,EAAE;gBAClE,WAAW,IAAI,GAAG,QAAQ,CAAC,IAAI,yBAAyB,QAAQ,CAAC,QAAQ,GAAG,CAAC;aAC9E;YAED,IAAI,UAAU,CAAC,SAAS,CAAC,MAAM,GAAG,EAAE,EAAE;gBACpC,MAAM,UAAU,GAAG,CAAC,UAAU,CAAC,SAAS,CAAC,MAAM,GAAG,YAAY,CAAC,CAAC;gBAChE,WAAW,IAAI,WAAW,UAAU,6BAA6B,CAAC;aACnE;YAED,OAAO;gBACL,QAAQ,EAAE,UAAU,CAAC,QAAQ;gBAC7B,OAAO;gBACP,WAAW;gBACX,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,UAAU,CAAC,QAAQ,CAAC;gBAC7D,MAAM,EAAE,CAAC,YAAY,EAAE,SAAS,UAAU,CAAC,QAAQ,EAAE,CAAC;aACvD,CAAA;QACH,CAAC;KAAA;IAEO,aAAa,CAAC,GAAW;QAC/B,OAAO,WAAW,IAAI,CAAC,MAAM,CAAC,IAAI,WAAW,GAAG,EAAE,CAAA;IACpD,CAAC;CACF"} \ No newline at end of file +{"version":3,"file":"JiraTicketProvider.js","sourceRoot":"","sources":["../../../src/providers/JiraTicketProvider.ts"],"names":[],"mappings":";;;;;;;;;AACA,OAAO,EAAc,aAAa,EAAyB,MAAM,WAAW,CAAC;AAC7E,OAAO,OAAO,MAAM,aAAa,CAAC;AA8BlC,MAAM,OAAO,kBAAkB;IAI7B,YAAmB,MAAg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UAAU,CAAC,QAAQ,EAAE;oBAC9B,UAAU,CAAC,UAAU;oBACrB,UAAU,CAAC,IAAI;iBAChB;aACF,CAAA;QACH,CAAC;KAAA;IAEO,aAAa,CAAC,GAAW;QAC/B,OAAO,WAAW,IAAI,CAAC,MAAM,CAAC,IAAI,WAAW,GAAG,EAAE,CAAA;IACpD,CAAC;CACF"} \ No newline at end of file diff --git a/lib/esm/providers/NewRelicServerErrorProvider.js b/lib/esm/providers/NewRelicServerErrorProvider.js index 0a1bdda..c6ccbe9 100644 --- a/lib/esm/providers/NewRelicServerErrorProvider.js +++ b/lib/esm/providers/NewRelicServerErrorProvider.js @@ -47,6 +47,7 @@ export class NewRelicServerErrorProvider { newRelicError.type = ErrorType.SERVER; newRelicError.count = (newRelicError.uniqueCount > 0 ? newRelicError.uniqueCount : newRelicError.count); newRelicError.countType = newRelicError.uniqueCount > 0 ? ErrorCountType.USERS : ErrorCountType.TRX; + newRelicError.countPeriodHours = hoursBack; }); const appId = newRelicError.max; const filters = [{ diff --git a/lib/esm/providers/NewRelicServerErrorProvider.js.map b/lib/esm/providers/NewRelicServerErrorProvider.js.map index 7d78406..e76fb0e 100644 --- a/lib/esm/providers/NewRelicServerErrorProvider.js.map +++ b/lib/esm/providers/NewRelicServerErrorProvider.js.map @@ -1 +1 @@ -{"version":3,"file":"NewRelicServerErrorProvider.js","sourceRoot":"","sources":["../../../src/providers/NewRelicServerErrorProvider.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAS,cAAc,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAE7D,OAAO,WAAW,MAAM,qBAAqB,CAAC;AAW9C,MAAM,OAAO,2BAA2B;IAItC,YAAmB,MAAyC;QAC1D,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAEY,SAAS,CAAC,SAAS,GAAE,EAAE,EAAE,KAAK,GAAG,IAAI;;YAChD,MAAM,IAAI,GAAG;;;;;;cAMH,SAAS;cACT,KAAK;KAC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AC,cAAc,CAAC,GAAG,CAAC;wBACtG,CAAC,CAAC,CAAC;wBAGH,MAAM,KAAK,GAAG,aAAa,CAAC,GAAG,CAAC;wBAChC,MAAM,OAAO,GAAG,CAAC;gCACf,GAAG,EAAE,eAAe;gCACpB,KAAK,EAAE,aAAa,CAAC,IAAI;gCACzB,IAAI,EAAE,KAAK;6BACZ,CAAC,CAAC;wBACH,MAAM,cAAc,GAAG,kBAAkB,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC;wBACnE,aAAa,CAAC,QAAQ,GAAG,qCAAqC,KAAK,iBAAiB,aAAa,CAAC,GAAG,6GAA6G,cAAc,EAAE,CAAC;wBAEnO,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;oBAC7B,CAAC,CAAC,CAAC;oBAEH,OAAO,CAAC,MAAM,CAAC,CAAC;gBAClB,CAAC,CAAC,CAAC;YACL,CAAC,CAAC,CAAC;QACL,CAAC;KAAA;CACF"} \ No newline at end of file +{"version":3,"file":"NewRelicServerErrorProvider.js","sourceRoot":"","sources":["../../../src/providers/NewRelicServerErrorProvider.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAS,cAAc,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAE7D,OAAO,WAAW,MAAM,qBAAqB,CAAC;AAW9C,MAAM,OAAO,2BAA2B;IAItC,YAAmB,MAAyC;QAC1D,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAEY,SAAS,CAAC,SAAS,GAAE,EAAE,EAAE,KAAK,GAAG,IAAI;;YAChD,MAAM,IAAI,GAAG;;;;;;cAMH,SAAS;cACT,KAAK;KACd,CAAC;YAEF,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;gBACrC,WAAW,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,KAAK,EAAE,QA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AAG,EAAE,eAAe;gCACpB,KAAK,EAAE,aAAa,CAAC,IAAI;gCACzB,IAAI,EAAE,KAAK;6BACZ,CAAC,CAAC;wBACH,MAAM,cAAc,GAAG,kBAAkB,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC;wBACnE,aAAa,CAAC,QAAQ,GAAG,qCAAqC,KAAK,iBAAiB,aAAa,CAAC,GAAG,6GAA6G,cAAc,EAAE,CAAC;wBAEnO,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;oBAC7B,CAAC,CAAC,CAAC;oBAEH,OAAO,CAAC,MAAM,CAAC,CAAC;gBAClB,CAAC,CAAC,CAAC;YACL,CAAC,CAAC,CAAC;QACL,CAAC;KAAA;CACF"} \ No newline at end of file diff --git a/lib/esm/providers/OpsGenieAlertProvider.d.ts b/lib/esm/providers/OpsGenieAlertProvider.d.ts index d216691..7e85524 100644 --- a/lib/esm/providers/OpsGenieAlertProvider.d.ts +++ b/lib/esm/providers/OpsGenieAlertProvider.d.ts @@ -8,7 +8,7 @@ export declare type OpsGenieAlertProviderConfig = { export declare class OpsGenieAlertProvider implements AlertProviderInterface { private config; constructor(config: OpsGenieAlertProviderConfig); - findAlert(clientId: string): Promise; + findAlert(clientId: string): Promise; createAlert(alertContent: AlertContent): Promise; updateAlert(alert: Alert): Promise; generateAlertContent(errorGroup: ErrorGroup): Promise; diff --git a/lib/esm/providers/OpsGenieAlertProvider.js b/lib/esm/providers/OpsGenieAlertProvider.js index 467672d..d170b8a 100644 --- a/lib/esm/providers/OpsGenieAlertProvider.js +++ b/lib/esm/providers/OpsGenieAlertProvider.js @@ -32,18 +32,34 @@ export class OpsGenieAlertProvider { identifier: clientId, identifierType: 'alias', }, (error, response) => { - return (error ? reject(error) : resolve(response.data)); + if (!error) { + return resolve(response.data); + } + else if (error.httpStatusCode === 404) { + return resolve(undefined); + } + else if (error instanceof Error) { + return reject(error); + } + else { + return reject(new Error(error.message || error)); + } }); }); - return { - id: clientId, - clientId, - summary: opsgenieAlert.message, - description: opsgenieAlert.description, - priority: opsgenieAlert.priority, - labels: [], - ticketUrl: opsgenieAlert.details['Ticket Link'], - }; + if (!opsgenieAlert) { + return undefined; + } + else { + return { + id: clientId, + clientId, + summary: opsgenieAlert.message, + description: opsgenieAlert.description, + priority: opsgenieAlert.priority, + labels: [], + ticketUrl: opsgenieAlert.details['Ticket Link'], + }; + } }); } createAlert(alertContent) { @@ -83,7 +99,7 @@ export class OpsGenieAlertProvider { generateAlertContent(errorGroup) { var _a; return __awaiter(this, void 0, void 0, function* () { - const summary = `[BUG] ${errorGroup.name}`.substr(0, 130); + const summary = `[${errorGroup.type}] [${errorGroup.sourceName}] ${errorGroup.name}`.substr(0, 130); return { clientId: errorGroup.clientId, summary, diff --git a/lib/esm/providers/OpsGenieAlertProvider.js.map b/lib/esm/providers/OpsGenieAlertProvider.js.map index e644d02..e460463 100644 --- a/lib/esm/providers/OpsGenieAlertProvider.js.map +++ b/lib/esm/providers/OpsGenieAlertProvider.js.map @@ -1 +1 @@ -{"version":3,"file":"OpsGenieAlertProvider.js","sourceRoot":"","sources":["../../../src/providers/OpsGenieAlertProvider.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAmC,aAAa,EAAE,MAAM,WAAW,CAAC;AAE3E,OAAO,QAAQ,MAAM,cAAc,CAAC;AAQpC,MAAM,OAAO,qBAAqB;IAGhC,YAAY,MAAmC;QAC7C,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC;QAEjD,QAAQ,CAAC,SAAS,CAAC;YACjB,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM;SAC5B,CAAC,CAAC;QAGH,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE;YAC5B,IAAI,CAAC,MAAM,CAAC,WAAW,GAAG;gBACxB,CAAC,aAAa,CAAC,EAAE,CAAC,EAAE,I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5B,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,UAAU,CAAC,QAAQ,CAAC;gBACtD,MAAM,EAAE,EAAE;gBACV,SAAS,EAAE,MAAA,UAAU,CAAC,MAAM,0CAAE,GAAG;aAClC,CAAA;;KACF;CACF"} \ No newline at end of file +{"version":3,"file":"OpsGenieAlertProvider.js","sourceRoot":"","sources":["../../../src/providers/OpsGenieAlertProvider.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAmC,aAAa,EAAE,MAAM,WAAW,CAAC;AAE3E,OAAO,QAAQ,MAAM,cAAc,CAAC;AAQpC,MAAM,OAAO,qBAAqB;IAGhC,YAAY,MAAmC;QAC7C,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC;QAEjD,QAAQ,CAAC,SAAS,CAAC;YACjB,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM;SAC5B,CAAC,CAAC;QAGH,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE;YAC5B,IAAI,CAAC,MAAM,CAAC,WAAW,GAAG;gBACxB,CAAC,aAAa,CAAC,EAAE,CAAC,EAAE,IAAI;gBACxB,CAAC,aAAa,CAAC,EAAE,CAAC,EAAE,IAAI;gBACxB,CAAC,aAAa,CAAC,EAAE,CAAC,EAAE,IAAI;gBACxB,CAAC,aAAa,CAAC,EAAE,CAAC,EAAE,IAAI;gBACxB,CAAC,aAAa,CAAC,EAAE,CAAC,EAAE,IAAI;aACzB,CAAC;SACH;IACH,CAAC;IAEY,SAAS,CAAC,QAAgB;;YACrC,MAAM,aAAa,GAAQ,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;gBAC/D,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC;oBACnB,UAAU,EAAE,QAAQ;oBACpB,cAAc,EAAE,OAAO;iBACxB,EAAE,CAAC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D,MAAM,EAAE,EAAE;gBACV,SAAS,EAAE,MAAA,UAAU,CAAC,MAAM,0CAAE,GAAG;aAClC,CAAA;;KACF;CACF"} \ No newline at end of file diff --git a/lib/esm/providers/S3CacheProvider.js b/lib/esm/providers/S3CacheProvider.js index b85cdd3..d9c871c 100644 --- a/lib/esm/providers/S3CacheProvider.js +++ b/lib/esm/providers/S3CacheProvider.js @@ -7,7 +7,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; -import { CacheName } from '../models'; import AWS from 'aws-sdk'; export class S3CacheProvider { constructor(config) { @@ -35,7 +34,7 @@ export class S3CacheProvider { saveAllCaches() { return __awaiter(this, void 0, void 0, function* () { for (const cacheName in this.caches) { - yield this.setCache(CacheName[cacheName], this.caches[cacheName]); + yield this.setCache(cacheName, this.caches[cacheName]); } }); } @@ -61,7 +60,6 @@ export class S3CacheProvider { } setCache(name, data) { return __awaiter(this, void 0, void 0, function* () { - console.log('Saving', data); const s3 = new AWS.S3(); const params = { Bucket: this.config.bucket, diff --git a/lib/esm/providers/S3CacheProvider.js.map b/lib/esm/providers/S3CacheProvider.js.map index c818abe..8161a99 100644 --- a/lib/esm/providers/S3CacheProvider.js.map +++ b/lib/esm/providers/S3CacheProvider.js.map @@ -1 +1 @@ -{"version":3,"file":"S3CacheProvider.js","sourceRoot":"","sources":["../../../src/providers/S3CacheProvider.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,OAAO,GAAG,MAAM,SAAS,CAAC;AAQ1B,MAAM,OAAO,eAAe;IAI1B,YAAmB,MAA6B;QAFxC,WAAM,GAAwB,EAAE,CAAC;QAGvC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QAErB,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE;YACtB,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,MAAM,EA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AS,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;YAC/D,CAAC,CAAC,CAAC;QACL,CAAC;KAAA;CACF"} \ No newline at end of file diff --git a/lib/esm/util/ErrorUtil.d.ts b/lib/esm/util/ErrorUtil.d.ts new file mode 100644 index 0000000..48aae44 --- /dev/null +++ b/lib/esm/util/ErrorUtil.d.ts @@ -0,0 +1,3 @@ +import { ErrorGroup } from "../models"; +export declare const getReadableErrorFrequency: (error: ErrorGroup) => string; +export declare const getReadableErrorCountPeriod: (countPeriodHours: number) => string; diff --git a/lib/esm/util/ErrorUtil.js b/lib/esm/util/ErrorUtil.js new file mode 100644 index 0000000..0e3291f --- /dev/null +++ b/lib/esm/util/ErrorUtil.js @@ -0,0 +1,21 @@ +export const getReadableErrorFrequency = (error) => { + let countPeriod = getReadableErrorCountPeriod(error.countPeriodHours); + return `${error.count} ${error.countType} ${countPeriod}`; +}; +export const getReadableErrorCountPeriod = (countPeriodHours) => { + if (countPeriodHours === 1) { + return '1 hour'; + } + else if (countPeriodHours < 24) { + return `${countPeriodHours} hours`; + } + const days = Math.floor(countPeriodHours / 24); + const hours = countPeriodHours % 24; + if (hours === 0) { + return (days > 1 ? `${days} days` : 'day'); + } + else { + return `${days}d ${hours}h`; + } +}; +//# sourceMappingURL=ErrorUtil.js.map \ No newline at end of file diff --git a/lib/esm/util/ErrorUtil.js.map b/lib/esm/util/ErrorUtil.js.map new file mode 100644 index 0000000..a031df1 --- /dev/null +++ b/lib/esm/util/ErrorUtil.js.map @@ -0,0 +1 @@ +{"version":3,"file":"ErrorUtil.js","sourceRoot":"","sources":["../../../src/util/ErrorUtil.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,KAAiB,EAAE,EAAE;IAC7D,IAAI,WAAW,GAAG,2BAA2B,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC;IACtE,OAAO,GAAG,KAAK,CAAC,KAAK,IAAI,KAAK,CAAC,SAAS,IAAI,WAAW,EAAE,CAAC;AAC5D,CAAC,CAAA;AAGD,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,gBAAwB,EAAE,EAAE;IACtE,IAAI,gBAAgB,KAAK,CAAC,EAAE;QAC1B,OAAO,QAAQ,CAAC;KACjB;SAAM,IAAI,gBAAgB,GAAG,EAAE,EAAE;QAChC,OAAO,GAAG,gBAAgB,QAAQ,CAAC;KACpC;IAED,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,gBAAgB,GAAG,EAAE,CAAC,CAAC;IAC/C,MAAM,KAAK,GAAG,gBAAgB,GAAG,EAAE,CAAC;IAEpC,IAAI,KAAK,KAAK,CAAC,EAAE;QACf,OAAO,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;KAC5C;SAAM;QACL,OAAO,GAAG,IAAI,KAAK,KAAK,GAAG,CAAC;KAC7B;AACH,CAAC,CAAA"} \ No newline at end of file diff --git a/package.json b/package.json index f8dd0fe..7dc5b39 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "error-sync-lib", - "version": "0.1.8", + "version": "0.1.9", "private": "true", "scripts": { "build": "yarn build:esm && yarn build:cjs", diff --git a/src/Synchronizer.ts b/src/Synchronizer.ts index 5b510a4..d9a93ab 100644 --- a/src/Synchronizer.ts +++ b/src/Synchronizer.ts @@ -63,34 +63,23 @@ export class Synchronizer { // run all error provider synchronizations in parallel try { - const errorPromises = this.config.errors.map(async (errorConfig) => { - try { - this.runForErrorProvider(errorConfig, finalResult); - } catch (e) { - finalResult.exitCode = 1; - finalResult.errors.push({ - message: e.message || e, - }); - - console.error(e); - } - }); + const errorPromises = await this.config.errors.map((errorConfig) => this.runForErrorProvider(errorConfig, finalResult)); // check for any promise rejections from our error provider synchronizations const providerResults = await Promise.allSettled(errorPromises); for (const [index, providerResult] of providerResults.entries()) { if (providerResult.status === 'rejected') { const providerName = this.config.errors[index].name; - console.error('An unexpected exception occurred while trying to synchronize errors for the ' + + console.error('An exception occurred while trying to synchronize errors for the ' + `provider named "${providerName}":`, providerResult.reason); - finalResult.exitCode = 2; + finalResult.exitCode = 1; finalResult.errors.push({ message: providerResult.reason.message || providerResult.reason, }); } } } catch (e) { - finalResult.exitCode = 3; + finalResult.exitCode = 2; finalResult.errors.push({ message: e.message || e, }); @@ -100,9 +89,9 @@ export class Synchronizer { // persist all cached data changes try { - this.config.cacheProvider.saveAllCaches(); + await this.config.cacheProvider.saveAllCaches(); } catch (e) { - finalResult.exitCode = 4; + finalResult.exitCode = 3; finalResult.errors.push({ message: e.message || e, }); @@ -112,7 +101,7 @@ export class Synchronizer { if (finalResult.errors.length > 0) { console.error('Some errors were not synchronized to the ticketing and/or alerting system. Please see errors above.'); - finalResult.exitCode = finalResult.exitCode || 5; + finalResult.exitCode = finalResult.exitCode || 4; } return finalResult; @@ -129,7 +118,7 @@ export class Synchronizer { // is done because the ticket + alert has already been created and does not need to be updated. for (const errorGroup of errorGroups) { try { - this.syncErrorGroup(errorGroup, errorConfig); + await this.syncErrorGroup(errorGroup, errorConfig); result.completedErrorGroups.push(errorGroup); } catch (e) { result.errors.push({ @@ -145,7 +134,12 @@ export class Synchronizer { } private async syncErrorGroup(errorGroup: ErrorGroup, errorConfig: SynchronizerErrorProviderConfig) { - errorGroup.priority = await errorConfig.prioritizationProvider.determinePriority(errorGroup); + // determine the appropriate priority + const { priority, priorityReason } = await errorConfig.prioritizationProvider.determinePriority(errorGroup); + errorGroup.priority = priority; + errorGroup.priorityReason = priorityReason; + + // read any cached version of the ticket and alert errorGroup.ticket = await this.config.cacheProvider.getObject(errorGroup.clientId, CacheName.Tickets); errorGroup.alert = await this.config.cacheProvider.getObject(errorGroup.clientId, CacheName.Alerts); @@ -174,7 +168,7 @@ export class Synchronizer { isTicketReopened = true; } - this.config.cacheProvider.setObject(errorGroup.ticket.id, errorGroup.ticket, CacheName.Tickets, false); + await this.config.cacheProvider.setObject(errorGroup.clientId, errorGroup.ticket, CacheName.Tickets, false); // if our alert cache does not know about the error, then we search in the source-of-truth // alert system. if it is not there either, then we will end up creating a new alert. @@ -190,7 +184,7 @@ export class Synchronizer { errorGroup.alert = await this.config.alertProvider.updateAlert(errorGroup.alert); } - this.config.cacheProvider.setObject(errorGroup.alert.id, errorGroup.alert, CacheName.Alerts, false); + await this.config.cacheProvider.setObject(errorGroup.clientId, errorGroup.alert, CacheName.Alerts, false); } private createErrorGroup(error: Error, sourceName: string): ErrorGroup { @@ -213,10 +207,12 @@ export class Synchronizer { name: normalizedName, sourceName, type: error.type, - priority: ErrorPriority.P5, + priority: ErrorPriority.P5, // to be set later after aggregation is completed + priorityReason: 'Unknown', // to be set later after aggregation is completed clientId, count: error.count, countType: error.countType, + countPeriodHours: error.countPeriodHours, ticket: null, alert: null, instances: [error], diff --git a/src/interfaces/AlertProviderInterface.ts b/src/interfaces/AlertProviderInterface.ts index 2727151..570d138 100644 --- a/src/interfaces/AlertProviderInterface.ts +++ b/src/interfaces/AlertProviderInterface.ts @@ -1,7 +1,7 @@ import { ErrorGroup, Alert, AlertContent } from '../models'; export interface AlertProviderInterface { - findAlert(clientId: string): Promise; + findAlert(clientId: string): Promise; createAlert(alertContent: AlertContent): Promise; diff --git a/src/interfaces/PrioritizationProviderInterface.ts b/src/interfaces/PrioritizationProviderInterface.ts index 20dd05e..1d430f0 100644 --- a/src/interfaces/PrioritizationProviderInterface.ts +++ b/src/interfaces/PrioritizationProviderInterface.ts @@ -1,5 +1,10 @@ import { ErrorGroup, ErrorPriority } from '../models'; +export type ErrorPrioritizationResult = { + priority: ErrorPriority, + priorityReason: string, +} + export interface PrioritizationProviderInterface { - determinePriority(errorGroup: ErrorGroup): Promise; + determinePriority(errorGroup: ErrorGroup): Promise; } diff --git a/src/models/Error.ts b/src/models/Error.ts index 9e0e4ad..7e60f12 100644 --- a/src/models/Error.ts +++ b/src/models/Error.ts @@ -20,11 +20,12 @@ export enum ErrorType { } export type Error = { - name, - type, - count, - countType, - debugUrl, + name: string, + type: ErrorType, + count: number, + countType: ErrorCountType, + countPeriodHours: number, + debugUrl: string, }; export type ErrorGroup = { @@ -32,9 +33,11 @@ export type ErrorGroup = { sourceName: string, type: ErrorType, priority: string, + priorityReason: string, clientId: string, count: number, countType: ErrorCountType, + countPeriodHours: number, ticket: Ticket, alert: Alert, instances: Error[], diff --git a/src/providers/ErrorCountPrioritizationProvider.ts b/src/providers/ErrorCountPrioritizationProvider.ts index 449fb33..9a4f2ce 100644 --- a/src/providers/ErrorCountPrioritizationProvider.ts +++ b/src/providers/ErrorCountPrioritizationProvider.ts @@ -1,5 +1,6 @@ import { ErrorGroup, ErrorPriority } from '../models'; -import { PrioritizationProviderInterface } from '../interfaces'; +import { ErrorPrioritizationResult, PrioritizationProviderInterface } from '../interfaces'; +import { getReadableErrorCountPeriod } from "../util/ErrorUtil"; export type ErrorCountPrioritizationProviderThreshold = { threshold: number, @@ -47,10 +48,14 @@ export class ErrorCountPrioritizationProvider implements PrioritizationProviderI this.config = config ?? DefaultErrorCountPrioritizationProviderConfig; } - public async determinePriority(errorGroup: ErrorGroup): Promise { + public async determinePriority(errorGroup: ErrorGroup): Promise { for (const threshold of this.config.thresholds) { if (errorGroup.count < threshold.threshold) { - return threshold.priority; + const countPeriod = getReadableErrorCountPeriod(errorGroup.countPeriodHours); + return { + priority: threshold.priority, + priorityReason: `Affecting ${threshold.label} ${errorGroup.countType} per ${countPeriod}`, + }; } } } diff --git a/src/providers/JiraTicketProvider.ts b/src/providers/JiraTicketProvider.ts index b225c74..5eea6e9 100644 --- a/src/providers/JiraTicketProvider.ts +++ b/src/providers/JiraTicketProvider.ts @@ -1,6 +1,7 @@ import { TicketProviderInterface } from '../interfaces'; import { ErrorGroup, ErrorPriority, Ticket, TicketContent } from '../models'; import JiraApi from 'jira-client'; +import { getReadableErrorCountPeriod, getReadableErrorFrequency } from "../util/ErrorUtil"; export type JiraBasicAuthConfig = { username: string, @@ -164,13 +165,13 @@ export class JiraTicketProvider implements TicketProviderInterface { const maxInstances = 10; const summary = `[${errorGroup.type}] [${errorGroup.sourceName}] ${errorGroup.name}`; - let description = errorGroup.name + - '\nh3.Frequency\n' + - `${errorGroup.count} ${errorGroup.countType} per day` + - '\nh3.Instances\n'; + let description = `{noformat}${errorGroup.name}{noformat}` + + '\nh4.Priority Reason\n' + + `${errorGroup.priorityReason}` + + '\nh4.Instances\n'; for (const instance of errorGroup.instances.slice(0, maxInstances)) { - description += `${instance.name}\n\nTroubleshoot at: [${instance.debugUrl}]`; + description += `{noformat}${instance.name}{noformat}\n\nTroubleshoot at: [${instance.debugUrl}]`; } if (errorGroup.instances.length > 10) { diff --git a/src/providers/NewRelicServerErrorProvider.ts b/src/providers/NewRelicServerErrorProvider.ts index 584f69a..c9a0dea 100644 --- a/src/providers/NewRelicServerErrorProvider.ts +++ b/src/providers/NewRelicServerErrorProvider.ts @@ -55,6 +55,7 @@ export class NewRelicServerErrorProvider implements ErrorProviderInterface { newRelicError.type = ErrorType.SERVER; newRelicError.count = (newRelicError.uniqueCount > 0 ? newRelicError.uniqueCount : newRelicError.count); newRelicError.countType = newRelicError.uniqueCount > 0 ? ErrorCountType.USERS : ErrorCountType.TRX; + newRelicError.countPeriodHours = hoursBack; }); // produce a debug URL that can be used to visualize the error in a browser diff --git a/src/providers/OpsGenieAlertProvider.ts b/src/providers/OpsGenieAlertProvider.ts index dbdb7dc..6690ea8 100644 --- a/src/providers/OpsGenieAlertProvider.ts +++ b/src/providers/OpsGenieAlertProvider.ts @@ -30,7 +30,7 @@ export class OpsGenieAlertProvider implements AlertProviderInterface { } } - public async findAlert(clientId: string): Promise { + public async findAlert(clientId: string): Promise { const opsgenieAlert: any = await new Promise((resolve, reject) => { opsGenie.alertV2.get({ identifier: clientId, @@ -39,23 +39,27 @@ export class OpsGenieAlertProvider implements AlertProviderInterface { if (!error) { return resolve(response.data); } else if (error.httpStatusCode === 404) { - return undefined; + return resolve(undefined); } else if (error instanceof Error) { - throw error; + return reject(error); } else { - throw new Error(error.message || error); + return reject(new Error(error.message || error)); } }); }); - return { - id: clientId, - clientId, - summary: opsgenieAlert.message, - description: opsgenieAlert.description, - priority: opsgenieAlert.priority, - labels: [], - ticketUrl: opsgenieAlert.details['Ticket Link'], + if (!opsgenieAlert) { + return undefined; + } else { + return { + id: clientId, + clientId, + summary: opsgenieAlert.message, + description: opsgenieAlert.description, + priority: opsgenieAlert.priority, + labels: [], + ticketUrl: opsgenieAlert.details['Ticket Link'], + } } } diff --git a/src/providers/S3CacheProvider.ts b/src/providers/S3CacheProvider.ts index 0c3cf90..ca3c79c 100644 --- a/src/providers/S3CacheProvider.ts +++ b/src/providers/S3CacheProvider.ts @@ -36,7 +36,7 @@ export class S3CacheProvider implements CacheProviderInterface { public async saveAllCaches(): Promise { for (const cacheName in this.caches) { - await this.setCache(CacheName[cacheName], this.caches[cacheName]); + await this.setCache(cacheName as CacheName, this.caches[cacheName]); } } @@ -63,7 +63,6 @@ export class S3CacheProvider implements CacheProviderInterface { } private async setCache(name: CacheName, data: Record): Promise { - console.log('Saving', data); const s3 = new AWS.S3(); const params = { Bucket: this.config.bucket, diff --git a/src/util/ErrorUtil.ts b/src/util/ErrorUtil.ts new file mode 100644 index 0000000..f047372 --- /dev/null +++ b/src/util/ErrorUtil.ts @@ -0,0 +1,24 @@ +import { ErrorGroup } from "../models"; + +export const getReadableErrorFrequency = (error: ErrorGroup) => { + let countPeriod = getReadableErrorCountPeriod(error.countPeriodHours); + return `${error.count} ${error.countType} ${countPeriod}`; // e.g. 11 users per day +} + + +export const getReadableErrorCountPeriod = (countPeriodHours: number) => { + if (countPeriodHours === 1) { + return '1 hour'; + } else if (countPeriodHours < 24) { + return `${countPeriodHours} hours`; + } + + const days = Math.floor(countPeriodHours / 24); + const hours = countPeriodHours % 24; + + if (hours === 0) { + return (days > 1 ? `${days} days` : 'day'); // e.g. day, 2 days + } else { + return `${days}d ${hours}h`; // e.g. 1d 12h + } +}