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

Commit

Permalink
test: add new test cases for pluginloader and tracing classes
Browse files Browse the repository at this point in the history
  • Loading branch information
silva-fabio authored and kjin committed May 11, 2018
1 parent c098984 commit f32d3f7
Show file tree
Hide file tree
Showing 22 changed files with 1,340 additions and 525 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ TAGS

# nodejs
node_modules/
!packages/opencensus-nodejs/test/instrumentation/node_modules
npm-debug.log
.nyc_output/
build/
Expand Down
9 changes: 8 additions & 1 deletion packages/opencensus-nodejs/AUTHORS
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
Google Inc.
# This is the list of OpenCensus authors for copyright purposes.
#
# This does not necessarily list everyone who has contributed code, since in
# some cases, their employer may be the copyright holder. To see the full list
# of contributors, see the revision history in source control.

Google LLC
CESAR Team (www.cesar.org.br)
105 changes: 6 additions & 99 deletions packages/opencensus-nodejs/README.md
Original file line number Diff line number Diff line change
@@ -1,109 +1,16 @@
# OpenCensus Libraries for Node.js
# OpenCensus Core Node.js
[![Gitter chat][gitter-image]][gitter-url]

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.
OpenCensus for Node.js is an implementation of OpenCensus, a toolkit for collecting application performance and behavior monitoring data.

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

Please join [gitter](https://gitter.im/census-instrumentation/Lobby) for help or feedback on this project.

Note: This code was tested on the following Node versions:
- v6.10.0 (for console exporter only)
- v9.8.0 (for Stackdriver and Zipkin exporters)

___

## OpenCensus Setup

1. Clone the OpenCensus Node repository < https://github.com/census-instrumentation/opencensus-node.git>
```bash
git clone https://github.com/census-instrumentation/opencensus-node.git
```

**TODO Ver com Fábio se o usuário terá que compilar**

2. Switch to branch `dev` with:
```bash
git checkout dev
```

3. Navigate to the OpenCensus Node project folder and install the dependencies with:
```bash
cd opencensus-node
npm install
```

4. Compile the TypeScript code into JavaScript with:
```
node_modules/.bin/tsc
```

___

## Instrumenting an Application

Navigate to your application folder. Inside it's `node_modules` folder, create a directory named `@opencensus`:
```
cd node_modules
mkdir @opencensus
```

Navigate to your new `@opencensus` folder and create a symlink to OpenCensus Node package with:
```bash
cd @opencensus
ln -s <path-to-opencensus-dir>/packages/opencensus-nodejs/ opencensus-nodejs
```

### Using Stackdriver Exporter

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:
```bash
export GOOGLE_APPLICATION_CREDENTIALS=path/to/your/credential.json
```

Add the OpenCensus Stackdriver Exporter package to your project's `node_modules/@opencensus` folder with:
```
cd node_modules/@opencensus
ln -s <path-to-opencensus-dir>/packages/opencensus-exporter-stackdriver/ opencensus-exporter-stackdriver
```

Finally, on top of your application, add the following lines of code:
```javascript
var tracing = require('@opencensus/opencensus-nodejs');
var stackdriver = require('@opencensus/opencensus-exporter-stackdriver');

// Add your project id to the Stackdriver options
var options = new stackdriver.StackdriverOptions('your-project-id');
var exporter = new stackdriver.Stackdriver(options);

tracing.registerExporter(exporter).start();
```

### Using Zipkin Exporter

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:
```bash
wget -O zipkin.jar 'https://search.maven.org/remote_content?g=io.zipkin.java&a=zipkin-server&v=LATEST&c=exec'
java -jar zipkin.jar
```

Add the OpenCensus Zipkin Exporter package to your project's `node_modules/@opencensus` folder with:
```
cd node_modules/@opencensus
ln -s <path-to-opencensus-dir>/packages/opencensus-exporter-zipkin/ opencensus-exporter-zipkin
```

Finally, on top of your application, add the following lines of code:
```javascript
var tracing = require('@opencensus/opencensus-nodejs');
var zipkin = require('@opencensus/opencensus-exporter-zipkin');

// Add your zipkin url and application name to the Zipkin options
var options = new zipkin.ZipkinOptions("your-zipkin-url", "your-application-name")
var exporter = new zipkin.Zipkin(options);

tracing.registerExporter(exporter).start();
```
## Useful links
- For more information on OpenCensus, visit: <https://opencensus.io/>
- To checkout the OpenCensus for Node.js, visit: <https://github.com/census-instrumentation/opencensus-node>
- For help or feedback on this project, join us on [gitter](https://gitter.im/census-instrumentation/Lobby)

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

0 comments on commit f32d3f7

Please sign in to comment.