-
Notifications
You must be signed in to change notification settings - Fork 232
Reduce visibility of TextMapCodec.contextFromString to package scope #519
Changes from 6 commits
3ad52db
a1cb911
843c937
8847020
fa973ea
986986e
48112ed
900524b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,7 +27,6 @@ | |
import io.jaegertracing.internal.clock.Clock; | ||
import io.jaegertracing.internal.metrics.InMemoryMetricsFactory; | ||
import io.jaegertracing.internal.metrics.Metrics; | ||
import io.jaegertracing.internal.propagation.TextMapCodec; | ||
import io.jaegertracing.internal.reporters.InMemoryReporter; | ||
import io.jaegertracing.internal.samplers.ConstSampler; | ||
import io.jaegertracing.spi.BaggageRestrictionManager; | ||
|
@@ -200,7 +199,7 @@ public void testWithoutTimestampsInaccurateClock() { | |
.thenThrow(new IllegalStateException("currentTimeMicros() called 2nd time")); | ||
when(clock.currentNanoTicks()).thenReturn(20000L).thenReturn(30000L); | ||
|
||
JaegerSpan jaegerSpan = tracer.buildSpan("test-service-name").start(); | ||
JaegerSpan jaegerSpan = tracer.buildSpan("test-operation").start(); | ||
jaegerSpan.finish(); | ||
|
||
assertEquals(1, reporter.getSpans().size()); | ||
|
@@ -210,14 +209,11 @@ public void testWithoutTimestampsInaccurateClock() { | |
|
||
@Test | ||
public void testSpanToString() { | ||
JaegerSpan jaegerSpan = tracer.buildSpan("test-operation").start(); | ||
JaegerSpanContext expectedContext = jaegerSpan.context(); | ||
JaegerSpanContext actualContext = TextMapCodec.contextFromString(expectedContext.contextAsString()); | ||
|
||
assertEquals(expectedContext.getTraceId(), actualContext.getTraceId()); | ||
assertEquals(expectedContext.getSpanId(), actualContext.getSpanId()); | ||
assertEquals(expectedContext.getParentId(), actualContext.getParentId()); | ||
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. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. prod == prod. Please test for exact string. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You mean I should use a string literal instead of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Right. Will do. |
||
assertEquals(expectedString, span.toString()); | ||
span.finish(); | ||
} | ||
|
||
@Test | ||
|
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.
removing it is not equivalent. But you can change L215 to use TextMapCodec's extract method.
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 am not sure if this still applies. See testSpanToString in
TextMapCodec
.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.
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 testingspan.toString()
, onlyspanContext.contextAsString()
. So let's separate these.span.toString()
, we can simply compare with an exact literal string (including the operation name).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), butThere 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.
But what? :)
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.
sorry, a left over