Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to Brave 5 #29

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft

Update to Brave 5 #29

wants to merge 1 commit into from

Conversation

devinsba
Copy link

I've started the process toward Brave 5, I need to fix a couple more things in the tests. I may need some guidance from @adriancole on the HTTP ones, I'm not entirely sure how to convert those to be more idiomatic so that they pass the tests. I put notes and @Ignore on all the tests that didn't pass so that I could work through all the modules. I don't intend for this to be merged before all the @Ignore's are removed

Copy link
Contributor

@codefromthecrypt codefromthecrypt left a comment

Choose a reason for hiding this comment

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

made some comments, not all of which need to be addressed immediately

@@ -222,7 +222,7 @@

private static final class HttpAdapter extends HttpClientAdapter<Request, HttpResponseStatus> {

@Override public boolean parseServerAddress(Request req, Endpoint.Builder builder) {
@Override public boolean parseServerIpAndPort(Request req, Endpoint.Builder builder) {
Copy link
Contributor

Choose a reason for hiding this comment

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

@@ -154,7 +154,7 @@ private ClientTracing() {}

private static final class HttpAdapter extends HttpClientAdapter<Request, HttpResponseStatus> {

@Override public boolean parseServerAddress(Request req, Endpoint.Builder builder) {
@Override public boolean parseServerIpAndPort(Request req, Endpoint.Builder builder) {
Copy link
Contributor

Choose a reason for hiding this comment

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

same comment

@@ -135,7 +137,7 @@ public void injectingFlagsShouldNotUnsetBuilderValues() {
SimpleB3ContextCarrier.Setter setter = new SimpleB3ContextCarrier.Setter();
setter.put(carrier, SimpleB3ContextCarrier.TRACE_ID_NAME, HexCodec.toLowerHex(1234));
setter.put(carrier, SimpleB3ContextCarrier.SPAN_ID_NAME, HexCodec.toLowerHex(9012));
setter.put(carrier, SimpleB3ContextCarrier.FLAGS_NAME, "0000000000000000");
setter.put(carrier, SimpleB3ContextCarrier.FLAGS_NAME, "0000000000000000"); // TODO 0 is not a valid hex anymore
Copy link
Contributor

Choose a reason for hiding this comment

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

is it zero is not valid? or an unnecessarily long string of zeros :)

Copy link
Author

Choose a reason for hiding this comment

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

The brave HexCodec class throws a NumberFormatException if you try to encode hex that ends up equaling 0

@@ -156,7 +159,7 @@ public void injectingZeroFlagsShouldNotSetValues() {
SimpleB3ContextCarrier.Setter setter = new SimpleB3ContextCarrier.Setter();
setter.put(carrier, SimpleB3ContextCarrier.TRACE_ID_NAME, HexCodec.toLowerHex(1234));
setter.put(carrier, SimpleB3ContextCarrier.SPAN_ID_NAME, HexCodec.toLowerHex(9012));
setter.put(carrier, SimpleB3ContextCarrier.FLAGS_NAME, "0000000000000000");
setter.put(carrier, SimpleB3ContextCarrier.FLAGS_NAME, "0000000000000000"); // TODO 0 is not a valid hex anymore
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto

@@ -124,6 +125,7 @@ public void builderShouldCopyFrom() {
assertThat(carrier2).isEqualTo(carrier);
}

@Ignore
@Test
public void injectingFlagsShouldNotUnsetBuilderValues() {
SimpleB3ContextCarrier carrier = SimpleB3ContextCarrier.newBuilder()
Copy link
Contributor

Choose a reason for hiding this comment

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

wonder if this type needs to still exist? (ok if it does for now, just curious)

@@ -57,7 +57,7 @@
<artifactId>brave</artifactId>
</dependency>
<dependency>
<groupId>io.zipkin.java</groupId>
<groupId>io.zipkin.zipkin2</groupId>
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think you'll need this dep except maybe in testing as we don't access endpoint directly anymore

@@ -74,11 +87,8 @@
TracedConsumerRecord<K, byte[]> tracedConsumerRecord = getTracedConsumerRecord(record);
TraceContextOrSamplingFlags traceContextOrSamplingFlags =
tracedConsumerRecord.traceContextOrSamplingFlags;
TraceContext ctx = traceContextOrSamplingFlags.context();
Copy link
Contributor

Choose a reason for hiding this comment

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

https://github.com/openzipkin/brave/blob/master/instrumentation/kafka-clients/src/main/java/brave/kafka/clients/KafkaTracing.java#L118

though this file itself possible is delete worthy, an aside to consider what needs to happen now vs later

@@ -44,7 +57,7 @@
if (envelope.hasParentId()) {
builder.parentId(envelope.getParentId().getValue());
}
TraceContextOrSamplingFlags traceContextOrSamplingFlags = TraceContextOrSamplingFlags.create(builder);
TraceContextOrSamplingFlags traceContextOrSamplingFlags = TraceContextOrSamplingFlags.create(builder.build());
Copy link
Contributor

Choose a reason for hiding this comment

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

make a single-message version of this eventually, if consumer interceptor are still needed.

https://github.com/openzipkin/brave/blob/master/instrumentation/kafka-clients/src/main/java/brave/kafka/clients/TracingConsumer.java#L60

@@ -46,7 +46,7 @@
<artifactId>brave</artifactId>
</dependency>
<dependency>
<groupId>io.zipkin.java</groupId>
<groupId>io.zipkin.zipkin2</groupId>
<artifactId>zipkin</artifactId>
<optional>true</optional>
Copy link
Contributor

Choose a reason for hiding this comment

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

same comment on scope.. try to remove these or set as test dep

Span oneWay = withEndpoint((ctx != null)
? tracing.tracer().joinSpan(ctx)
: tracing.tracer().newTrace(traceContextOrSamplingFlags.samplingFlags()));
Span oneWay;
Copy link
Contributor

Choose a reason for hiding this comment

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

one way isn't the better choice anymore. this pre-dated messaging model. not sure what's required to fix now vs later

@devinsba
Copy link
Author

I'm not sure I have the time to take this over the finish line right now. I ended up using an approach based around RequestHander2, influenced by this code, in our code base which I plan to open source as soon as I get a free hour but that is questionable unless I can find some time over the weekend

@codefromthecrypt
Copy link
Contributor

codefromthecrypt commented Mar 1, 2019 via email

@llinder
Copy link
Contributor

llinder commented Mar 5, 2019

Really appreciate the attempt to upgrade things. I will take a look through this ASAP and see where I can help out.

@YasinK-IW
Copy link

Would love to use this library once its all updated.

@YasinK-IW
Copy link

Any update on this?

@codefromthecrypt
Copy link
Contributor

@YasinK-IW do you have time to pick this up and address the comments?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants