Skip to content

Commit 86bd551

Browse files
committed
merged with dev, still debugging, need to switch to dev
2 parents 498f437 + 105b4d0 commit 86bd551

File tree

10 files changed

+281
-53
lines changed

10 files changed

+281
-53
lines changed

.DS_Store

0 Bytes
Binary file not shown.

README.md

Lines changed: 105 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,110 @@
1-
# What is Chronos?
2-
A tool for visualizing communication and health throughout a microservices application
1+
![Chronos logo](https://raw.githubusercontent.com/Chronos2-0/Chronos/master/app/assets/logo2.png)
2+
## Chronos
3+
Microservice communication and health visualizer.
34

4-
## How can I use Chronos?
5-
1. Go to https://www.npmjs.com/package/chronos-microservice-debugger and follow the instructions to install the NPM package within each microservice of your application
6-
2. Download this repo
7-
3. Inside the downloaded directory, run `npm install` followed by `npm start`
5+
[![NPM Version][npm-image]][npm-url]
6+
[![NPM Downloads][downloads-image]][downloads-url]
7+
8+
```js
9+
const cmd = require('chronos-microservice-debugger3')
10+
cmd.propagate()
11+
12+
app.use('/', cmd.microCom('microserviceName', 'databaseType', 'databaseURL', 'wantMicroHealth', 'queryFrequency'))
13+
```
14+
15+
## Features
16+
17+
* HTTP request tracing
18+
* Speed and latency tracking
19+
* Process monitoring
20+
* Memory usage
21+
22+
## Installation
23+
24+
Chronos consists of a [Node](https://nodejs.org/en/) module available through the
25+
[npm registry](https://www.npmjs.com/) and a lightweight [Electron](https://electronjs.org/) desktop application.
26+
27+
#### Node module
28+
29+
To begin, install the [Chronos](https://www.npmjs.com/package/chronos-microservice-debugger3) node module within each microservice of your application using the
30+
[`npm install`](https://docs.npmjs.com/getting-started/installing-npm-packages-locally)command:
31+
32+
```
33+
npm install chronos-microservice-debugger3
34+
```
35+
36+
Once installed, write the following two lines at the top of each microservice's server file:
37+
```javascript
38+
const cmd = require('chronos-microservice-debugger3');
39+
cmd.propagate();
40+
```
41+
42+
Then add a route handler for all incoming requests:
43+
```js
44+
app.use('/', cmd.microCom('microserviceName', 'databaseType', 'databaseURL', 'wantMicroHealth', 'queryFrequency'))
45+
```
46+
47+
The cmd.microCom handler function logs communication and health data to a user-provided database. This is to ensure that your private data stays private. We currently support MongoDB and SQL/PostgreSQL databases.
48+
49+
cmd.microCom takes four parameters and an optional fifth parameter. You can enter the arguments as individual strings or as an array.
50+
51+
The parameters are:
52+
1. microserviceName: To identify the microservice (i.e. "payments")
53+
2. databaseType: Enter either "mongo" or "sql"
54+
3. databaseURL: Enter the URL of your database
55+
4. wantMicroHealth: Do you want to monitor the health of this microservice? Enter "yes" or "no"
56+
5. queryFrequency (optional): How frequently do you want to log the health of this microservice? It defaults to every minute, but you can choose:
57+
* "s" : every second
58+
* "m" : every minute (default)
59+
* "h" : every hour
60+
* "d" : once per day
61+
* "w" : once per week
62+
63+
String parameter example:
64+
```javascript
65+
app.use('/', cmd.microCom('payments', 'mongo', 'mongodb+srv://user:[email protected]/','yes','h'))
66+
```
67+
68+
Array parameter example:
69+
```javascript
70+
let values = [
71+
'payments',
72+
'mongo',
73+
'mongodb+srv://user:[email protected]/',
74+
'yes',
75+
'h'
76+
]
77+
78+
app.use('/', cmd.microCom(values)
79+
```
80+
81+
#### Electron desktop application
82+
83+
After installing the node module in each microservice, download the Electron desktop application from the public [Chronos](https://github.com/Chronos2-0/Chronos) repo.
84+
85+
Inside the downloaded directory, install all dependencies using the `npm install` command followed by the `npm start` command to start the Electron desktop application.
86+
87+
## Contributing
888
9-
## How can I contribute to Chronos?
1089
Chronos hopes to inspire an active community of both users and developers. For questions, comments, or contributions, please submit a pull request.
1190
12-
## Who created Chronos?
13-
* Mohtasim Chowdhury
14-
* Natalie Umanzor
15-
* Michelle Herrera
16-
* Duane McFarlane
17-
* Ben Mizel
18-
* Timothy Atapagra
19-
* Jenae Pennie
20-
* Chris Romano
21-
* Ousman Diallo
91+
## People
92+
93+
[Tim Atapagra](https://github.com/orgs/Chronos2-0/people/timpagra),
94+
[Mohtasim Chowdhury](https://github.com/mohtasim317),
95+
[Ousman Diallo](https://github.com/orgs/Chronos2-0/people/Dialloousman),
96+
[Michelle Herrera](https://github.com/mesherrera),
97+
[Duane McFarlane](https://github.com/Duane11003),
98+
[Ben Mizel](https://github.com/orgs/Chronos2-0/people/ben-mizel),
99+
[Jenae Pennie](https://github.com/orgs/Chronos2-0/people/jenaepen),
100+
[Chris Romano](https://github.com/orgs/Chronos2-0/people/robicano22),
101+
[Natalie Umanzor](https://github.com/nmczormick)
102+
103+
## License
104+
105+
[MIT](LICENSE)
22106
107+
[npm-image]: https://img.shields.io/npm/v/chronos-microservice-debugger3.svg
108+
[npm-url]: https://www.npmjs.com/package/chronos-microservice-debugger3
109+
[downloads-image]: https://img.shields.io/npm/dm/chronos-microservice-debugger3.svg
110+
[downloads-url]: https://npmjs.org/package/chronos-microservice-debugger3

app/assets/chartModal.png

22.9 KB
Loading
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
import React, { useContext } from 'react';
2+
import { Bar } from 'react-chartjs-2';
3+
import CommunicationsContext from '../context/OverviewContext';
4+
5+
const MicroServiceTraffic = (props) => {
6+
const communicationsData = useContext(CommunicationsContext).overviewData;
7+
8+
//initialize an empty object resObj. This object will store the microservice names as values and its corresponding correlatingId or correlatingid as keys. The microservice names will be stored in array within the order it was to the database.
9+
const resObj = {};
10+
11+
if(communicationsData.length>0 && communicationsData[0]["_id"]){
12+
//Sort the communication array from latest to earliest document
13+
communicationsData.sort((a,b)=>{
14+
if(new Date(a.timeSent) > new Date(b.timeSent)) return 1;
15+
if(new Date(a.timeSent) < new Date(b.timeSent)) return -1;
16+
return 0;
17+
});
18+
19+
//Iterate over sorted communicationsData array from the end to the beginning
20+
for (let i = 0; i < communicationsData.length; i+=1) {
21+
//declare a constant element and initialize it as the object at index i of the communicationsData array
22+
const element = communicationsData[i];
23+
//Pushes the microservice name into the object
24+
if (resObj[element.correlatingId]) {
25+
resObj[element.correlatingId].push(element.currentMicroservice);
26+
}
27+
else resObj[element.correlatingId] = [element.currentMicroservice];
28+
}
29+
}
30+
31+
else {
32+
33+
for (let i = communicationsData.length-1; i >= 0; i--) {
34+
const element = communicationsData[i];
35+
if (resObj[element.correlatingid]) resObj[element.correlatingid].push(element.currentmicroservice);
36+
else resObj[element.correlatingid] = [element.currentmicroservice];
37+
// initializing the object with the first microservice
38+
};
39+
}
40+
41+
//use object values to destructure locations
42+
const tracePoints = Object.values(resObj);
43+
let position = communicationsData[0].correlatingid ? 0 : tracePoints.length-1;
44+
45+
// Declare Micro-server-count dictinary to capture the amount of times a particular server is hit
46+
const microServiceCountdictionary = {};
47+
48+
// iterate over Trace Points
49+
for (let i = 0; i < tracePoints[position].length; i+=1) {
50+
51+
// populate Micro-count dictionary
52+
if (!microServiceCountdictionary[tracePoints[position][i]]) {
53+
microServiceCountdictionary[tracePoints[position][i]] = 1;
54+
} else {
55+
microServiceCountdictionary[tracePoints[position][i]]+=1
56+
}
57+
};
58+
59+
// capture values of microServiceCountdictionary to use as data to populate chart object
60+
const serverPingCount = Object.values(microServiceCountdictionary);
61+
62+
63+
// Create chart object data to feed into bar component
64+
const myChart = {
65+
//spread dictionary keys inorder to properly label chart x axis
66+
labels: [...Object.keys(microServiceCountdictionary)],
67+
datasets: [
68+
{
69+
label: 'Times server Pinged',
70+
backgroundColor: 'rgba(241, 207, 70,1)',
71+
borderColor: 'rgba(0,0,0,1)',
72+
borderWidth: 1,
73+
data: [...serverPingCount, 0] // spread ping count array into data array to have chart populate the Y axis
74+
}
75+
]
76+
}
77+
78+
79+
// return div with Bar component and Trace Points data
80+
return (
81+
<div>
82+
<Bar
83+
data={myChart}
84+
width={100}
85+
height={50}
86+
options={{
87+
title:{
88+
display:true,
89+
text:'Microservices Overview',
90+
fontSize:20
91+
},
92+
legend:{
93+
display:true,
94+
position:'right'
95+
}
96+
}}
97+
/>
98+
</div>
99+
)
100+
};
101+
102+
export default MicroServiceTraffic;
103+

app/charts/route-trace.jsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/* eslint-disable react/jsx-one-expression-per-line */
22
import React, { useContext } from 'react';
3+
import { Bar } from 'react-chartjs-2';
34
import CommunicationsContext from '../context/OverviewContext';
45

56
const RouteLocations = (props) => {
@@ -10,14 +11,12 @@ const RouteLocations = (props) => {
1011

1112
if (communicationsData.length > 0 && communicationsData[0]._id) {
1213
// Sort the communication array from latest to earliest document
13-
// communicationsData.sort((a,b)=>{ new Date(a.timeSent) - new Date(b.timeSent)})
1414
communicationsData.sort((a, b) => {
1515
if (new Date(a.timeSent) > new Date(b.timeSent)) return 1;
1616
if (new Date(a.timeSent) < new Date(b.timeSent)) return -1;
1717
return 0;
1818
});
1919

20-
2120
// Iterate over sorted communicationsData array from the end to the beginning
2221
for (let i = 0; i < communicationsData.length; i += 1) {
2322
// declare a constant element and initialize it as the object at index i of the communicationsData array
@@ -26,7 +25,6 @@ const RouteLocations = (props) => {
2625
if (resObj[element.correlatingId]) {
2726
resObj[element.correlatingId].push(element.currentMicroservice);
2827
} else resObj[element.correlatingId] = [element.currentMicroservice];
29-
// initializing the object with the first microservice
3028
}
3129
} else {
3230
for (let i = communicationsData.length - 1; i >= 0; i--) {
@@ -43,7 +41,9 @@ const RouteLocations = (props) => {
4341

4442
const resArray = [];
4543

44+
// iterate over Trace Points
4645
for (let i = 0; i < tracePoints[position].length; i += 1) {
46+
// push into resulting array current tracepoint as div
4747
resArray.push(
4848
<div className="RouteCircle" key={i}>
4949
<p id="routeText">Point {i + 1}: {tracePoints[position][i]}</p>
@@ -53,10 +53,12 @@ const RouteLocations = (props) => {
5353

5454
console.log('resArray: ', resArray);
5555

56+
57+
// return div with Trace Points data
5658
return (
57-
<div id="routes">
58-
{resArray}
59-
</div>
59+
<div>
60+
{resArray}
61+
</div>
6062
);
6163
};
6264

app/components/Modal.jsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import TemperatureChart from '../charts/temperature-chart.jsx';
77
import LatencyChart from '../charts/latency-chart.jsx';
88
import MemoryChart from '../charts/memory-chart.jsx';
99
import RouteTrace from '../charts/route-trace.jsx';
10+
import MicroServiceTraffic from '../charts/microservice-traffic.jsx';
1011

1112
const Modal = (props) => {
1213
// Destructuring props to make linter happy
@@ -21,6 +22,7 @@ const Modal = (props) => {
2122
speed: <SpeedChart service={service} />,
2223
processes: <ProcessesChart service={service} />,
2324
latency: <LatencyChart service={service} />,
25+
Traffic: <MicroServiceTraffic service={service} />,
2426
temperature: <TemperatureChart service={service} />,
2527
memory: <MemoryChart service={service} />,
2628
};

app/components/ServiceDetails.jsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ const ServiceDetails = (props) => {
2222
const { currentMicroservice } = props;
2323

2424
// Dictionary used by the healthInfoButtons loop below
25-
// { id: 'request', alt: 'Request Data', src: 'https://st2.depositphotos.com/3894705/9581/i/950/depositphotos_95816620-stock-photo-round-button-shows-speedometer.jpg' },
2625

2726
const buttonProperties = [
2827
{ id: 'request', alt: 'Request Data', src: 'app/assets/pieChart.png' },

0 commit comments

Comments
 (0)