Skip to content

Commit 8b39aa8

Browse files
authored
Merge pull request #13 from hodesza/Static_files
Images look good, instructions are fairly clear.
2 parents 68b5239 + 4a00482 commit 8b39aa8

File tree

6 files changed

+271
-14
lines changed

6 files changed

+271
-14
lines changed

CONTRIBUTING.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,14 @@ Chronos welcomes all pull requests.
1313
5. Make sure code is formatted with `prettier` and follows the [Airbnb React/JSX Style Guide](https://github.com/airbnb/javascript/blob/master/react/README.md).
1414
6. Create a pull request to `master`.
1515

16+
## Getting started
17+
- `npm run bot`: Run Node and Electron at the same time to start Chronos app
18+
- To make changes to codebase on the Main Process
19+
- Files in the main process must be compiled prior to starting the app
20+
- In the terminal un Chronos directory, input `tsc` to comile typescript files
21+
- Once compiled, `npm run both`
22+
* Note** If typescript is not installed, `npm install -g typescript`
23+
1624
## Issues
1725

1826
Please do not hesitate to file issues. Chronos is based off of community feedback and is always looking for ways to get better. The team behind Chronos is interested to hear about your experience and how we can improve it.

README.md

Lines changed: 128 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
Chronos is a comprehensive developer tool that monitors the health and web traffic of servers, microservices, and containers. Use Chronos to see real-time data monitoring and receive automated notifications over Slack or email.
1818

1919
## Table of Contents
20-
20+
- [New-Features](#new-feature)
2121
- [Features](#features)
2222
- [Demo](#demo)
2323
- [Installation](#installation)
@@ -34,18 +34,31 @@ Chronos is a comprehensive developer tool that monitors the health and web traff
3434
- [Examples](#examples)
3535
- [Microservices](#microservices)
3636
- [Docker](#docker)
37-
- [Middleware](#middleware-branch)
37+
- [gRPC](#grpc-branch)
3838
- [Technologies](#technologies)
3939
- [License](#license)
4040

4141
#
4242
###### Return to [Top](#Chronos)
4343
<br>
4444

45-
## Features
45+
## <img src ="./app/assets/fire.png" height=22 > New-Features <img src ="./app/assets/fire.png" height=24>
46+
47+
- New UI Features
48+
- Dark and Light mode options now available across user sessions.
49+
- Updated charts to now also support gRPC calls
50+
- Integrated log to provide users with relational data on request & response cycle
51+
52+
- Bug Fixes
53+
- Fixed bug where users could only connect to one MongoDB databsae adn would see its microservices listed even when uesrs clicked on apllications using other MongoDb databases
54+
55+
- Chronos now support monitoring for gRPC!
56+
- Distributed tracing across network request
57+
- Currently chronos gRPC tracing for Mongodb and PostgresQL
58+
59+
## Ver 6.0 Features
4660

4761
- Distributed tracing enabled across microservices applications
48-
- Supports <a href="#"><img src="./app/assets/http-logo-color.png" alt="HTTP" title="HTTP" align="center" height="20" /></a> protocol, with <img src="./app/assets/grpc-logo-color.png" alt="gRPC" title="gRPC" align="center" height="20" /></a> _coming soon_
4962
- Compatible with <img src="./app/assets/graphql-logo-color.png" alt="GraphQL" title="GraphQL" align="center" height="20" /></a>
5063
- Provides <a href="#"><img src="./app/assets/docker-logo-color.png" alt="Docker" title="Docker" align="center" height="20" /></a> container stats (e.g. ID, memory usage %, CPU usage %, running processes, etc.)
5164
- Supports <a href="#"><img src="./app/assets/postgres-logo-color.png" alt="PostgreSQL" title="PostgreSQL" align="center" height="20" /></a> and <img src="./app/assets/mongo-logo-color.png" alt="MongoDB" title="MongoDB" align="center" height="20" /></a> databases
@@ -87,7 +100,7 @@ To use Chronos in your existing application, download and install the following
87100
npm install chronos-tracker
88101
```
89102

90-
### Configure Chronos
103+
### Configure Chronos for REST or gRPC
91104

92105
Similarly, in the **root directory** of _each of your microservice applications_, create a `chronos-config.js` file with properties listed below:
93106

@@ -101,6 +114,7 @@ chronos.use({
101114
interval: 2000,
102115
dockerized: true,
103116
database: {
117+
connection: 'REST',
104118
type: 'MongoDB',
105119
URI: process.env.MONGO_URI,
106120
},
@@ -115,6 +129,7 @@ The `interval` property is optional and takes in an integer. This controls the C
115129
The `dockerized` property is optional and should be specified as `true` if the server is running inside of a Docker container. Otherwise, this should be `false`. If omitted, Chronos will assume this server is not running in a container.
116130

117131
The `database` property is required and takes in the following:
132+
- `connection` which should be a string and only supports 'REST' and 'gRPC'
118133
- `type` which should be a string and only supports 'MongoDB' and 'PostgreSQL'.
119134
- `URI` which should be a connection string the database you intend Chronos to write and record data regarding health, HTTP route tracing, and container infomation to. A `.env` is recommended.
120135

@@ -126,14 +141,15 @@ The `notifications` property is optional. Jump to the section below, [Notificati
126141
<br>
127142
<br>
128143

129-
### Initialize Chronos
144+
### Initialize Chronos for REST
130145

131146
Wherever you create an instance of your server (see example below),
132147

133148
```js
134-
// Example
149+
// Example for REST
135150
const express = require('express');
136151
const app = express());
152+
137153
```
138154

139155
you will also need to require in `chronos-tracker` and initialize Chronos, as well as the `./chronos-config` file. You will then need to invoke `chronos.propagate()` to initiate the route tracing, in addition to implementing `chronos.track()` for all endpoints.
@@ -149,8 +165,110 @@ app.use('/', chronos.track());
149165
```
150166

151167
You should be good to go! The last step, **Docker Configuration**, is **only applicable** if you need to configure <a href="#"><img src="./app/assets/docker-logo-color.png" alt="Docker" title="Docker" align="center" height="20" /></a> for your application.
168+
152169
<br>
153170

171+
172+
### Initialize Chronos for gRPC
173+
174+
Wherever you create an instance of your server (see example below),
175+
176+
177+
```js
178+
// Example of gRPC server
179+
const server = new grpc.Server();
180+
181+
server.bindAsync("127.0.0.1:30044", grpc. ServerCredentials.createInsecure(), () => {
182+
server.start();
183+
console.log("Server running at http://127.0.0.1:30044");
184+
});
185+
```
186+
you will also need to require Chronos-tracker, Chronos-config, and dotenv.config(if this is used). For health data simply use Chronos.track()
187+
188+
189+
190+
```js
191+
//track health data
192+
const chronos = require('chronos-tracker');
193+
require('./chronos-config');
194+
require('dotenv').config(); // set up environment variables in .env
195+
const BookModel = require('./BookModel');
196+
197+
chronos.track()
198+
```
199+
To trace requests, first wrap the gRPC client using Chronos
200+
```js
201+
const grpc = require('@grpc/grpc-js');
202+
const protoLoader = require('@grpc/proto-loader');
203+
const chronos = require('chronos');
204+
205+
const PROTO_PATH = './order.proto';
206+
207+
const packageDefinition = protoLoader.loadSync(PROTO_PATH, {
208+
keepCase: true,
209+
longs: String,
210+
enums: String,
211+
arrays: true,
212+
});
213+
const OrderToBookService = grpc.loadPackageDefinition(packageDefinition).OrderToBook;
214+
const bookClient = new OrderToBookService('localhost:30044', grpc.credentials.createInsecure());
215+
216+
const ClientWrapper = chronos.ClientWrapper(bookClient, OrderToBookService);
217+
```
218+
Next wrap the gRPC server using Chronos
219+
```js
220+
221+
const ServerWrapper = chronos.ServerWrapper(server, Proto.protoname.service, {
222+
AddBook: (call, callback) => {
223+
// console.log(call.metadata)
224+
// get the properties from the gRPC client call
225+
const { title, author, numberOfPages, publisher, bookID } = call.request;
226+
// create a book in our book collection
227+
BookModel.create({
228+
title,
229+
author,
230+
numberOfPages,
231+
publisher,
232+
bookID,
233+
});
234+
callback(null, {});
235+
},
236+
});
237+
})
238+
```
239+
For any request you wish to trace, require uuidv4 and write the following code where the initial gRPC request begins,
240+
```js
241+
const require { v4: uuidv4} = require('uuid')
242+
const createMeta = () => {
243+
const meta = new grpc.Metadata();
244+
meta.add('id', uuidvd());
245+
return meta
246+
}
247+
```
248+
and then invoke createMeta as a third argument to any client method that is the beginning of the request path.
249+
250+
```js
251+
orderClient.AddOrder(
252+
order,
253+
(err, data) => {
254+
if (err !== null) {
255+
console.log(err);
256+
// could not add order because bookID does not exist
257+
return res.sendStatus(404);
258+
}
259+
console.log('addOrder response: ', data);
260+
return res.sendStatus(200);
261+
},
262+
createMeta()
263+
);
264+
265+
```
266+
Finally, on all servers that will be involved in the request path, invoke `chronos.link` with parameters of `client` and `ServerWrapper` in the server wrapper.
267+
268+
```js
269+
chronos.link(client, ServerWrapper);
270+
```
271+
154272
### Docker Configuration
155273

156274
Again, this step is **only applicable** if you are currently using <a href="#"><img src="./app/assets/docker-logo-color.png" alt="Docker" title="Docker" align="center" height="20" /></a> containers for your microservices.
@@ -266,9 +384,9 @@ Refer to the [README](link) in the `docker` folder for more details.
266384

267385
<br>
268386

269-
### Middleware Branch
387+
### gRPC Branch
388+
The **'gRPC'** branch is the current codebase for the <a href="#"><img src="./app/assets/npm-logo-color.png" alt="NPM" title="NPM" align="center" height="20" /></a> package, which is what you will install in your own application in order to use Chronos. Download the <a href="#"><img src="./app/assets/npm-logo-color.png" alt="NPM" title="NPM" align="center" height="20" /></a> package [here](https://www.npmjs.com/package/chronos-tracker).
270389

271-
The **'middleware'** branch is the current codebase for the <a href="#"><img src="./app/assets/npm-logo-color.png" alt="NPM" title="NPM" align="center" height="20" /></a> package, which is what you will install in your own application in order to use Chronos. Download the <a href="#"><img src="./app/assets/npm-logo-color.png" alt="NPM" title="NPM" align="center" height="20" /></a> package [here](https://www.npmjs.com/package/chronos-tracker).
272390
<br>
273391

274392
#
@@ -286,7 +404,7 @@ The **'middleware'** branch is the current codebase for the <a href="#"><img src
286404
- <a href="#"><img src="./app/assets/node-logo-color.png" alt="Node" title="Node" align="center" height="30" /></a>
287405
- <a href="#"><img src="./app/assets/express-logo-color.png" alt="Express" title="Express" align="center" height="30" /></a>
288406
- <a href="#"><img src="./app/assets/http-logo-color.png" alt="HTTP" title="HTTP" align="center" height="30" /></a>
289-
- <a href="#"><img src="./app/assets/grpc-logo-color.png" alt="gRPC" title="gRPC" align="center" height="30" /></a> _coming soon_
407+
- <a href="#"><img src="./app/assets/grpc-logo-color.png" alt="gRPC" title="gRPC" align="center" height="30" /></a>
290408
- <a href="#"><img src="./app/assets/graphql-logo-color.png" alt="GraphQL" title="GraphQL" align="center" height="30" /></a>
291409
- <a href="#"><img src="./app/assets/docker-logo-color.png" alt="Docker" title="Docker" align="center" height="30" /></a>
292410
- <a href="#"><img src="./app/assets/aws-logo-color.png" alt="AWS" title="AWS" align="center" height="30" /></a>

app/assets/dotenvSetup.png

27.5 KB
Loading

app/assets/fire.png

5.79 KB
Loading

examples/gRPC/README.md

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
![Chronos logo](https://raw.githubusercontent.com/Chronos2-0/Chronos/master/app/assets/logo2.png)
2+
## Microservices Architecture
3+
Microservices architecture for testing [Chronos](https://github.com/oslabs-beta/Chronos), a microservice communication and health visualizer.
4+
5+
## Purpose and Design
6+
This sample microservices architecture allows developers to explore the functionality of Chronos with gRPC calls. It consists of 3 microservices, which are contained within the directories:
7+
- Reverse Proxy
8+
- Books
9+
- Orders
10+
11+
Each microservice has its own server, which receives requests from both the client and from other microservices. Books, Customers, and Orders also have their own databases, which they can query to respond to those requests.
12+
13+
## Getting Started w/ gRPC Example Microservices
14+
15+
Follow **'main'** branch READ>ME steps: Pre-Installation, Install Dependencies before start.
16+
17+
On each microservice in example/microserivces, perform the following steps
18+
- *Do this for microservices: books, orders, & reverse proxy
19+
- Install dotenv `npm install dotenv`
20+
- Create a .env file across each ,microservices and input your own Mongodb Atlast URI for both Microservice_URI and CHRONOS_URI
21+
- ** Reverse Proxy .env file will only require CHRONOS_URI
22+
23+
```
24+
BOOK_URI = mongodb+srv://<username>:<password>@cluster0.o2hx5.mongodb.net/<dbname>?retryWrites=true&w=majority
25+
26+
CHRONOS_URI = mongodb+srv://<username>:<password>@cluster0.o2hx5.mongodb.net/<dbname>?retryWrites=true&w=majority
27+
```
28+
- In each Microservice Mode.js file import and set the Microservice_URI
29+
30+
```
31+
const myURI = process.env.BOOK_URI;
32+
33+
```
34+
35+
- In each of the chronos-config.js files, import and set URI property in database to the Chronos_URI as shown
36+
37+
```
38+
require('dotenv').config();
39+
const chronos = require('chronos-tracker');
40+
41+
chronos.use({
42+
microservice: 'name of microservice e.g books or orders',
43+
interval: 2000,
44+
database: {
45+
type: 'MongoDB'
46+
URI: process.env.CHRONOS_URI
47+
},
48+
notifications: [],
49+
})
50+
```
51+
- **Note: The Initialize Chronos step is already taken care of for you.
52+
- Run `npm run start` in each folder directory
53+
- To do so, within each microservice directory, install all dependencies using the `npm install`
54+
- Head over to localhost:3030 to view reverse proxy acting as the frontend of this microservice example
55+
- Start adding data!
56+
- Run `npm run both` to start Electron app
57+
- Add a new application in Chronos app dashboard.
58+
- The URI should be your CHRONOS_URI
59+
60+
61+
**To test the functionality of Chronos using this sample microservices architecture, you must install the [Chronos node module](https://www.npmjs.com/package/chronos-microservice-debugger3) within each microservice. _It is not pre-installed._ Installation instructions for both the Chronos node module and the Chronos desktop visualizer are below:**
62+
63+
64+
#### Electron desktop application
65+
66+
After installing the node module in each microservice, download the Electron desktop application from the public [Chronos](https://github.com/oslabs-beta/Chronos) repo.
67+
68+
Inside the downloaded directory, install all dependencies using the `npm install` command followed by the `npm run both` command to start the Electron desktop application.
69+
70+
## Contributing
71+
72+
Chronos hopes to inspire an active community of both users and developers. For questions, comments, or contributions, please submit a pull request.
73+
74+
## People
75+
76+
[Vince Ho](https://github.com/hodesza)
77+
[Matt Jiang](https://github.com/mattljiang)
78+
[Derek Lam](https://github.com/DerekQuoc)
79+
[Kit Loong Yee](https://github.com/kitloong1)
80+
## License
81+
82+
[MIT](LICENSE)
83+
84+
[npm-image]: https://img.shields.io/npm/v/chronos-microservice-debugger3.svg
85+
[npm-url]: https://www.npmjs.com/package/chronos-microservice-debugger3
86+
[downloads-image]: https://img.shields.io/npm/dm/chronos-microservice-debugger3.svg
87+
[downloads-url]: https://npmjs.org/package/chronos-microservice-debugger3

examples/microservices/README.md

Lines changed: 48 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,53 @@ This sample microservices architecture allows developers to explore the function
1111

1212
Each microservice has its own server, which receives requests from both the client and from other microservices. Books, Customers, and Orders also have their own databases, which they can query to respond to those requests.
1313

14-
**You must replace the placeholder MongoDB Atlas URIs for the databases with your own _actual_ MongoDB Atlas URIs:**
14+
## Getting Started w/ gRPC Example Microservices
15+
16+
Follow **'main'** branch READ>ME steps: Pre-Installation, Install Dependencies before start.
17+
18+
On each microservice in example/microserivces, perform the following steps
19+
- *Do this for microservices: books, orders, & reverse proxy
20+
- Install dotenv `npm install dotenv`
21+
- Create a .env file across each ,microservices and input your own Mongodb Atlast URI for both Microservice_URI and CHRONOS_URI
22+
- ** Reverse Proxy .env file will only require CHRONOS_URI
23+
24+
```
25+
BOOK_URI = mongodb+srv://<username>:<password>@cluster0.o2hx5.mongodb.net/<dbname>?retryWrites=true&w=majority
26+
27+
CHRONOS_URI = mongodb+srv://<username>:<password>@cluster0.o2hx5.mongodb.net/<dbname>?retryWrites=true&w=majority
28+
```
29+
- In each Microservice Mode.js file import and set the Microservice_URI
30+
31+
```
32+
const myURI = process.env.BOOK_URI;
33+
34+
```
35+
36+
- In each of the chronos-config.js files, import and set URI property in database to the Chronos_URI as shown
1537

1638
```
17-
const myURI = 'mongodb+srv://johndoe:[email protected]/';
39+
require('dotenv').config();
40+
const chronos = require('chronos-tracker');
41+
42+
chronos.use({
43+
microservice: 'name of microservice e.g books or orders',
44+
interval: 2000,
45+
database: {
46+
type: 'MongoDB'
47+
URI: process.env.CHRONOS_URI
48+
},
49+
notifications: [],
50+
})
1851
```
52+
- **Note: The Initialize Chronos step is already taken care of for you.
53+
- Run `npm run start` in each folder directory
54+
- To do so, within each microservice directory, install all dependencies using the `npm install`
55+
- Head over to localhost:3000 to view reverse proxy acting as the frontend of this microservice example
56+
- Start adding data!
57+
- Run `npm run both` to start Electron app
58+
- Add a new application in Chronos app dashboard.
59+
- The URI should be your CHRONOS_URI
1960

20-
In order to start the entire application, you will need to start each microservice's server. To do so, within each microservice directory, install all dependencies using the `npm install` command followed by the `npm start` command. You will then be able to interact with the application (as though you are a user) on a barebones frontend, which is being served by the Reverse Proxy server and can be found at localhost:3000.
2161

2262
**To test the functionality of Chronos using this sample microservices architecture, you must install the [Chronos node module](https://www.npmjs.com/package/chronos-microservice-debugger3) within each microservice. _It is not pre-installed._ Installation instructions for both the Chronos node module and the Chronos desktop visualizer are below:**
2363

@@ -84,14 +124,18 @@ app.use('/', cmd.microCom(values)
84124
85125
After installing the node module in each microservice, download the Electron desktop application from the public [Chronos](https://github.com/oslabs-beta/Chronos) repo.
86126
87-
Inside the downloaded directory, install all dependencies using the `npm install` command followed by the `npm start` command to start the Electron desktop application.
127+
Inside the downloaded directory, install all dependencies using the `npm install` command followed by the `npm run both` command to start the Electron desktop application.
88128
89129
## Contributing
90130
91131
Chronos hopes to inspire an active community of both users and developers. For questions, comments, or contributions, please submit a pull request.
92132
93133
## People
94134
135+
[Vince Ho](https://github.com/hodesza)
136+
[Matt Jiang](https://github.com/mattljiang)
137+
[Derek Lam](https://github.com/DerekQuoc)
138+
[Kit Loong Yee](https://github.com/kitloong1)
95139
[Tim Atapagra](https://github.com/timpagra),
96140
[Mohtasim Chowdhury](https://github.com/mohtasim317),
97141
[Ousman Diallo](https://github.com/Dialloousman),

0 commit comments

Comments
 (0)