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

Upgrading open-tracing and jaeger #5742

Merged
merged 5 commits into from
May 1, 2020
Merged

Upgrading open-tracing and jaeger #5742

merged 5 commits into from
May 1, 2020

Conversation

haverma
Copy link

@haverma haverma commented May 1, 2020

open-tracing upgraded from 0.30 to 0.33
open-tracing-jaxrs upgraded from 0.0.9 to 1.0.0
jaeger core upgraded from 0.21 to 1.2.0 (group ID also changed for this)

The way spans are created changed. ActiveSpan no longer exists, it is the same as any other span, and another class ScopeManager decides which span is active.
Now every span has to be closed by calling span.finish() in finally.

More details of usage can be found here

@batfish-bot
Copy link

This change is Reviewable

Copy link
Author

@haverma haverma left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 29 files reviewed, 1 unresolved discussion (waiting on @haverma)

a discussion (no related file):
Some things are failing, I am debugging that. Opened this to give an idea of the extent of changes


Copy link
Member

@dhalperi dhalperi left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 29 files at r1, 3 of 6 files at r2.
Reviewable status: 4 of 29 files reviewed, 5 unresolved discussions (waiting on @haverma)


projects/pom.xml, line 774 at r2 (raw file):

Quoted 17 lines of code…

        <groupId>io.jaegertracing</groupId>
        <artifactId>jaeger-core</artifactId>
        <version>${jaeger.version}</version>
        <exclusions>
          <exclusion>
            <groupId>commons-logging</groupId>
            <artifactId>commons-logging</artifactId>
          </exclusion>
        </exclusions>
      </dependency>

      <dependency>
        <groupId>io.jaegertracing</groupId>
        <artifactId>jaeger-thrift</artifactId>
        <version>${jaeger.version}</version>
      </dependency>

Please keep these sorted alphabetically (move to io section).


projects/allinone/pom.xml, line 136 at r2 (raw file):

      <groupId>io.jaegertracing</groupId>
      <artifactId>jaeger-core</artifactId>
    </dependency>

(move to io section throughout)


projects/allinone/src/main/java/org/batfish/allinone/AllInOne.java, line 152 at r2 (raw file):

.fromEnv().

why use the from environment variants if you are going to override the settings?


