You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Supports <ahref="#"><imgsrc="./app/assets/postgres-logo-color.png"alt="PostgreSQL"title="PostgreSQL"align="center"height="20" /></a> and <imgsrc="./app/assets/mongo-logo-color.png"alt="MongoDB"title="MongoDB"align="center"height="20" /></a> databases
@@ -101,7 +100,7 @@ To use Chronos in your existing application, download and install the following
101
100
npm install chronos-tracker
102
101
```
103
102
104
-
### Configure Chronos for REST
103
+
### Configure Chronos for REST or gRPC
105
104
106
105
Similarly, in the **root directory** of _each of your microservice applications_, create a `chronos-config.js` file with properties listed below:
107
106
@@ -147,9 +146,10 @@ The `notifications` property is optional. Jump to the section below, [Notificati
147
146
Wherever you create an instance of your server (see example below),
148
147
149
148
```js
150
-
// Example
149
+
// Example for REST
151
150
constexpress=require('express');
152
151
constapp=express());
152
+
153
153
```
154
154
155
155
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.
You should be good to go! The last step, **Docker Configuration**, is **only applicable** if you need to configure <ahref="#"><imgsrc="./app/assets/docker-logo-color.png"alt="Docker"title="Docker"align="center"height="20" /></a> for your application.
168
+
168
169
<br>
169
170
171
+
170
172
### Initialize Chronos for gRPC
171
173
174
+
Wherever you create an instance of your server (see example below),
For any request you wish to trace, require uuidv4 and write the following code where the initial gRPC request begins,
240
+
```js
241
+
constrequire { v4:uuidv4} =require('uuid')
242
+
constcreateMeta= () => {
243
+
constmeta=newgrpc.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
+
returnres.sendStatus(404);
258
+
}
259
+
console.log('addOrder response: ', data);
260
+
returnres.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
+
172
272
### Docker Configuration
173
273
174
274
Again, this step is **only applicable** if you are currently using <ahref="#"><imgsrc="./app/assets/docker-logo-color.png"alt="Docker"title="Docker"align="center"height="20" /></a> containers for your microservices.
@@ -304,7 +404,7 @@ The **'gRPC'** branch is the current codebase for the <a href="#"><img src="./ap
0 commit comments