Reduce visibility of TextMapCodec.contextFromString to package scope#519
Conversation
Signed-off-by: Isaac Hier <ihier@uber.com>
| assertEquals(traceId, contextFromStr.getTraceId()); | ||
| assertEquals(spanId, contextFromStr.getSpanId()); | ||
| assertEquals(parentId, contextFromStr.getParentId()); | ||
| assertEquals(flags, contextFromStr.getFlags()); |
There was a problem hiding this comment.
don't see how removing this makes the test equivalent. But this whole test can move to text codec test, since it's not really testing the context toString
There was a problem hiding this comment.
Right let me fix that.
| assertEquals(expectedContext.getTraceId(), actualContext.getTraceId()); | ||
| assertEquals(expectedContext.getSpanId(), actualContext.getSpanId()); | ||
| assertEquals(expectedContext.getParentId(), actualContext.getParentId()); | ||
| assertEquals(expectedContext.getFlags(), actualContext.getFlags()); |
There was a problem hiding this comment.
removing it is not equivalent. But you can change L215 to use TextMapCodec's extract method.
There was a problem hiding this comment.
I am not sure if this still applies. See testSpanToString in TextMapCodec.
There was a problem hiding this comment.
Here's what I am thinking. The method is called testSpanToString. Such method should belong in SpanTest class, not the codecs. But it's not actually testing span.toString(), only spanContext.contextAsString(). So let's separate these.
- to test
span.toString(), we can simply compare with an exact literal string (including the operation name). - what is the contract of
contextAsString()? Do we, strictly speaking, care if the output matches the output of the codec? What if we use a different codec in the future? I think it mattered more when span context had the oppositefromString()method, but nowcontextAsString()seems merely a dependency ofspan.toString(), nothing more. Or is it used elsewhere? If not, we can not test it at all (since it's covered byspan.toString()test), and we can consider making it package viz.
Counter-proposal: keep the test here (since it's testing Span's behavior, not the codec), but
Codecov Report
@@ Coverage Diff @@
## master #519 +/- ##
===========================================
+ Coverage 88.26% 88.37% +0.1%
Complexity 500 500
===========================================
Files 65 65
Lines 1849 1849
Branches 239 239
===========================================
+ Hits 1632 1634 +2
+ Misses 141 138 -3
- Partials 76 77 +1
Continue to review full report at Codecov.
|
Signed-off-by: Isaac Hier <ihier@uber.com>
| byte flags = (byte) 129; | ||
|
|
||
| // I use MIN_VALUE because the most significant bit, and thats when | ||
| // we want to make sure the hex number is positive. |
There was a problem hiding this comment.
this comment looks like some old left-over. Doesn't seem to make any sense now.
Signed-off-by: Isaac Hier <ihier@uber.com>
Signed-off-by: Isaac Hier <ihier@uber.com>
Signed-off-by: Isaac Hier <ihier@uber.com>
| @Override | ||
| public void inject(JaegerSpanContext spanContext, TextMap carrier) { | ||
| carrier.put(contextKey, encodedValue(spanContext.contextAsString())); | ||
| carrier.put(contextKey, encodedValue(spanContext.toString())); |
There was a problem hiding this comment.
I don't think it's a good idea to rely on toString() for marshaling purposes.
Maybe do the same thing as with fromString, move contextAsString() from SpanContext to TextMapCodec, but keep it public so that SpanContext.toString() can call it.
Signed-off-by: Isaac Hier <ihier@uber.com>
| assertEquals(expectedContext.getFlags(), actualContext.getFlags()); | ||
| String operation = "test-operation"; | ||
| JaegerSpan span = tracer.buildSpan(operation).start(); | ||
| String expectedString = span.context().toString() + " - " + operation; |
There was a problem hiding this comment.
prod == prod. Please test for exact string.
There was a problem hiding this comment.
You mean I should use a string literal instead of expectedString? Not sure what the suggestion is.
There was a problem hiding this comment.
yes, expectedString = "some literal value". Otherwise you are just comparing outputs of two prod functions. If we change the representation used by the codec, technically this test should fail since span.toString() would change.
Signed-off-by: Isaac Hier <ihier@uber.com>
Signed-off-by: Isaac Hier <ihier@uber.com>
Which problem is this PR solving?
Short description of the changes