Skip to content
This repository was archived by the owner on Oct 3, 2023. It is now read-only.

Commit 34a7744

Browse files
eduardoemerysilva-fabio
authored andcommitted
doc: added readme.md files
1 parent 1d0bafe commit 34a7744

2 files changed

Lines changed: 117 additions & 10 deletions

File tree

README.md

Lines changed: 101 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,109 @@
1-
# OpenCensus - A stats collection and distributed tracing framework
1+
# OpenCensus Libraries for Node.js
22
[![Gitter chat][gitter-image]][gitter-url]
33

4-
OpenCensus is a toolkit for collecting application performance and behavior data. It currently
5-
includes 3 apis: stats, tracing and tags.
4+
OpenCensus Node.js is an implementation of OpenCensus, a toolkit for collecting application performance and behavior monitoring data. Right now OpenCensus for Node.js supports custom tracing and automatic tracing for http and mongodb.
65

76
The library is in alpha stage and the API is subject to change.
87

9-
Please join [gitter](https://gitter.im/census-instrumentation/Lobby) for help or feedback on this
10-
project.
8+
Please join [gitter](https://gitter.im/census-instrumentation/Lobby) for help or feedback on this project.
9+
10+
Note: This code was tested on the following Node versions:
11+
- v6.10.0 (for console exporter only)
12+
- v9.8.0 (for Stackdriver and Zipkin exporters)
13+
14+
___
15+
16+
## OpenCensus Setup
17+
18+
1. Clone the OpenCensus Node repository < https://github.com/census-instrumentation/opencensus-node.git>
19+
```bash
20+
git clone https://github.com/census-instrumentation/opencensus-node.git
21+
```
22+
23+
**TODO Ver com Fábio se o usuário terá que compilar**
24+
25+
2. Switch to branch `dev` with:
26+
```bash
27+
git checkout dev
28+
```
29+
30+
3. Navigate to the OpenCensus Node project folder and install the dependencies with:
31+
```bash
32+
cd opencensus-node
33+
npm install
34+
```
35+
36+
4. Compile the TypeScript code into JavaScript with:
37+
```
38+
node_modules/.bin/tsc
39+
```
40+
41+
___
42+
43+
## Instrumenting an Application
44+
45+
Navigate to your application folder. Inside it's `node_modules` folder, create a directory named `@opencensus`:
46+
```
47+
cd node_modules
48+
mkdir @opencensus
49+
```
50+
51+
Navigate to your new `@opencensus` folder and create a symlink to OpenCensus Node package with:
52+
```bash
53+
cd @opencensus
54+
ln -s <path-to-opencensus-dir>/packages/opencensus-nodejs/ opencensus-nodejs
55+
```
56+
57+
### Using Stackdriver Exporter
58+
59+
To use Stackdriver as your exporter, make sure you have enabled [Stackdriver Tracing](https://cloud.google.com/trace/docs/quickstart) on Google Cloud Platform. Enable your [Application Default Credentials](https://cloud.google.com/docs/authentication/getting-started) for authentication with:
60+
```bash
61+
export GOOGLE_APPLICATION_CREDENTIALS=path/to/your/credential.json
62+
```
63+
64+
Add the OpenCensus Stackdriver Exporter package to your project's `node_modules/@opencensus` folder with:
65+
```
66+
cd node_modules/@opencensus
67+
ln -s <path-to-opencensus-dir>/packages/opencensus-exporter-stackdriver/ opencensus-exporter-stackdriver
68+
```
69+
70+
Finally, on top of your application, add the following lines of code:
71+
```javascript
72+
var tracing = require('@opencensus/opencensus-nodejs');
73+
var stackdriver = require('@opencensus/opencensus-exporter-stackdriver');
74+
75+
// Add your project id to the Stackdriver options
76+
var options = new stackdriver.StackdriverOptions('your-project-id');
77+
var exporter = new stackdriver.Stackdriver(options);
78+
79+
tracing.registerExporter(exporter).start();
80+
```
81+
82+
### Using Zipkin Exporter
83+
84+
To use Zipkin as your exporter, first, download from any of the three available options on [Quickstart](https://zipkin.io/pages/quickstart.html): through Docker, on Java or manually compiling the source code. Tests were executed running Zipkin with Java, through the following commands on terminal:
85+
```bash
86+
wget -O zipkin.jar 'https://search.maven.org/remote_content?g=io.zipkin.java&a=zipkin-server&v=LATEST&c=exec'
87+
java -jar zipkin.jar
88+
```
89+
90+
Add the OpenCensus Zipkin Exporter package to your project's `node_modules/@opencensus` folder with:
91+
```
92+
cd node_modules/@opencensus
93+
ln -s <path-to-opencensus-dir>/packages/opencensus-exporter-zipkin/ opencensus-exporter-zipkin
94+
```
95+
96+
Finally, on top of your application, add the following lines of code:
97+
```javascript
98+
var tracing = require('@opencensus/opencensus-nodejs');
99+
var zipkin = require('@opencensus/opencensus-exporter-zipkin');
100+
101+
// Add your zipkin url and application name to the Zipkin options
102+
var options = new zipkin.ZipkinOptions("your-zipkin-url", "your-application-name")
103+
var exporter = new zipkin.Zipkin(options);
104+
105+
tracing.registerExporter(exporter).start();
106+
```
11107

12108
[gitter-image]: https://badges.gitter.im/census-instrumentation/lobby.svg
13109
[gitter-url]: https://gitter.im/census-instrumentation/lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge

packages/opencensus-core/README.md

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,24 @@
1-
# OpenCensus - A stats collection and distributed tracing framework
1+
# OpenCensus Core Node.js
22
[![Gitter chat][gitter-image]][gitter-url]
33

4-
OpenCensus is a toolkit for collecting application performance and behavior data. It currently
5-
includes 3 apis: stats, tracing and tags.
4+
OpenCensus Node.js is an implementation of OpenCensus, a toolkit for collecting application performance and behavior monitoring data. Right now OpenCensus for Node.js supports custom tracing and automatic tracing for http and mongodb.
65

76
The library is in alpha stage and the API is subject to change.
87

9-
Please join [gitter](https://gitter.im/census-instrumentation/Lobby) for help or feedback on this
10-
project.
8+
OpenCensus Core allow exporters and plugins to be built on it. To instrument an application, please visit [OpenCensus Node.js](https://github.com/census-instrumentation/opencensus-node)
9+
10+
Please join [gitter](https://gitter.im/census-instrumentation/Lobby) for help or feedback on this project.
11+
12+
Note: This code was tested on the following Node versions:
13+
- v6.10.0 (for console exporter only)
14+
- v9.8.0 (for Stackdriver and Zipkin exporters)
15+
16+
17+
18+
## Useful links
19+
- For more information on OpenCensus, visit: <https://opencensus.io/>
20+
- To checkout the OpenCensus for Node.js, visit: <https://github.com/census-instrumentation/opencensus-node>
21+
- For help or feedback on this project, join us on [gitter](https://gitter.im/census-instrumentation/Lobby)
1122

1223
[gitter-image]: https://badges.gitter.im/census-instrumentation/lobby.svg
1324
[gitter-url]: https://gitter.im/census-instrumentation/lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge

0 commit comments

Comments
 (0)