-
Notifications
You must be signed in to change notification settings - Fork 834
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Jaeger-Exporter] host default env var #924
Conversation
Codecov Report
@@ Coverage Diff @@
## master #924 +/- ##
===========================================
+ Coverage 77.73% 94.93% +17.19%
===========================================
Files 74 248 +174
Lines 1752 11198 +9446
Branches 300 1070 +770
===========================================
+ Hits 1362 10631 +9269
- Misses 390 567 +177
|
Please add a test that verifies the env var usage |
@dyladan How can this be achieved? |
6f01a16
to
40ac3f3
Compare
In the start of the test, set the variable |
I've never been able to achieve setting an env var for a single test. Is there any online examples of this? |
Also if both |
You just assign it like any other variable: describe('suite', () => {
// clean up for other tests
afterEach(() => {
delete process.env.JAEGER_AGENT_HOST;
}));
it('should respect jaeger host env variable', () => {
process.env.JAEGER_AGENT_HOST = 'env-var';
const exporter = new JaegerExporter({
serviceName: 'test-service',
});
// assert host is env-var
});
it('should prioritize host option over env variable', () => {
process.env.JAEGER_AGENT_HOST = 'env-var';
const exporter = new JaegerExporter({
serviceName: 'test-service',
host: 'explicit-host'
});
// assert host is explicit-host
});
}); |
40ac3f3
to
3decd1e
Compare
Amazing, not the first time I wanted this. I'm surprised I could not find any online docs for this. |
Wouldn't we want the env var to be authoritative? Am I wrong to say that it is generally easier to configure an env var on the fly rather than change the code? |
Yes the ENV var is much easier to change, but if someone goes to the trouble of putting something in code you can be pretty sure they meant to do that. We could log if they are both set or something if you want to be extra careful. |
Fair enough. Will skip logging at this time but will add a note about authority in README. |
… defined It still falls back to localhost, but if the env var is set, it will use that as the host to send spans to. This prevents end users from writing extra code when the jaeger agent is remote. Signed-off-by: Naseem <naseem@transit.app>
3decd1e
to
ac3f2dd
Compare
note: I was unable to add a test as this depends on an env var. runningJAEGER_AGENT_HOST=foo npm run test
showed me that it works though by failing the host checking tests hereby added.Which problem is this PR solving?
Short description of the changes
JAEGER_AGENT_HOST
in their app and the exporter will pick it up and use it as a value for host. settinghost
in the exporter config would trump this. Let me know if you would like the env var to take precedence.