-
Notifications
You must be signed in to change notification settings - Fork 231
Conversation
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()); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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"; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 Report
@@ 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
Continue to review full report at Codecov.
|
@@ -397,11 +398,6 @@ private String debugId() { | |||
} | |||
} | |||
|
|||
// TODO move this to jaeger-zipkin, this adds tracer tags to zipkin first span in a process |
There was a problem hiding this comment.
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)?
There was a problem hiding this comment.
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")) { |
There was a problem hiding this comment.
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()); |
There was a problem hiding this comment.
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()
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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")); |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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"; |
There was a problem hiding this comment.
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"; |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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{}
No description provided.