Skip to content

Commit 23a742d

Browse files
authored
Merge pull request #6 from oslabs-beta/npm-package
Add files via upload
2 parents d64ed21 + dd14430 commit 23a742d

8 files changed

Lines changed: 657 additions & 185 deletions

File tree

Communication.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@ mongoose.model('Communication', {
1717
type: String,
1818
},
1919
timeSent: {
20-
type: Date,
20+
type: Date
2121
}
2222
})

MicroserviceHealth.js

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,54 +3,44 @@ const mongoose = require("mongoose");
33
mongoose.model("MicroserviceHealth", {
44
currentMicroservice: {
55
type: String,
6-
required: true
76
},
87
cpuCurrentSpeed: {
98
type: Number,
10-
required: true
119
},
1210
cpuTemperature: {
1311
type: Number,
14-
required: true
12+
},
13+
cpuCurrentLoadMemoryPercentage: {
14+
type: Number,
1515
},
1616
totalMemory: {
1717
type: Number,
18-
required: true
1918
},
2019
freeMemory: {
2120
type: Number,
22-
required: true
2321
},
2422
usedMemory: {
2523
type: Number,
26-
required: true
2724
},
2825
activeMemory: {
2926
type: Number,
30-
required: true
3127
},
3228
totalNumProcesses: {
3329
type: Number,
34-
required: true
3530
},
3631
numRunningProcesses: {
3732
type: Number,
38-
required: true
3933
},
4034
numBlockedProcesses: {
4135
type: Number,
42-
required: true
4336
},
4437
numSleepingProcesses: {
4538
type: Number,
46-
required: true
4739
},
4840
latency: {
4941
type: Number,
50-
required: true
5142
},
5243
timestamp: {
5344
type: Date,
54-
required: true
5545
}
5646
});

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-debgugger.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: http://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)