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

Commit 13cab60

Browse files
eduardoemerykjin
authored andcommitted
feat: add a default zipkin url (#111)
1 parent 5d42114 commit 13cab60

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

packages/opencensus-exporter-zipkin/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ wget -O zipkin.jar 'https://search.maven.org/remote_content?g=io.zipkin.java&a=z
2222
java -jar zipkin.jar
2323
```
2424

25-
Instance the exporter on your application and pass the options. For javascript:
25+
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.
26+
27+
For javascript:
2628

2729
```javascript
2830
var tracing = require('@opencensus/nodejs');

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import * as http from 'http';
2121
import * as url from 'url';
2222

2323
export interface ZipkinExporterOptions extends ExporterConfig {
24-
url: string;
24+
url?: string;
2525
serviceName: string;
2626
}
2727

@@ -40,13 +40,15 @@ interface TranslatedSpan {
4040

4141
/** Zipkin Exporter manager class */
4242
export class ZipkinTraceExporter implements Exporter {
43+
static readonly DEFAULT_URL = 'http://localhost:9411/api/v2/spans';
4344
private zipkinUrl: url.UrlWithStringQuery;
4445
private serviceName: string;
4546
buffer: ExporterBuffer;
4647
logger: Logger;
4748

4849
constructor(options: ZipkinExporterOptions) {
49-
this.zipkinUrl = url.parse(options.url);
50+
this.zipkinUrl = options.url && url.parse(options.url) ||
51+
url.parse(ZipkinTraceExporter.DEFAULT_URL);
5052
this.serviceName = options.serviceName;
5153
this.buffer = new ExporterBuffer(this, options);
5254
this.logger = options.logger || logger.logger();

0 commit comments

Comments
 (0)