Skip to content

Commit 88e6c3f

Browse files
authored
Merge branch 'dev' into electron-react
2 parents 70e1248 + 8b4c983 commit 88e6c3f

11 files changed

Lines changed: 1069 additions & 11591 deletions

Communication.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
const mongoose = require('mongoose');
2+
3+
mongoose.model('Communication', {
4+
currentMicroservice: {
5+
type: String,
6+
},
7+
targetedEndpoint: {
8+
type: String,
9+
},
10+
reqType: {
11+
type: String,
12+
},
13+
resStatus: {
14+
type: Number,
15+
},
16+
resMessage: {
17+
type: String,
18+
},
19+
timeSent: {
20+
type: Date
21+
}
22+
})

MicroserviceHealth.js

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
const mongoose = require("mongoose");
2+
3+
mongoose.model("MicroserviceHealth", {
4+
currentMicroservice: {
5+
type: String,
6+
},
7+
cpuCurrentSpeed: {
8+
type: Number,
9+
},
10+
cpuTemperature: {
11+
type: Number,
12+
},
13+
cpuCurrentLoadMemoryPercentage: {
14+
type: Number,
15+
},
16+
totalMemory: {
17+
type: Number,
18+
},
19+
freeMemory: {
20+
type: Number,
21+
},
22+
usedMemory: {
23+
type: Number,
24+
},
25+
activeMemory: {
26+
type: Number,
27+
},
28+
totalNumProcesses: {
29+
type: Number,
30+
},
31+
numRunningProcesses: {
32+
type: Number,
33+
},
34+
numBlockedProcesses: {
35+
type: Number,
36+
},
37+
numSleepingProcesses: {
38+
type: Number,
39+
},
40+
latency: {
41+
type: Number,
42+
},
43+
timestamp: {
44+
type: Date,
45+
}
46+
});

README.md

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,34 @@
1-
# Chronos
1+
##Chronos Microservice Debugger
2+
Chronos Microservice Debugger consists of an npm package with an optional Electron front end to visualize and monitor your microservices.
3+
4+
## Install
5+
```javascript
6+
npm install chronos-microservice-debugger
7+
```
8+
9+
## Usage
10+
There are two main aspects to Chronos-Microservice-Debugger
11+
*Communication Monitor: Listens in on all microservice-microservice and microservice-client communication and monitors the response statuses and messages to ensure communications are making it to the correct destination successfully.
12+
*Health Monitor: The health monitor checks the status of your microservice every second and sends this health information to an optional electron frontend where it is visualized for easier use.
13+
14+
15+
```javascript
16+
app.use('/', chronos-microservice-debugger.microCom('microserviceName', 'databaseType', 'databaseURL'))
17+
chronos-microservice-debugger.microHealth('microserviceName', databaseType, databaseURL))
18+
```
19+
Chronos uses a user-owned and provided database to ensure that your private data stays private. We currently support MongoDB and SQL/PostgreSQL databases.
20+
21+
## Things in the Works
22+
*gRPC support
23+
*Ability to determine how often your microservice health is monitored (currently every second)
24+
*'Time Travel' to see how your microservices have changed over time
25+
*Docker health information for containerized microservices
26+
*Implement additional unit testing
27+
28+
## Links
29+
*Chronos Website: http://chronos.ninja
30+
*Gitub Page: https://github.com/oslabs-beta/Chronos
31+
32+
## Contact Us
33+
For questions, requests, or more information, please contact us at teammicronos@gmail.com
34+

chronos.js

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
const mongoMiddleware = require('./mwMongo.js')
2+
const sqlMiddleware = require('./mwSQL.js')
3+
4+
const chronos = {}
5+
chronos.microHealth = (microserviceName, databaseType, userOwnedDB) => {
6+
microserviceName.toLowerCase();
7+
databaseType.toLowerCase();
8+
9+
if (!microserviceName || !databaseType || !userOwnedDB) {
10+
throw new Error(
11+
"Please verify that you have provided all three required parameters"
12+
);
13+
}
14+
15+
if (
16+
typeof microserviceName !== "string" ||
17+
typeof databaseType !== "string" ||
18+
typeof userOwnedDB !== "string"
19+
) {
20+
throw new Error(
21+
"Please verify that the parameters you entered are all strings"
22+
);
23+
}
24+
25+
if (databaseType === "mongo" || databaseType === "mongodb") {
26+
return mongoMiddleware.microHealth(userOwnedDB, microserviceName);
27+
} else if (databaseType === "sql" || databaseType === "postgresql") {
28+
return sqlMiddleware.microHealth(userOwnedDB, microserviceName);
29+
} else {
30+
throw new Error (
31+
'Chronos currently only supports Mongo and SQL/PostgresQL databases. Please enter "mongo" or "sql'
32+
);
33+
}
34+
},
35+
chronos.microCom = (microserviceName, databaseType, userOwnedDB, req, res, next) => {
36+
microserviceName.toLowerCase();
37+
databaseType.toLowerCase();
38+
39+
if (!microserviceName || !databaseType || !userOwnedDB) {
40+
throw new Error(
41+
"Please verify that you have provided all three required parameters"
42+
);
43+
}
44+
45+
if (
46+
typeof microserviceName !== "string" ||
47+
typeof databaseType !== "string" ||
48+
typeof userOwnedDB !== "string"
49+
) {
50+
throw new Error(
51+
"Please verify that the parameters you entered are all strings"
52+
);
53+
}
54+
55+
if (databaseType === "mongo" || databaseType === "mongodb") {
56+
return mongoMiddleware.microCom(userOwnedDB, microserviceName);
57+
} else if (databaseType === "sql" || databaseType === "postgresql") {
58+
return sqlMiddleware.microCom(userOwnedDB, microserviceName);
59+
} else {
60+
throw new Error(
61+
'Chronos currently only supports Mongo and SQL/PostgresQL databases. Please enter "mongo" or "sql'
62+
);
63+
}
64+
};
65+
66+
67+
module.exports = chronos;
68+
69+
70+
71+

0 commit comments

Comments
 (0)