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

Upgrades internals to Zipkin v2 library #456

Merged
merged 1 commit into from
Jun 22, 2018
Merged

Upgrades internals to Zipkin v2 library #456

merged 1 commit into from
Jun 22, 2018

Conversation

codefromthecrypt
Copy link
Contributor

Which problem is this PR solving?

The current zipkin integration encourages use of a dead version of a library (io.zipkin.reporter)

Short description of the changes

Recent version of io.zipkin.zipkin2:zipkin has been backported to
support thrift encoding. This updates the corresponding sender here to
use that, notably to migrate off the io.zipkin.reporter libraries which
receive no updates.

@codecov
Copy link

codecov bot commented Jun 19, 2018

Codecov Report

Merging #456 into master will increase coverage by 0.01%.
The diff coverage is 71.42%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master     #456      +/-   ##
============================================
+ Coverage     88.29%   88.31%   +0.01%     
- Complexity      489      494       +5     
============================================
  Files            63       63              
  Lines          1846     1848       +2     
  Branches        240      241       +1     
============================================
+ Hits           1630     1632       +2     
  Misses          139      139              
  Partials         77       77
Impacted Files Coverage Δ Complexity Δ
.../java/io/jaegertracing/zipkin/V2SpanConverter.java 87.83% <100%> (+3.02%) 21 <1> (+1) ⬆️
...aegertracing/senders/zipkin/ThriftSpanEncoder.java 80% <100%> (+3.07%) 4 <3> (+2) ⬆️
.../io/jaegertracing/senders/zipkin/ZipkinSender.java 65.67% <50%> (-2.08%) 17 <3> (+2)

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 f5a1097...3cb58bc. Read the comment docs.

@codefromthecrypt
Copy link
Contributor Author

ps I plan to add a test for the v2 path, but only after figuring out the following:

  1. would this be mergable in general?
  2. since the version is <1.0 can we remove the old factory method now? If so, there will be less test work to do to achieve the same coverage.

@yurishkuro
Copy link
Member

+1 on (1)
no strong feeling on (2)

If people are running Zipkin collectors with v1 thrift model only (i.e. have not upgraded to collectors that accept v2 model), would the now-deprecated v1 factory still work for them?

@codefromthecrypt
Copy link
Contributor Author

codefromthecrypt commented Jun 19, 2018 via email

@codefromthecrypt
Copy link
Contributor Author

ok tests now use both paths.

I'm keen either way, retaining the deprecated factory method for a release, or cutting it now. If we do the former, we need to remember to remove it later.

@pavolloffay
Copy link
Member

As there is ZipkinV2Reporter (which can be used to sent thrift) can't we just deprecate the entire sender? Now we have to maintain two converters and sender only for thrift.

@codefromthecrypt
Copy link
Contributor Author

codefromthecrypt commented Jun 19, 2018 via email

@codefromthecrypt
Copy link
Contributor Author

codefromthecrypt commented Jun 19, 2018 via email

* sender = ZipkinSender.create(KafkaSender.create("192.168.99.100:9092"));
* sender = ZipkinSender.create(
* KafkaSender.newBuilder()
* .encoding(Encoding.THRIFT)
Copy link
Member

Choose a reason for hiding this comment

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

What happens if the encoding != thrift?

Copy link
Member

Choose a reason for hiding this comment

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

Cool there is a check. nevermind

@codefromthecrypt
Copy link
Contributor Author

@yurishkuro etc I think the least tech debt way here is to remove the deprecated factory method which then removes a large part of this code which will restore coverage to where it was. This also allows a smooth transition for those who can't immediately switch off thrift (for example)

if you say go, I'll do that and hopefully we can get this merged.

@yurishkuro
Copy link
Member

@adriancole I have no problem with removing the factory, my question was about functional impact. I haven't followed zipkin v2 too closely, was it a change to JSON schema only, or did thrift model changed as well? If the thrift model is the same (https://github.com/openzipkin/zipkin-api/blob/master/thrift/zipkinCore.thrift - this one?), then upgrading the library to send it makes total sense.

@codefromthecrypt
Copy link
Contributor Author

codefromthecrypt commented Jun 20, 2018 via email

@codefromthecrypt
Copy link
Contributor Author

ok ready to roll. I can squash or you can

@@ -122,14 +119,13 @@ private static void buildTags(Span span, zipkin2.Span.Builder builder) {
}
}

