MCPcopy Index your code
hub / github.com/scality/cloudserver / routeHandler

Function routeHandler

lib/utilities/monitoringHandler.js:222–242  ·  view source on GitHub ↗
(req, res, cb)

Source from the content-addressed store, hash-verified

220 registry.clusterMetrics.bind(registry) : registry.metrics.bind(registry);
221
222async function routeHandler(req, res, cb) {
223 if (req.method !== 'GET') {
224 return cb(errors.BadRequest, []);
225 }
226 let promMetrics;
227 try {
228 // Catch timeout on IPC between worker and primary
229 // prom-client has a 5s hardcoded timeout
230 promMetrics = await getMetrics();
231 } catch (err) {
232 return cb(err, { message: err.toString() });
233 }
234
235 const contentLen = Buffer.byteLength(promMetrics, 'utf8');
236 res.writeHead(200, {
237 'Content-Length': contentLen,
238 'Content-Type': registry.contentType,
239 });
240 res.end(promMetrics);
241 return undefined;
242}
243
244/**
245 * Checks if client IP address is allowed to make http request to

Callers 1

monitoringHandlerFunction · 0.70

Calls 2

getMetricsFunction · 0.85
endMethod · 0.80

Tested by

no test coverage detected