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

Add sampling path for tracer sampler config (#532) #533

Merged
merged 1 commit into from
Oct 18, 2021
Merged
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
5 changes: 4 additions & 1 deletion src/configuration.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ let jaegerSchema = {
hostPort: { type: 'string' },
host: { type: 'string' },
port: { type: 'number' },
samplingPath: { type: 'string' },
refreshIntervalMs: { type: 'number' },
},
required: ['type', 'param'],
Expand Down Expand Up @@ -76,6 +77,7 @@ export default class Configuration {
let hostPort = config.sampler.hostPort;
let host = config.sampler.host;
let port = config.sampler.port;
let samplingPath = config.sampler.samplingPath;
let refreshIntervalMs = config.sampler.refreshIntervalMs;

if (typeof param !== 'number') {
Expand All @@ -101,6 +103,7 @@ export default class Configuration {
hostPort: hostPort,
host: host,
port: port,
samplingPath: samplingPath,
refreshInterval: refreshIntervalMs,
metrics: options.metrics,
logger: options.logger,
Expand Down Expand Up @@ -138,7 +141,7 @@ export default class Configuration {
senderConfig['password'] = config.reporter.password;
}
if (config.reporter.timeoutMs) {
senderConfig[ 'timeoutMs' ] = config.reporter.timeoutMs;
senderConfig['timeoutMs'] = config.reporter.timeoutMs;
}
}
if (config.reporter.agentHost) {
Expand Down
9 changes: 9 additions & 0 deletions src/configuration_env.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,15 @@ export default class ConfigurationEnv {
samplerConfig.port = parseInt(value);
}

value = ConfigurationEnv._getConfigValue(
config.sampler,
'samplingPath',
process.env.JAEGER_SAMPLER_SAMPLING_PATH
);
if (value) {
samplerConfig.samplingPath = value;
}

value = ConfigurationEnv._getConfigValue(
config.sampler,
'refreshIntervalMs',
Expand Down
5 changes: 5 additions & 0 deletions test/init_tracer.js
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,7 @@ describe('initTracerFromENV', () => {
delete process.env.JAEGER_SAMPLER_HOST;
delete process.env.JAEGER_SAMPLER_PORT;
delete process.env.JAEGER_SAMPLER_MANAGER_HOST_PORT;
delete process.env.JAEGER_SAMPLER_SAMPLING_PATH;
delete process.env.JAEGER_SAMPLER_REFRESH_INTERVAL;
delete process.env.JAEGER_REPORTER_AGENT_PORT;
delete process.env.JAEGER_AGENT_PORT;
Expand Down Expand Up @@ -397,11 +398,13 @@ describe('initTracerFromENV', () => {

process.env.JAEGER_SAMPLER_TYPE = 'remote';
process.env.JAEGER_SAMPLER_MANAGER_HOST_PORT = 'localhost:8080';
process.env.JAEGER_SAMPLER_SAMPLING_PATH = '/api/sampling';
process.env.JAEGER_SAMPLER_REFRESH_INTERVAL = 100;
tracer = initTracerFromEnv();
expect(tracer._sampler).to.be.an.instanceof(RemoteSampler);
assert.equal(tracer._sampler._host, 'localhost');
assert.equal(tracer._sampler._port, 8080);
assert.equal(tracer._sampler._samplingPath, '/api/sampling');
assert.equal(tracer._sampler._refreshInterval, 100);
tracer.close();
});
Expand All @@ -419,11 +422,13 @@ describe('initTracerFromENV', () => {
process.env.JAEGER_SAMPLER_TYPE = 'remote';
process.env.JAEGER_SAMPLER_HOST = 'localhost';
process.env.JAEGER_SAMPLER_PORT = 8080;
process.env.JAEGER_SAMPLER_SAMPLING_PATH = '/api/sampling';
process.env.JAEGER_SAMPLER_REFRESH_INTERVAL = 100;
tracer = initTracerFromEnv();
expect(tracer._sampler).to.be.an.instanceof(RemoteSampler);
assert.equal(tracer._sampler._host, 'localhost');
assert.equal(tracer._sampler._port, 8080);
assert.equal(tracer._sampler._samplingPath, '/api/sampling');
assert.equal(tracer._sampler._refreshInterval, 100);
tracer.close();
});
Expand Down