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

Add Process IP to jaeger.thrift #197

Merged
merged 7 commits into from
Jun 19, 2017
Merged

Add Process IP to jaeger.thrift #197

merged 7 commits into from
Jun 19, 2017

Conversation

black-adder
Copy link
Contributor

No description provided.

this.version = loadVersion();

tags.put("jaeger.version", this.version);
String hostname = getHostName();
if (hostname != null) {
tags.put("jaeger.hostname", hostname);
}
int ipv4 = 0;
try {
tags.put("ip", InetAddress.getLocalHost().getHostAddress());
Copy link
Contributor

@vprithvi vprithvi Jun 19, 2017

Choose a reason for hiding this comment

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

Use a standard tag like PEER_HOST_IPV4

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, I'd recommend putting InetAddress.getLocalHost().getHostAddress() into a variable because the host address might change due to DHCP.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it's not a standard opentracing tag, I can add it to constants I guess with jaeger.version and jaeger.hostname

Copy link
Contributor Author

Choose a reason for hiding this comment

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

so keep it as a variable and only commit to the ip only when we report? We report once a second, is it really that bad if for 1 second we report the wrong ip?

Copy link
Member

Choose a reason for hiding this comment

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

We define tracer tags at initialization and never update them. If IP address changes, there's nothing we can do without refactoring. I don't think it's a big concerns.

/**
* The name used to report host name of the process.
*/
public static final String TRACER_HOSTNAME_TAG_KEY = "jaeger.hostname";
Copy link
Member

Choose a reason for hiding this comment

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

I think this should be just hostname. It needed to be jaeger.xxx when we were sending Zipkin format since it did not have the distinction between span and process tags.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Checked the backend zipkin to jaeger converter to make sure all is kosher, looks good. Making the change.

Copy link
Member

Choose a reason for hiding this comment

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

what we may want to do is when the tags are added to Zipkin spans, add a tracer. prefix to them

Copy link
Contributor Author

Choose a reason for hiding this comment

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

maybe a later PR? need to coordinate with a backend change

Copy link
Member

Choose a reason for hiding this comment

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

sure. Although I don't know why you need a backend change. The idea here is that when people use Jaeger backend, they should be using jaeger.thrift reporters (udp or http). Only when they use Zipkin backend they would use zipkin.thrift reporter, where we convert tracer tags into first-in-process span tags.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

nvm, I thought we were considering when the user uses zipkin reporter and the jaeger backend and we need to convert from zipkin to jaeger. I'll make the change.

rootTags.put("tracer.tag.num", 1);
rootTags.put("jaeger.version", SENTINEL);
rootTags.put("jaeger.hostname", SENTINEL);
rootTags.put("tracer.tag.str", SENTINEL);
Copy link
Member

Choose a reason for hiding this comment

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

Confused by this change. The SENTINEL comment says "sentinel value is used to mark tags that should not be present". So if you're setting tracer.tag.str, why would it not be present?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is for jaeger.thrift, these tags will only be present in process.tags or else we'll be double reporting the same tags in both process.tags and tags.

Copy link
Member

Choose a reason for hiding this comment

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

Well, I think this whole test was meant for zipkin.thrift, because it had the logic of only reporting the process tags in the first-in-process span. You're essentially changing everything to SENTINEL, meaning these tags are not going to be set on the span.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I already have similar tests for this in zipkin.thrift. I'd argue this test still provides some value to ensure tags aren't double reported in jaeger.thrift; but I'll update this test to provide some better value (ie check the process.tags actually exist)

@codecov-io
Copy link

codecov-io commented Jun 19, 2017

Codecov Report

Merging #197 into master will increase coverage by 0.02%.
The diff coverage is 85.71%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master     #197      +/-   ##
============================================
+ Coverage     81.31%   81.34%   +0.02%     
- Complexity      465      470       +5     
============================================
  Files            77       77              
  Lines          1804     1812       +8     
  Branches        211      214       +3     
============================================
+ Hits           1467     1474       +7     
  Misses          249      249              
- Partials         88       89       +1
Impacted Files Coverage Δ Complexity Δ
...-core/src/main/java/com/uber/jaeger/Constants.java 0% <ø> (ø) 0 <0> (ø) ⬇️
...ber/jaeger/senders/zipkin/ThriftSpanConverter.java 85.05% <100%> (+1.72%) 25 <1> (+6) ⬆️
...ger-core/src/main/java/com/uber/jaeger/Tracer.java 87.72% <72.72%> (-0.06%) 17 <1> (ø)
...jaeger/reporters/protocols/ThriftUdpTransport.java 77.96% <0%> (-5.09%) 14% <0%> (-2%)
...a/com/uber/jaeger/senders/zipkin/ZipkinSender.java 68.25% <0%> (+3.17%) 15% <0%> (+1%) ⬆️

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 4752c93...1b3829e. Read the comment docs.

@@ -397,11 +398,6 @@ private String debugId() {
}
}

