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

Avoid host lookups if trace tags have already been provided #371

Merged
merged 1 commit into from Mar 18, 2018

Conversation

huntc
Copy link
Contributor

@huntc huntc commented Mar 17, 2018

Fixes jaegertracing/jaeger#742 (comment)

Marked as WIP as I've not yet tested it etc.

@codecov
Copy link

codecov bot commented Mar 17, 2018

Codecov Report

Merging #371 into master will increase coverage by 0.21%.
The diff coverage is 82.35%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master     #371      +/-   ##
============================================
+ Coverage      84.5%   84.72%   +0.21%     
- Complexity      619      624       +5     
============================================
  Files            95       95              
  Lines          2459     2468       +9     
  Branches        274      276       +2     
============================================
+ Hits           2078     2091      +13     
+ Misses          284      283       -1     
+ Partials         97       94       -3
Impacted Files Coverage Δ Complexity Δ
...ger-core/src/main/java/com/uber/jaeger/Tracer.java 87.14% <82.35%> (+0.48%) 23 <0> (+2) ⬆️
.../uber/jaeger/samplers/RemoteControlledSampler.java 85.85% <0%> (+1.01%) 20% <0%> (+1%) ⬆️
...jaeger/reporters/protocols/ThriftUdpTransport.java 86.44% <0%> (+5.08%) 16% <0%> (+2%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ee137d6...8f90229. Read the comment docs.

Copy link
Member

@yurishkuro yurishkuro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please make sure to sign commits: git commit -s, works with --amend on existing ones too

String hostname = getHostName();
if (hostname != null) {
tags.put(Constants.TRACER_HOSTNAME_TAG_KEY, hostname);
Object hostNameTag = tags.get(Constants.TRACER_HOSTNAME_TAG_KEY);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use if (tags.containsKey(Constants.TRACER_HOSTNAME_TAG_KEY)) to avoid leaking variable name to outer scope

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That’s me being consistent with the code below. I will modify to your tastes.

Object ipTag = tags.get(Constants.TRACER_IP_TAG_KEY);
if (ipTag == null) {
try {
tags.put(Constants.TRACER_IP_TAG_KEY, InetAddress.getLocalHost().getHostAddress());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can DRY InetAddress.getLocalHost().getHostAddress()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, where am I repeating myself?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry, nvm, the 2nd one is getting v4 address

@huntc huntc changed the title WIP - DO NOT MERGE - Avoid host lookups if trace tags have already been provided Avoid host lookups if trace tags have already been provided Mar 18, 2018
@huntc
Copy link
Contributor Author

huntc commented Mar 18, 2018

@yurishkuro PR updated, signed off and tests included.

Signed-off-by: Christopher Hunt <huntchr@gmail.com>
@huntc
Copy link
Contributor Author

huntc commented Mar 18, 2018

I don't know what you want to do with this - I'm still not hitting the test coverage, despite there being no test for the specific hostname resolution failing before. I don't know how to make that bit of code fail either. I'm pretty confident that the changes I've introduced are covered well with the tests.

TBH, for such a small PR, I've spent about 4 hours, so any further assistance would be appreciated.

@yurishkuro yurishkuro merged commit c86d689 into jaegertracing:master Mar 18, 2018
@yurishkuro
Copy link
Member

Thanks!

The test coverage changes is sometimes indeed confusing.

for such a small PR, I've spent about 4 hours

Do you feel this is due to the way this repo is setup, or some other reasons? Do you have suggestions on what we can improved?

@huntc huntc deleted the avoid-host-lookup branch March 18, 2018 18:31
@huntc
Copy link
Contributor Author

huntc commented Mar 18, 2018

Do you feel this is due to the way this repo is setup, or some other reasons? Do you have suggestions on what we can improved?

It was probably the test coverage thing mostly. But then, I’ve not been subject to Cobertura for some time so may be it is just me!

I’m left feeling positive that Jaegertracing has a strong focus on quality which certainly matches my experience of using it.

SEJeff added a commit to SEJeff/jaeger-client-python that referenced this pull request Apr 29, 2018
This matches the functionality of jaeger-client-java after
jaegertracing/jaeger-client-java#371 was merged.

Refs: jaegertracing#166
SEJeff added a commit to SEJeff/jaeger-client-python that referenced this pull request Apr 29, 2018
This matches the functionality of jaeger-client-java after
jaegertracing/jaeger-client-java#371 was merged.

Refs: jaegertracing#166

Signed-off-by: Jeff Schroeder <jeffschroeder@computer.org>
yurishkuro pushed a commit to jaegertracing/jaeger-client-python that referenced this pull request Apr 29, 2018
* Allow specifying the hostname via a tag

This is useful for applications running inside containers where the
hostname is autogenerated and generally useless. In kubernetes, the
downward api can be used to pass in the node name actually running
the container.

Fixes #66

Signed-off-by: Jeff Schroeder <jeffschroeder@computer.org>

* Catch the `socket.error` exception when trying to get the hostname

This is the base exception for all errors in the socket library. Explicit
is better than implicit!

Signed-off-by: Jeff Schroeder <jeffschroeder@computer.org>

* Don't attempt to lookup the ip address if specified via a tag

This matches the functionality of jaeger-client-java after
jaegertracing/jaeger-client-java#371 was merged.

Refs: #166

Signed-off-by: Jeff Schroeder <jeffschroeder@computer.org>

* Remove ipv4_to_int since jaeger converts tags to strings

Signed-off-by: Jeff Schroeder <jeffschroeder@computer.org>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants