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

Commit

Permalink
Add sampling path for tracer sampler config (#532) (#533)
Browse files Browse the repository at this point in the history
Signed-off-by: 飞雪无情 <[email protected]>
  • Loading branch information
flysnoworg authored Oct 18, 2021
1 parent 5a60f1e commit 3454cd6
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
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

0 comments on commit 3454cd6

Please sign in to comment.