projects/batfish/src/main/java/org/batfish/bddreachability/BDDLoopDetectionAnalysis.java, line 62 at r2 (raw file):

    Span span = GlobalTracer.get().buildSpan("BDDLoopDetectionAnalysis.detectLoops").start();
    try (Scope scope = GlobalTracer.get().scopeManager().activate(span)) {

I don't quite understand this pattern. It sure looks the docs give a simpler way to do this:

Tracer.SpanBuilder.startActiveSpan(boolean finishOnClose) will create a new Span and will automatically set is as the active one for the current context.

import io.opentracing.Scope;

// Strongly encouraged to use them under try statements,
// to prevent ending up with the incorrect active Span
// in case of error.
try (Scope scope = tracer.buildSpan("foo").startActive(true)) {
    scope.span().setTag(...);
    scope.span().log(...);
}

  // The 'foo' Span is finished at this point.

from https://opentracing.io/guides/java/scopes/#scope-objects

@codecov
Copy link

codecov bot commented May 1, 2020

Codecov Report

Merging #5742 into master will increase coverage by 0.01%.
The diff coverage is 68.83%.

@@             Coverage Diff              @@
##             master    #5742      +/-   ##
============================================
+ Coverage     71.40%   71.42%   +0.01%     
+ Complexity    33677    33671       -6     
============================================
  Files          2788     2788              
  Lines        139590   139704     +114     
  Branches      16790    16794       +4     
============================================
+ Hits          99677    99786     +109     
+ Misses        32050    32042       -8     
- Partials       7863     7876      +13     
Impacted Files Coverage Δ Complexity Δ
...e/src/main/java/org/batfish/allinone/AllInOne.java 49.61% <0.00%> (-0.39%) 5.00 <0.00> (ø)
...or/src/main/java/org/batfish/coordinator/Main.java 57.34% <0.00%> (-0.28%) 29.00 <0.00> (ø)
...lient/src/main/java/org/batfish/client/Client.java 52.21% <36.84%> (+0.12%) 309.00 <2.00> (ø)
...batfish/src/main/java/org/batfish/main/Driver.java 48.90% <44.00%> (+0.32%) 29.00 <0.00> (ø)
...tfish/bddreachability/BDDReachabilityAnalysis.java 63.49% <56.25%> (-2.58%) 11.00 <0.00> (ø)
...src/main/java/org/batfish/coordinator/WorkMgr.java 70.52% <63.15%> (+0.17%) 281.00 <0.00> (ø)
...ava/org/batfish/topology/TopologyProviderImpl.java 78.65% <63.82%> (-0.99%) 30.00 <9.00> (ø)
...batfish/common/bdd/BDDFlowConstraintGenerator.java 96.15% <66.66%> (ø) 14.00 <0.00> (ø)
...atfish/src/main/java/org/batfish/main/Batfish.java 76.45% <71.30%> (+0.65%) 305.00 <14.00> (ø)
...g/batfish/dataplane/ibdp/IncrementalBdpEngine.java 91.08% <74.80%> (+0.31%) 84.00 <13.00> (ø)
... and 26 more

Copy link
Author

@haverma haverma left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 35 files reviewed, 4 unresolved discussions (waiting on @dhalperi and @haverma)

a discussion (no related file):

Previously, haverma (Harsh Verma) wrote…

Some things are failing, I am debugging that. Opened this to give an idea of the extent of changes

Nothing is failing now but opentracing-jaxrs2 (https://github.com/opentracing-contrib/java-jaxrs) is not logging the name of REST APIs in span db (instead I see serialize/deserialize in span names). Couldn't figure out the reason but may be it is not compatible with latest open-tracing APIs or it is not being initialized/setup correctly
Screen Shot 2020-05-01 at 4.07.52 AM.png

Here deserialize/serialize should ideally be the REST API's name, I can see the correct name in IDE but not in Jaeger UI.



projects/pom.xml, line 774 at r2 (raw file):

Previously, dhalperi (Dan Halperin) wrote…

        <groupId>io.jaegertracing</groupId>
        <artifactId>jaeger-core</artifactId>
        <version>${jaeger.version}</version>
        <exclusions>
          <exclusion>
            <groupId>commons-logging</groupId>
            <artifactId>commons-logging</artifactId>
          </exclusion>
        </exclusions>
      </dependency>

      <dependency>
        <groupId>io.jaegertracing</groupId>
        <artifactId>jaeger-thrift</artifactId>
        <version>${jaeger.version}</version>
      </dependency>

Please keep these sorted alphabetically (move to io section).

done


projects/allinone/pom.xml, line 136 at r2 (raw file):

Previously, dhalperi (Dan Halperin) wrote…
      <groupId>io.jaegertracing</groupId>
      <artifactId>jaeger-core</artifactId>
    </dependency>

(move to io section throughout)

moved (alphabetized by groupID)


projects/allinone/src/main/java/org/batfish/allinone/AllInOne.java, line 152 at r2 (raw file):

Previously, dhalperi (Dan Halperin) wrote…
.fromEnv().

why use the from environment variants if you are going to override the settings?

creating a new instance now


projects/batfish/src/main/java/org/batfish/bddreachability/BDDLoopDetectionAnalysis.java, line 62 at r2 (raw file):

Previously, dhalperi (Dan Halperin) wrote…
    Span span = GlobalTracer.get().buildSpan("BDDLoopDetectionAnalysis.detectLoops").start();
    try (Scope scope = GlobalTracer.get().scopeManager().activate(span)) {

I don't quite understand this pattern. It sure looks the docs give a simpler way to do this:

Tracer.SpanBuilder.startActiveSpan(boolean finishOnClose) will create a new Span and will automatically set is as the active one for the current context.

import io.opentracing.Scope;

// Strongly encouraged to use them under try statements,
// to prevent ending up with the incorrect active Span
// in case of error.
try (Scope scope = tracer.buildSpan("foo").startActive(true)) {
    scope.span().setTag(...);
    scope.span().log(...);
}

  // The 'foo' Span is finished at this point.

from https://opentracing.io/guides/java/scopes/#scope-objects

It seems that the linked doc is for JaegerTracer and not open-tracing's Tracer. Also in JaegerTracer, they have marked that API @deprecated - https://github.com/jaegertracing/jaeger-client-java/blob/a0080e065d4dbe805a9e02ed669759f042808023/jaeger-core/src/main/java/io/jaegertracing/internal/JaegerTracer.java#L486

open-tracing's Tracer (which we are using) - https://github.com/opentracing/opentracing-java/blob/master/opentracing-api/src/main/java/io/opentracing/Tracer.java doesn't have startActive. So activating a span may be a two step process (with no auto closable)

@haverma haverma marked this pull request as ready for review May 1, 2020 11:20
Copy link
Member

@dhalperi dhalperi left a comment

Choose a reason for hiding this comment

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

Reviewed 12 of 16 files at r3.
Reviewable status: 12 of 35 files reviewed, 3 unresolved discussions (waiting on @dhalperi and @haverma)


maven_install.json, line 4134 at r3 (raw file):

            },
            {
                "coord": "org.xerial:sqlite-jdbc:jar:sources:3.25.2",

Did you sort this file or something? This was not created simply by running @unpinned_maven//:pin, I think. At least my runs ~1 day ago did not rewrite the entire file.

Copy link
Member

@dhalperi dhalperi left a comment

Choose a reason for hiding this comment

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

Reviewable status: 12 of 35 files reviewed, 3 unresolved discussions (waiting on @haverma)


projects/batfish/src/main/java/org/batfish/bddreachability/BDDLoopDetectionAnalysis.java, line 62 at r2 (raw file):

Previously, haverma (Harsh Verma) wrote…

It seems that the linked doc is for JaegerTracer and not open-tracing's Tracer. Also in JaegerTracer, they have marked that API @deprecated - https://github.com/jaegertracing/jaeger-client-java/blob/a0080e065d4dbe805a9e02ed669759f042808023/jaeger-core/src/main/java/io/jaegertracing/internal/JaegerTracer.java#L486

open-tracing's Tracer (which we are using) - https://github.com/opentracing/opentracing-java/blob/master/opentracing-api/src/main/java/io/opentracing/Tracer.java doesn't have startActive. So activating a span may be a two step process (with no auto closable)

yep. wow, they have terrible documentation maintenance habits.

Copy link
Member

@dhalperi dhalperi left a comment

Choose a reason for hiding this comment

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

Reviewed 19 of 29 files at r1, 4 of 16 files at r3.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @haverma)

a discussion (no related file):

Previously, haverma (Harsh Verma) wrote…

Nothing is failing now but opentracing-jaxrs2 (https://github.com/opentracing-contrib/java-jaxrs) is not logging the name of REST APIs in span db (instead I see serialize/deserialize in span names). Couldn't figure out the reason but may be it is not compatible with latest open-tracing APIs or it is not being initialized/setup correctly
Screen Shot 2020-05-01 at 4.07.52 AM.png

Here deserialize/serialize should ideally be the REST API's name, I can see the correct name in IDE but not in Jaeger UI.

ok for now.


Copy link
Author

@haverma haverma left a comment

Choose a reason for hiding this comment

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

Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @dhalperi and @haverma)


maven_install.json, line 4134 at r3 (raw file):

Previously, dhalperi (Dan Halperin) wrote…

Did you sort this file or something? This was not created simply by running @unpinned_maven//:pin, I think. At least my runs ~1 day ago did not rewrite the entire file.

no, I also ran bazel run @unpinned_maven//:pin. I ran it again just now after reverting my changes, and it again produced the same file.

Copy link
Member

@dhalperi dhalperi left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 1 files at r4.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @haverma)

@haverma haverma merged commit 694c72c into master May 1, 2020
@haverma haverma deleted the upgrade-tracing branch May 1, 2020 17:28
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

3 participants