Skip to content

Commit

Permalink
fix: Improve metrics in mocked-backend for metrics service (#2274)
Browse files Browse the repository at this point in the history
* Emit one metric event at a time

Signed-off-by: Carson Cook <carson.cook@ibm.com>

* Convert metrics to json with values

Signed-off-by: Carson Cook <carson.cook@ibm.com>
  • Loading branch information
CarsonCook committed Apr 7, 2022
1 parent d888a11 commit f12ebe8
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 24 deletions.
@@ -0,0 +1,69 @@
{
"rollingCountFallbackSuccess": 10,
"rollingCountFallbackFailure": 1,
"propertyValue_circuitBreakerRequestVolumeThreshold": 20,
"propertyValue_circuitBreakerForceOpen": false,
"propertyValue_metricsRollingStatisticalWindowInMilliseconds": 10000,
"latencyTotal_mean": 10,
"rollingMaxConcurrentExecutionCount": 2,
"type": "HystrixCommand",
"rollingCountResponsesFromCache": 2,
"rollingCountBadRequests": 1,
"rollingCountTimeout": 1,
"propertyValue_executionIsolationStrategy": "SEMAPHORE",
"rollingCountFailure": 1,
"rollingCountExceptionsThrown": 1,
"rollingCountFallbackMissing": 1,
"threadPool": "NotFoundErrorController",
"latencyExecute_mean": 1,
"isCircuitBreakerOpen": false,
"errorCount": 0,
"rollingCountSemaphoreRejected": 1,
"group": "NotFoundErrorController",
"latencyTotal": {
"0": 1,
"99": 2,
"100": 3,
"25": 4,
"90": 5,
"50": 6,
"95": 7,
"99.5": 8,
"75": 9
},
"requestCount": 10,
"rollingCountCollapsedRequests": 15,
"rollingCountShortCircuited": 1,
"propertyValue_circuitBreakerSleepWindowInMilliseconds": 5000,
"latencyExecute": {
"0": 1,
"99": 2,
"100": 3,
"25": 4,
"90": 5,
"50": 6,
"95": 7,
"99.5": 8,
"75": 9
},
"rollingCountEmit": 10,
"currentConcurrentExecutionCount": 15,
"propertyValue_executionIsolationSemaphoreMaxConcurrentRequests": 1000,
"errorPercentage": 1,
"rollingCountThreadPoolRejected": 1,
"propertyValue_circuitBreakerEnabled": false,
"propertyValue_executionIsolationThreadInterruptOnTimeout": true,
"propertyValue_requestCacheEnabled": true,
"rollingCountFallbackRejection": 1,
"propertyValue_requestLogEnabled": true,
"rollingCountFallbackEmit": 1,
"rollingCountSuccess": 10,
"propertyValue_fallbackIsolationSemaphoreMaxConcurrentRequests": 10,
"propertyValue_circuitBreakerErrorThresholdPercentage": 50,
"propertyValue_circuitBreakerForceClosed": false,
"name": "SampleServiceExample",
"reportingHosts": 1,
"propertyValue_executionIsolationThreadPoolKeyOverride": "null",
"propertyValue_executionIsolationThreadTimeoutInMilliseconds": 30000,
"propertyValue_executionTimeoutInMilliseconds": 30000
}

This file was deleted.

5 changes: 2 additions & 3 deletions metrics-service-ui/frontend/mocked-backend/routes.js
Expand Up @@ -5,8 +5,7 @@ const loginSuccess = require('./assets/login-success.json');
const invalidCredentials = require('./assets/invalid-credentials.json');
const timeout = require('./assets/timeout-error.json');
const clusters = require('./assets/services/clusters.json');

const metrics = fs.readFileSync(path.join(__dirname, './assets/services/metrics.txt'), 'utf-8');
const metrics = require('./assets/services/metrics.json');

function validateCredentials({ username, password }) {
return username === 'USER' && password === 'validPassword';
Expand Down Expand Up @@ -48,7 +47,7 @@ const appRouter = app => {

res.setHeader('Content-Type', 'text/event-stream');
const responseIntervalId = setInterval(() => {
res.write(metrics);
res.write(`data: ${JSON.stringify(metrics)}\n\n`);
}, 1000);

res.on('close', () => {
Expand Down

0 comments on commit f12ebe8

Please sign in to comment.