private static InetAddress convertIp(int ip) {
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 fixed this as it was bothering me

@@ -88,9 +89,6 @@ public void testAppendSpanTooLarge() throws Exception {

@Test
public void testAppend() throws Exception {
// find size of the initial span
AutoExpandingBufferWriteTransport memoryTransport =
Copy link
Contributor Author

Choose a reason for hiding this comment

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

unused

@@ -160,9 +175,14 @@ public int close() throws SenderException {
return n;
}

@Override
public String toString() {
return "ZipkinSender{" + delegate + "}";
Copy link
Contributor Author

Choose a reason for hiding this comment

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

previous toString looked bad as another field was forgotten to be excluded. this is a problem with auto-generated toStrings. This type is simple and this won't break even if you add new fields later.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Looks like this PR removes @ToString and implements its own toString(). Did you have problems with the resulting toString() from @ToString?

@codefromthecrypt
Copy link
Contributor Author

codefromthecrypt commented Jun 21, 2018 via email

@yurishkuro
Copy link
Member

I can squash or you can

Our (CNCF's) contributing policy requires signed commits (the DCO check), so it's best if you squash them and sign as a single commit (git commit -s ...)

@codefromthecrypt
Copy link
Contributor Author

codefromthecrypt commented Jun 21, 2018 via email

@codefromthecrypt
Copy link
Contributor Author

actually will push a slight test update as I used the wrong exception type on invalid format

@codefromthecrypt
Copy link
Contributor Author

hopefully I've now addressed the severely annoying test coverage requirements


compile group: 'io.zipkin.java', name: 'zipkin', version: '2.8.1'
compile group: 'io.zipkin.reporter2', name: 'zipkin-reporter', version: '2.6.0'
implementation 'io.zipkin.reporter2:zipkin-reporter'
Copy link
Member

Choose a reason for hiding this comment

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

shouldn't this be api scope?

compile group: 'io.zipkin.java', name: 'zipkin', version: '2.8.1'
compile group: 'io.zipkin.reporter2', name: 'zipkin-reporter', version: '2.6.0'
implementation 'io.zipkin.reporter2:zipkin-reporter'
implementation 'io.zipkin.reporter2:zipkin-sender-urlconnection'
Copy link
Member

Choose a reason for hiding this comment

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

This is new to me, it's related to https://github.com/jaegertracing/jaeger-client-java/pull/456/files#diff-88b7c47e47b8ee65263b6784b86fa0a7R1

I got this when I included it into a different project

[WARNING] The POM for io.jaegertracing:jaeger-zipkin:jar:0.29.1-SNAPSHOT is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details

https://docs.gradle.org/4.6/userguide/java_library_plugin.html#sec:java_library_separation

Dependencies appearing in the api configurations will be transitively exposed to consumers of the library, and as such will appear on the compile classpath of consumers. Dependencies found in the implementation configuration will, on the other hand, not be exposed to consumers, and therefore not leak into the consumers' compile classpath. This comes with several benefits:

We basically require our clients to explicitly add dependency on zipkin-sender-urlconnection to make this work. If am correct it will fail on java.lang.NoClassDefFoundError: zipkin2/reporter/urlconnection/URLConnectionSender even if you use different sender.

@codefromthecrypt
Copy link
Contributor Author

codefromthecrypt commented Jun 21, 2018 via email

@pavolloffay
Copy link
Member

+1, or just include the reporter and let users specify sender they want. But it's a bigger breaking change. I guess url sender does not pull in anything special so it's fine to include it.

@codefromthecrypt
Copy link
Contributor Author

hmm

> Could not find method api() for arguments [io.zipkin.reporter2:zipkin-reporter] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

@codefromthecrypt
Copy link
Contributor Author

looks like api can work if I upgrade to gradle 4.8, adding that..

@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.8-bin.zip
Copy link
Collaborator

Choose a reason for hiding this comment

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

It would be awesome if you could update the version specified under the Wrapper task as well: https://github.com/jaegertracing/jaeger-client-java/blob/master/build.gradle#L40

@@ -160,9 +175,14 @@ public int close() throws SenderException {
return n;
}

@Override
public String toString() {
return "ZipkinSender{" + delegate + "}";
Copy link
Collaborator

Choose a reason for hiding this comment

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

Looks like this PR removes @ToString and implements its own toString(). Did you have problems with the resulting toString() from @ToString?

@@ -52,7 +53,7 @@
Tracer tracer;

@Before
public void setUp() throws Exception {
Copy link
Collaborator

Choose a reason for hiding this comment

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

+1

@codefromthecrypt
Copy link
Contributor Author

codefromthecrypt commented Jun 21, 2018 via email

@jpkrohling
Copy link
Collaborator

Sorry, missed your previous comment about the toString(). I'm OK with that but would prefer to keep the @ToString for consistency's sake.

@codefromthecrypt
Copy link
Contributor Author

as thinga dont seem to be working like I hoped and I am spending more time than I should.. i will revert the bom thing amd repush the change. feel free to re-bom later.

@codefromthecrypt
Copy link
Contributor Author

I will also revert the lombok tostring thing as that tool deserves no more time from me!

@codefromthecrypt codefromthecrypt changed the title Upgrades internals to Zipkin v2 library deprecating v1 factory method Upgrades internals to Zipkin v2 library Jun 21, 2018
Recent version of io.zipkin.zipkin2:zipkin has been backported to
support thrift encoding. This updates the corresponding sender here to
use that, notably to migrate off the io.zipkin.reporter libraries which
receive no updates.

Signed-off-by: Adrian Cole <acole@pivotal.io>
@codefromthecrypt
Copy link
Contributor Author

unless there's more karmatic debt to pay in the form of build failures, I'm done I think.

Copy link
Member

@yurishkuro yurishkuro left a comment

Choose a reason for hiding this comment

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

lgtm

@pavolloffay @jpkrohling how does it look to you?

Copy link
Collaborator

@jpkrohling jpkrohling left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -48,41 +54,52 @@
* <p>
* See https://github.com/openzipkin/zipkin/tree/master/zipkin-server
*/
@ToString(exclude = "spanBuffer")
@ToString(exclude = {"spanBuffer", "encoder"})
Copy link
Collaborator

Choose a reason for hiding this comment

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

\o/

(not that I'm a fan of Lombok, btw)

Copy link
Member

@pavolloffay pavolloffay left a comment

Choose a reason for hiding this comment

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

thanks @adriancole

@pavolloffay pavolloffay merged commit eb91a3a into jaegertracing:master Jun 22, 2018
@codefromthecrypt
Copy link
Contributor Author

codefromthecrypt commented Jun 23, 2018 via email

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.

None yet

4 participants