Skip to content
This repository has been archived by the owner on May 5, 2022. It is now read-only.

Added support for protocol option #52

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,15 @@ Alternatively, the hostname, port and service name (used by Zipkin to identify y
var appzip = require('appmetrics-zipkin')({
host: 'localhost',
port: 9411,
protocol: 'http',
serviceName:'frontend',
sampleRate: 1.0
});
```

**Note**: The properties file has precedence over the inline settings

If no configuration details are provided, the endpoint will be _localhost:9411_, the serviceName will be set to the program name that requires appmetrics-zipkin and the sample rate will be 1.0 (100% of requests).
If no configuration details are provided, the endpoint will be _http://localhost:9411_, the serviceName will be set to the program name that requires appmetrics-zipkin and the sample rate will be 1.0 (100% of requests).


## Usage
Expand Down
11 changes: 9 additions & 2 deletions appmetrics-zipkin.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,12 @@ module.exports = function(options) {

function start(options) {
// Set up the zipkin
var host, port, serviceName, sampleRate;
var host, port, protocol, serviceName, sampleRate;

if (options) {
host = options['host'];
port = options['port'];
protocol = options['protocol'];
serviceName = options['serviceName'];
sampleRate = options['sampleRate'];
}
Expand All @@ -70,6 +71,9 @@ function start(options) {
if (properties.get('port')) {
port = properties.get('port');
}
if (properties.get('protocol')) {
protocol = properties.get('protocol');
}
if (properties.get('serviceName')) {
serviceName = properties.get('serviceName');
}
Expand All @@ -87,6 +91,9 @@ function start(options) {
if (!port) {
port = 9411;
}
if (!protocol) {
protocol = 'http';
}
if (!sampleRate) {
sampleRate = 1.0;
}
Expand All @@ -102,7 +109,7 @@ function start(options) {
}
});

const zipkinUrl = `http://${host}:${port}`;
const zipkinUrl = `${protocol}://${host}:${port}`;
const recorder = new BatchRecorder({
logger: new HttpLogger({
endpoint: `${zipkinUrl}/api/v1/spans`
Expand Down
1 change: 1 addition & 0 deletions appmetrics-zipkin.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
host=
port=
protocol=
serviceName=
sampleRate=