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

Commit

Permalink
exporter/prometheus/README: should be a Stats exporter, not Tracing. (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
mayurkale22 committed Nov 28, 2018
1 parent 5fe3b38 commit bf85a7b
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 21 deletions.
64 changes: 44 additions & 20 deletions packages/opencensus-exporter-prometheus/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# OpenCensus Prometheus Exporter for Node.js
[![Gitter chat][gitter-image]][gitter-url]
[![Gitter chat][gitter-image]][gitter-url] ![Node Version][node-img] [![NPM Published Version][npm-img]][npm-url]

The OpenCensus Prometheus Exporter allows the user to send collected stats with [OpenCensus Node.js](https://github.com/census-instrumentation/opencensus-node) to Prometheus.

Expand All @@ -9,43 +9,60 @@ This package is still at an early stage of development, and is subject to change

Install OpenCensus Prometheus Exporter with:
```bash
npm install @opencensus/nodejs
npm install @opencensus/core
npm install @opencensus/exporter-prometheus
```

## Usage

Instance the exporter on your application. For javascript:
Instance the exporter on your application.

For javascript:
```javascript
var tracing = require('@opencensus/nodejs');
var prometheus = require('@opencensus/exporter-prometheus');
const { Stats } = require('@opencensus/core');
const { PrometheusStatsExporter } = require('@opencensus/exporter-prometheus');

// Add your port and startServer to the Prometheus options
const exporter = new PrometheusStatsExporter({
port: 9464,
startServer: false
});
```

var exporter = new prometheus.PrometheusTraceExporter();
Now, register the exporter.

tracing.registerExporter(exporter).start();
```
```javascript
// Our Stats manager
const stats = new Stats();

Similarly for Typescript:
// Pass the created exporter to Stats
stats.registerExporter(exporter);

// Run the server
exporter.startServer(function callback() {
// Callback
});
```

Similarly for Typescript (Since the source is written in TypeScript):
```typescript
import * as tracing from '@opencensus/nodejs';
import { PrometheusTraceExporter } from '@opencensus/exporter-prometheus';
import { PrometheusStatsExporter } from '@opencensus/exporter-prometheus';
import { Stats } from '@opencensus/core';

const exporter = new PrometheusTraceExporter();
```
// Add your port and startServer to the Prometheus options
const options = {port: 9464, startServer: false};
const exporter = new PrometheusStatsExporter(options);

Now, register the exporter and start tracing.
// Our Stats manager
const stats = new Stats();

```javascript
tracing.start({'exporter': exporter});
// Pass the created exporter to Stats
stats.registerExporter(exporter);
```

or
Viewing your metrics:

```javascript
tracing.registerExporter(exporter).start();
```
With the above you should now be able to navigate to the Prometheus UI at: <http://localhost:9464/metrics>

## Useful links
- To learn more about Prometheus, visit: <https://prometheus.io/>
Expand All @@ -55,3 +72,10 @@ tracing.registerExporter(exporter).start();

[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
[npm-url]: https://www.npmjs.com/package/@opencensus/exporter-prometheus
[npm-img]: https://badge.fury.io/js/%40opencensus%2Fexporter-prometheus.svg
[node-img]: https://img.shields.io/node/v/@opencensus/exporter-prometheus.svg

## LICENSE

Apache License 2.0
3 changes: 2 additions & 1 deletion packages/opencensus-exporter-prometheus/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
"keywords": [
"opencensus",
"nodejs",
"tracing",
"metrics",
"stats",
"profiling"
],
"author": "Google Inc.",
Expand Down

0 comments on commit bf85a7b

Please sign in to comment.