// TODO move this to jaeger-zipkin, this adds tracer tags to zipkin first span in a process
Copy link
Member

Choose a reason for hiding this comment

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

Does this mean that tracer tags won't be added to Zipkin spans(root in a process)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's still added, but I've moved that logic into ZipkinSpanConverter as per the TODO

// add tracer tags to first zipkin span in a process but remove "ip" tag as it is
// taken care of separately.
for (String tagKey : span.getTracer().tags().keySet()) {
if (!tagKey.equals("ip")) {
Copy link
Member

Choose a reason for hiding this comment

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

nit TRACER_IP_TAG_KEY?

int ipv4 = 0;
try {
tags.put(Constants.TRACER_IP_TAG_KEY, InetAddress.getLocalHost().getHostAddress());
ipv4 = Utils.ipToInt(Inet4Address.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.

DRY: define local var for 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.

one is InetAddress and the other is Inet4Address

}
int ipv4 = 0;
Copy link
Member

Choose a reason for hiding this comment

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

remove default value since you're setting to 0 in catch

Map<String, ?> processTags = tracer.tags();
assertEquals(true, processTags.containsKey("jaeger.version"));
assertEquals(true, processTags.containsKey("hostname"));
assertEquals(true, processTags.containsKey("tracer.tag.str"));
Copy link
Member

Choose a reason for hiding this comment

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

This test still doesn't make sense to me. The reason it was parameterized was to ensure that tracer tags are converted into span tags when the span is first-in-process (2 out of 3 parameterized test cases). Since that logic has moved to Zipkin converter, this test should be moved there and operate only on the converted Zipkin span. The test that exists there is not as comprehensive as this one.

We may add a separate test here that tracer-level tags do not make it to Span tags, as well as that withTag method of the TracerBuilder works (which probably exists already elsewhere).

boolean firstSpanInProcess = span.getReferences().isEmpty() || isRpcServer(span);

Map<String, ?> processTags = span.getTracer().tags();
if (firstSpanInProcess && processTags != null) {
Copy link
Member

Choose a reason for hiding this comment

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

tracer tags are never null: `this.tags = Collections.unmodifiableMap(tags);

private static final String SENTINEL = "sentinel";

// NA value is used to mark tags that should be present but we don't care what it's value is
private static final String NA = "na";
Copy link
Member

Choose a reason for hiding this comment

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

s/NA/ANY

@@ -56,6 +64,105 @@ public void setUp() {
.build();
}

// sentinel value is used to mark tags that should *not* be present
private static final String SENTINEL = "sentinel";
Copy link
Member

Choose a reason for hiding this comment

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

maybe rename this to UNDEF, easier to understand/read

for (String key : expectedTags.keySet()) {
Object expectedValue = expectedTags.get(key);
BinaryAnnotation anno = findBinaryAnnotation(annotations, key);
if (expectedValue == SENTINEL) {
Copy link
Member

Choose a reason for hiding this comment

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

compare strings with equal()

assertTrue(serverReceiveFound);
assertTrue(serverSendFound);
}

@Test
public void testSpanKindClientCreatesAnnotations() {
Span span = (com.uber.jaeger.Span) tracer.buildSpan("operation-name").startManual();
Span parent = (com.uber.jaeger.Span) tracer.buildSpan("operation-name").startManual();
Copy link
Member

Choose a reason for hiding this comment

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

why does this test require a parent?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it doesn't remnant of previous change, removing

@@ -88,6 +90,20 @@
Map<String, Object> tags = span.getTags();
boolean isRpc = isRpc(span);
boolean isClient = isRpcClient(span);
boolean firstSpanInProcess = span.getReferences().isEmpty() || isRpcServer(span);

Map<String, ?> processTags = span.getTracer().tags();
Copy link
Member

Choose a reason for hiding this comment

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

scope this inside the if{}

@black-adder black-adder merged commit 74faa98 into master Jun 19, 2017
@black-adder black-adder deleted the set_process_ip branch June 19, 2017 22:15
@mabn mabn mentioned this pull request Jun 19, 2017
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.

5 participants