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

Commit

Permalink
Exporter/jaeger: Enforce strictNullChecks and noUnusedLocals (#382)
Browse files Browse the repository at this point in the history
  • Loading branch information
mayurkale22 committed Mar 8, 2019
1 parent 9770bc9 commit 73f83a1
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 24 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ All notable changes to this project will be documented in this file.
- Enforce `--strictNullChecks` and `--noUnusedLocals` Compiler Options on [opencensus-exporter-instana] package.
- Add an API `globalStats.unregisterExporter()`.
- Add support for overriding sampling for a span.
- Enforce `--strictNullChecks` and `--noUnusedLocals` Compiler Options on [opencensus-exporter-jaeger] packages.

## 0.0.9 - 2019-02-12
- Add Metrics API.
Expand Down
34 changes: 29 additions & 5 deletions packages/opencensus-exporter-jaeger/README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,45 @@
# OpenCensus Jaeger Exporter for Node.js
# OpenCensus Jaeger Trace Exporter
[![Gitter chat][gitter-image]][gitter-url]

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

[Jaeger](https://jaeger.readthedocs.io/en/latest/), inspired by [Dapper](https://research.google.com/pubs/pub36356.html) and [OpenZipkin](http://zipkin.io/), is a distributed tracing system released as open source by [Uber Technologies](http://uber.github.io/). It is used for monitoring and troubleshooting microservices-based distributed systems, including:

- Distributed context propagation
- Distributed transaction monitoring
- Root cause analysis
- Service dependency analysis
- Performance / latency optimization

This project is still at an early stage of development. It's subject to change.

## Installation
## Quickstart

### Prerequisites

[Jaeger](https://jaeger.readthedocs.io/en/latest/) stores and queries traces exported by
applications instrumented with Census. The easiest way to [start a Jaeger
server](https://jaeger.readthedocs.io/en/latest/getting_started/) is to paste the below:

```bash
docker run -d \
-e COLLECTOR_ZIPKIN_HTTP_PORT=9411 \
-p5775:5775/udp -p6831:6831/udp -p6832:6832/udp \
-p5778:5778 -p16686:16686 -p14268:14268 -p9411:9411 \
jaegertracing/all-in-one:latest
```

### Installation

Install OpenCensus Jaeger Exporter with:
```bash
npm install @opencensus/nodejs
npm install @opencensus/exporter-jaeger
```

## Usage
### Usage

Instance the exporter on your application and pass the options, it must contain a service name and, optionaly, an URL. If no URL is passed, `http://localhost:9411/api/v2/spans` is used as default.
Install the exporter on your application and pass the options, it must contain a service name and, optionaly, an URL. If no URL is passed, `http://127.0.0.1:14268/api/traces` is used as default.

For ES6:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ export function spanToThrift(span: Span): ThriftSpan {
});
}

const unsigned = true;
const parentSpan: string|Buffer = span.parentSpanId ?
Utils.encodeInt64(span.parentSpanId) :
ThriftUtils.emptyBuffer;
Expand Down
13 changes: 7 additions & 6 deletions packages/opencensus-exporter-jaeger/src/jaeger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@
* limitations under the License.
*/

import {Exporter, ExporterBuffer, ExporterConfig, RootSpan, Span} from '@opencensus/core';
import {Exporter, ExporterConfig, RootSpan, Span} from '@opencensus/core';
import {logger, Logger} from '@opencensus/core';
import * as os from 'os';

import {spanToThrift, Tag, TagValue, ThriftProcess, ThriftUtils, UDPSender, Utils} from './jaeger-driver';

const DEFAULT_BUFFER_FLUSH_INTERVAL_MILLIS = 1000;
const DEFAULT_BUFFER_SIZE = 1000;

/**
* Options for Jaeger configuration
*/
Expand Down Expand Up @@ -53,17 +55,16 @@ export class JaegerTraceExporter implements Exporter {
/** Timeout control */
/** Max time for a buffer can wait before being sent */
private bufferTimeout: number;
/** Manage when the buffer timeout needs to be reseted */
private resetTimeout = false;
/** Indicates when the buffer timeout is running */
private timeoutSet = false;


constructor(options: JaegerTraceExporterOptions) {
const pjson = require('../../package.json');
this.logger = options.logger || logger.logger();
this.bufferTimeout = options.bufferTimeout;
this.bufferSize = options.bufferSize;
this.bufferTimeout =
options.bufferTimeout || DEFAULT_BUFFER_FLUSH_INTERVAL_MILLIS;
this.bufferSize = options.bufferSize || DEFAULT_BUFFER_SIZE;
this.sender = new UDPSender(options);
const tags: Tag[] = options.tags || [];

Expand Down
15 changes: 4 additions & 11 deletions packages/opencensus-exporter-jaeger/test/test-jaeger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,8 @@
* limitations under the License.
*/

import {CoreTracer, RootSpan, TracerConfig} from '@opencensus/core';
import {logger, Logger} from '@opencensus/core';
import {CoreTracer, logger} from '@opencensus/core';
import * as assert from 'assert';
import * as fs from 'fs';
import * as mocha from 'mocha';
import * as nock from 'nock';
import * as shimmer from 'shimmer';

import {JaegerTraceExporter, JaegerTraceExporterOptions} from '../src/';
import {spanToThrift, ThriftUtils, UDPSender} from '../src/jaeger-driver';

Expand All @@ -36,9 +30,7 @@ import {SenderCallback} from '../src/jaeger-driver';
* true to use a real zipkin service
* false to use a nock server
*/
const OPENCENSUS_NETWORK_TESTS =
['true', 'TRUE', '1'].indexOf(process.env.OPENCENSUS_NETWORK_TESTS) > -1;

const OPENCENSUS_NETWORK_TESTS = process.env.OPENCENSUS_NETWORK_TESTS;

describe('Jaeger Exporter', () => {
const testLogger = logger.logger('debug');
Expand Down Expand Up @@ -228,7 +220,8 @@ class MockedUDPSender extends UDPSender {

// Holds the initialized process information. Name matches the associated
// UDPSender property.
_process: ThriftProcess;
_process:
ThriftProcess = {serviceName: 'opencensus-exporter-jaeger', tags: []};

setProcess(process: ThriftProcess): void {
this._process = process;
Expand Down
3 changes: 2 additions & 1 deletion packages/opencensus-exporter-jaeger/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"pretty": true,
"module": "commonjs",
"target": "es6",
"strictNullChecks": false
"strictNullChecks": true,
"noUnusedLocals": true
},
"exclude": [
"node_modules"
Expand Down

0 comments on commit 73f83a1

Please sign in to comment.