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

Commit 48a163f

Browse files
committed
Exporter/jaeger: Enforce strictNullChecks and noUnusedLocals
1 parent fa1ea7f commit 48a163f

File tree

6 files changed

+43
-24
lines changed

6 files changed

+43
-24
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ All notable changes to this project will be documented in this file.
1515
- Add support for recording HTTP stats.
1616
- Enforce `--strictNullChecks` and `--noUnusedLocals` Compiler Options on [opencensus-instrumentation-http], [opencensus-instrumentation-grpc] and [opencensus-propagation-tracecontext] packages.
1717
- Enforce `--strictNullChecks` and `--noUnusedLocals` Compiler Options on [opencensus-exporter-zipkin] packages.
18+
- Enforce `--strictNullChecks` and `--noUnusedLocals` Compiler Options on [opencensus-exporter-jaeger] packages.
1819

1920
## 0.0.9 - 2019-02-12
2021
- Add Metrics API.

packages/opencensus-exporter-jaeger/README.md

+29-5
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,45 @@
1-
# OpenCensus Jaeger Exporter for Node.js
1+
# OpenCensus Jaeger Trace Exporter
22
[![Gitter chat][gitter-image]][gitter-url]
33

4-
OpenCensus Jaeger Exporter allows the user to send collected traces with OpenCensus Node.js to Jaeger.
4+
OpenCensus Jaeger Trace Exporter allows the user to send collected traces with [OpenCensus Node.js](https://github.com/census-instrumentation/opencensus-node) to Jaeger.
5+
6+
[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:
7+
8+
- Distributed context propagation
9+
- Distributed transaction monitoring
10+
- Root cause analysis
11+
- Service dependency analysis
12+
- Performance / latency optimization
513

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

8-
## Installation
16+
## Quickstart
17+
18+
### Prerequisites
19+
20+
[Jaeger](https://jaeger.readthedocs.io/en/latest/) stores and queries traces exported by
21+
applications instrumented with Census. The easiest way to [start a Jaeger
22+
server](https://jaeger.readthedocs.io/en/latest/getting_started/) is to paste the below:
23+
24+
```bash
25+
docker run -d \
26+
-e COLLECTOR_ZIPKIN_HTTP_PORT=9411 \
27+
-p5775:5775/udp -p6831:6831/udp -p6832:6832/udp \
28+
-p5778:5778 -p16686:16686 -p14268:14268 -p9411:9411 \
29+
jaegertracing/all-in-one:latest
30+
```
31+
32+
### Installation
933

1034
Install OpenCensus Jaeger Exporter with:
1135
```bash
1236
npm install @opencensus/nodejs
1337
npm install @opencensus/exporter-jaeger
1438
```
1539

16-
## Usage
40+
### Usage
1741

18-
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.
42+
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.
1943

2044
For ES6:
2145

packages/opencensus-exporter-jaeger/src/jaeger-driver/index.ts

-1
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,6 @@ export function spanToThrift(span: Span): ThriftSpan {
127127
});
128128
}
129129

130-
const unsigned = true;
131130
const parentSpan: string|Buffer = span.parentSpanId ?
132131
Utils.encodeInt64(span.parentSpanId) :
133132
ThriftUtils.emptyBuffer;

packages/opencensus-exporter-jaeger/src/jaeger.ts

+7-6
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,14 @@
1414
* limitations under the License.
1515
*/
1616

17-
import {Exporter, ExporterBuffer, ExporterConfig, RootSpan, Span} from '@opencensus/core';
17+
import {Exporter, ExporterConfig, RootSpan, Span} from '@opencensus/core';
1818
import {logger, Logger} from '@opencensus/core';
1919
import * as os from 'os';
20-
2120
import {spanToThrift, Tag, TagValue, ThriftProcess, ThriftUtils, UDPSender, Utils} from './jaeger-driver';
2221

22+
const DEFAULT_BUFFER_FLUSH_INTERVAL_MILLIS = 1000;
23+
const DEFAULT_BUFFER_SIZE = 1000;
24+
2325
/**
2426
* Options for Jaeger configuration
2527
*/
@@ -53,17 +55,16 @@ export class JaegerTraceExporter implements Exporter {
5355
/** Timeout control */
5456
/** Max time for a buffer can wait before being sent */
5557
private bufferTimeout: number;
56-
/** Manage when the buffer timeout needs to be reseted */
57-
private resetTimeout = false;
5858
/** Indicates when the buffer timeout is running */
5959
private timeoutSet = false;
6060

6161

6262
constructor(options: JaegerTraceExporterOptions) {
6363
const pjson = require('../../package.json');
6464
this.logger = options.logger || logger.logger();
65-
this.bufferTimeout = options.bufferTimeout;
66-
this.bufferSize = options.bufferSize;
65+
this.bufferTimeout =
66+
options.bufferTimeout || DEFAULT_BUFFER_FLUSH_INTERVAL_MILLIS;
67+
this.bufferSize = options.bufferSize || DEFAULT_BUFFER_SIZE;
6768
this.sender = new UDPSender(options);
6869
const tags: Tag[] = options.tags || [];
6970

packages/opencensus-exporter-jaeger/test/test-jaeger.ts

+4-11
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,8 @@
1414
* limitations under the License.
1515
*/
1616

17-
import {CoreTracer, RootSpan, TracerConfig} from '@opencensus/core';
18-
import {logger, Logger} from '@opencensus/core';
17+
import {CoreTracer, logger} from '@opencensus/core';
1918
import * as assert from 'assert';
20-
import * as fs from 'fs';
21-
import * as mocha from 'mocha';
22-
import * as nock from 'nock';
23-
import * as shimmer from 'shimmer';
24-
2519
import {JaegerTraceExporter, JaegerTraceExporterOptions} from '../src/';
2620
import {spanToThrift, ThriftUtils, UDPSender} from '../src/jaeger-driver';
2721

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

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

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

233226
setProcess(process: ThriftProcess): void {
234227
this._process = process;

packages/opencensus-exporter-jaeger/tsconfig.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
"pretty": true,
77
"module": "commonjs",
88
"target": "es6",
9-
"strictNullChecks": false
9+
"strictNullChecks": true,
10+
"noUnusedLocals": true
1011
},
1112
"exclude": [
1213
"node_modules"

0 commit comments

Comments
 (0)