@bull-monitor/root
Advanced tools
Comparing version 0.27.3 to 0.28.0
@@ -6,2 +6,13 @@ # Change Log | ||
# [0.28.0](https://github.com/s-r-x/bull-monitor/compare/v0.27.3...v0.28.0) (2021-07-07) | ||
### Features | ||
* metrics ([16af366](https://github.com/s-r-x/bull-monitor/commit/16af36690d03fdaed45ce351f3e0bf773492aac6)) | ||
## [0.27.3](https://github.com/s-r-x/bull-monitor/compare/v0.27.2...v0.27.3) (2021-07-01) | ||
@@ -8,0 +19,0 @@ |
@@ -9,5 +9,2 @@ import { DataSource } from 'apollo-datasource'; | ||
}; | ||
export declare class BullMonitorError extends Error { | ||
constructor(msg: any); | ||
} | ||
export declare enum ErrorEnum { | ||
@@ -14,0 +11,0 @@ QUEUE_NOT_FOUND = "Queue not found", |
@@ -15,3 +15,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.BullDataSource = exports.ErrorEnum = exports.BullMonitorError = void 0; | ||
exports.BullDataSource = exports.ErrorEnum = void 0; | ||
const apollo_datasource_1 = require("apollo-datasource"); | ||
@@ -23,10 +23,3 @@ const json_1 = require("../../../services/json"); | ||
const isNil_1 = __importDefault(require("lodash/isNil")); | ||
class BullMonitorError extends Error { | ||
constructor(msg) { | ||
super(msg); | ||
this.message = msg; | ||
this.name = 'BullMonitorError'; | ||
} | ||
} | ||
exports.BullMonitorError = BullMonitorError; | ||
const errors_1 = require("../errors"); | ||
var ErrorEnum; | ||
@@ -54,3 +47,3 @@ (function (ErrorEnum) { | ||
_throwInternalError(e) { | ||
throw new BullMonitorError(e); | ||
throw new errors_1.BullMonitorError(e); | ||
} | ||
@@ -57,0 +50,0 @@ _throwQueueNotFound() { |
export { BullDataSource } from './bull'; | ||
export { MetricsDataSource } from './metrics'; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.BullDataSource = void 0; | ||
exports.MetricsDataSource = exports.BullDataSource = void 0; | ||
var bull_1 = require("./bull"); | ||
Object.defineProperty(exports, "BullDataSource", { enumerable: true, get: function () { return bull_1.BullDataSource; } }); | ||
var metrics_1 = require("./metrics"); | ||
Object.defineProperty(exports, "MetricsDataSource", { enumerable: true, get: function () { return metrics_1.MetricsDataSource; } }); | ||
//# sourceMappingURL=index.js.map |
@@ -78,4 +78,14 @@ "use strict"; | ||
}, | ||
clearMetrics(_, args, { dataSources: { metrics } }) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return yield metrics.clearMetrics(args.queue); | ||
}); | ||
}, | ||
clearAllMetrics(_, __, { dataSources: { metrics } }) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return yield metrics.clearAllMetrics(); | ||
}); | ||
}, | ||
}, | ||
}; | ||
//# sourceMappingURL=mutation.js.map |
@@ -20,2 +20,7 @@ "use strict"; | ||
}, | ||
metrics(_, args, { dataSources: { metrics } }) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return yield metrics.getMetrics(args.queue, args.start, args.end); | ||
}); | ||
}, | ||
queues(_, __, { dataSources: { bull } }) { | ||
@@ -22,0 +27,0 @@ return bull.getQueues(); |
@@ -55,3 +55,3 @@ "use strict"; | ||
}, | ||
isPaused(parent, _, { dataSources: { bull } }) { | ||
isPaused(parent) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
@@ -68,4 +68,9 @@ return yield parent.isPaused(); | ||
}, | ||
metrics(parent, _, { dataSources: { metrics } }) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return yield metrics.getMetrics(parent.name); | ||
}); | ||
}, | ||
}, | ||
}; | ||
//# sourceMappingURL=queue.js.map |
import type { IResolvers } from 'graphql-tools'; | ||
import { BullDataSource } from '../data-sources'; | ||
import { BullDataSource, MetricsDataSource } from '../data-sources'; | ||
declare type DataSources = { | ||
dataSources: { | ||
bull: BullDataSource; | ||
metrics: MetricsDataSource; | ||
}; | ||
@@ -7,0 +8,0 @@ }; |
@@ -9,2 +9,3 @@ "use strict"; | ||
const root_query_1 = require("./root-query"); | ||
const metrics_1 = require("./metrics"); | ||
exports.typeDefs = [ | ||
@@ -14,2 +15,3 @@ redis_info_1.redisInfoTypeDef, | ||
queue_1.queueTypeDef, | ||
metrics_1.metricsTypeDef, | ||
mutations_1.mutationsTypeDef, | ||
@@ -16,0 +18,0 @@ root_query_1.rootQueryTypeDef, |
@@ -92,4 +92,7 @@ "use strict"; | ||
removeJobsByPattern(queue: String!, pattern: String!): Boolean | ||
clearMetrics(queue: String!): Boolean | ||
clearAllMetrics: Boolean | ||
} | ||
`; | ||
//# sourceMappingURL=mutations.js.map |
@@ -50,4 +50,5 @@ "use strict"; | ||
isPaused: Boolean! | ||
metrics: [QueueMetrics!] | ||
} | ||
`; | ||
//# sourceMappingURL=queue.js.map |
@@ -17,2 +17,3 @@ "use strict"; | ||
queue(name: String!): Queue | ||
metrics(queue: String!, start: Int = 0, end: Int = -1): [QueueMetrics!] | ||
jobs( | ||
@@ -19,0 +20,0 @@ queue: String! |
@@ -1,13 +0,9 @@ | ||
import type { Queue } from 'bull'; | ||
import type { ApolloServerBase, Config as ApolloConfig } from 'apollo-server-core'; | ||
export declare type Config = { | ||
queues: Queue[]; | ||
gqlPlayground?: boolean; | ||
gqlIntrospection?: boolean; | ||
baseUrl?: string; | ||
textSearchScanCount?: number; | ||
}; | ||
import type { Config, MetricsConfig } from './typings/config'; | ||
export declare abstract class BullMonitor<TServer extends ApolloServerBase> { | ||
constructor(config: Config); | ||
abstract init(...args: any): Promise<any>; | ||
private ui; | ||
private metricsCollector?; | ||
private _defaultMetricsConfig; | ||
private _defaultConfig; | ||
@@ -17,3 +13,2 @@ protected gqlBasePath: string; | ||
protected server: TServer; | ||
constructor(config: Config); | ||
protected createServer(Server: new (config: ApolloConfig) => TServer): void; | ||
@@ -26,1 +21,2 @@ protected startServer(): Promise<void>; | ||
} | ||
export { Config, MetricsConfig }; |
@@ -18,4 +18,11 @@ "use strict"; | ||
const config_1 = require("./gql/data-sources/bull/config"); | ||
const metrics_collector_1 = require("./services/metrics-collector"); | ||
class BullMonitor { | ||
constructor(config) { | ||
this._defaultMetricsConfig = { | ||
redisPrefix: 'bull_monitor::metrics::', | ||
collectInterval: { hours: 1 }, | ||
maxMetrics: 100, | ||
blacklist: [], | ||
}; | ||
this._defaultConfig = { | ||
@@ -27,6 +34,12 @@ queues: [], | ||
textSearchScanCount: config_1.DEFAULT_TEXT_SEARCH_SCAN_COUNT, | ||
metrics: false, | ||
}; | ||
this.gqlBasePath = '/graphql'; | ||
this.config = Object.assign(Object.assign({}, this._defaultConfig), config); | ||
this.config = Object.assign(Object.assign(Object.assign({}, this._defaultConfig), config), { metrics: config.metrics | ||
? Object.assign(Object.assign({}, this._defaultMetricsConfig), config.metrics) : false }); | ||
this.ui = new ui_1.UI(); | ||
if (this.config.metrics) { | ||
this.metricsCollector = new metrics_collector_1.MetricsCollector(this.config.queues, this.config.metrics); | ||
this.metricsCollector.startCollecting(); | ||
} | ||
} | ||
@@ -44,2 +57,3 @@ createServer(Server) { | ||
}), | ||
metrics: new data_sources_1.MetricsDataSource(this.metricsCollector), | ||
}), | ||
@@ -46,0 +60,0 @@ }); |
@@ -53,2 +53,6 @@ export declare type Maybe<T> = T | null; | ||
export declare type JobDataSearchInput = { | ||
/** | ||
* any key supported by https://lodash.com/docs/4.17.15#get | ||
* if not specified text search will be performed on the whole stringified data | ||
*/ | ||
key?: Maybe<Scalars['String']>; | ||
@@ -67,3 +71,4 @@ term: Scalars['String']; | ||
Failed = "failed", | ||
Paused = "paused" | ||
Paused = "paused", | ||
Stuck = "stuck" | ||
} | ||
@@ -113,2 +118,4 @@ export declare enum JobStatusClean { | ||
removeJobsByPattern?: Maybe<Scalars['Boolean']>; | ||
clearMetrics?: Maybe<Scalars['Boolean']>; | ||
clearAllMetrics?: Maybe<Scalars['Boolean']>; | ||
}; | ||
@@ -182,2 +189,5 @@ export declare type MutationPauseQueueArgs = { | ||
}; | ||
export declare type MutationClearMetricsArgs = { | ||
queue: Scalars['String']; | ||
}; | ||
export declare enum OrderEnum { | ||
@@ -190,2 +200,3 @@ Asc = "ASC", | ||
queue?: Maybe<Queue>; | ||
metrics?: Maybe<Array<QueueMetrics>>; | ||
jobs: Array<Job>; | ||
@@ -198,2 +209,7 @@ job?: Maybe<Job>; | ||
}; | ||
export declare type QueryMetricsArgs = { | ||
queue: Scalars['String']; | ||
start?: Maybe<Scalars['Int']>; | ||
end?: Maybe<Scalars['Int']>; | ||
}; | ||
export declare type QueryJobsArgs = { | ||
@@ -233,2 +249,3 @@ queue: Scalars['String']; | ||
isPaused: Scalars['Boolean']; | ||
metrics?: Maybe<Array<QueueMetrics>>; | ||
}; | ||
@@ -243,2 +260,6 @@ export declare type QueueJobsCounts = { | ||
}; | ||
export declare type QueueMetrics = { | ||
timestamp: Scalars['Float']; | ||
counts: QueueJobsCounts; | ||
}; | ||
export declare type RedisInfo = { | ||
@@ -245,0 +266,0 @@ redis_version: Scalars['String']; |
@@ -17,2 +17,3 @@ "use strict"; | ||
JobStatus["Paused"] = "paused"; | ||
JobStatus["Stuck"] = "stuck"; | ||
})(JobStatus = exports.JobStatus || (exports.JobStatus = {})); | ||
@@ -19,0 +20,0 @@ var JobStatusClean; |
{ | ||
"name": "@bull-monitor/root", | ||
"version": "0.27.3", | ||
"version": "0.28.0", | ||
"repository": { | ||
@@ -27,3 +27,4 @@ "type": "git", | ||
"lodash": "^4.17.21", | ||
"redis-info": "^3.0.8" | ||
"redis-info": "^3.0.8", | ||
"toad-scheduler": "^1.4.0" | ||
}, | ||
@@ -40,3 +41,3 @@ "devDependencies": { | ||
}, | ||
"gitHead": "30ede6af96cc5267d8b78e980327faff2954f36a" | ||
"gitHead": "645b53888c9da129ce92be6f1c6e42942ad398d3" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
111677
85
1907
5
+ Addedtoad-scheduler@^1.4.0
+ Addedtoad-scheduler@1.6.1(transitive)