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

Support opentracing-api 0.32 and 0.33 #93

Merged
merged 7 commits into from
Jun 25, 2019
Merged

Conversation

codefromthecrypt
Copy link
Contributor

@codefromthecrypt codefromthecrypt commented Apr 2, 2019

This updates to opentracing 0.32 and 0.33

Here are the following notes:

  • 0.31 and 0.32 cannot be supported at the same time.
    • This is due to overloading of setTag and withTag with the type Tag which doesn't exist in 0.31. creating an unresolvable compile conflict.
  • 0.32 and 0.33 are supported, with conditional code execution to avoid the flawed deprecated logic from 0.31 still present in 0.32.
  • binary formats are non-baggage carrying at the moment, using b3 single the same as brave's normal JMS does.

Fixes #91

@codefromthecrypt
Copy link
Contributor Author

codefromthecrypt commented Apr 2, 2019 via email

@felixbarny
Copy link

AFAICT, It's meant to be only string, number and boolean. But you are right, nothing stops anyone from creating a ExceptionTag implements Tag<Exception> which extracts the stack trace and sets it as a string tag, for example. I have not seen that in the wild though. I'd suggest relying on an instance of check and assume there can only be Strings, Numbers and Boolean tag values until there is a Tag#set(SpanBuilder sb, T value) method.

@codefromthecrypt
Copy link
Contributor Author

Ok I will change this to throw IllegalArgumentException (also should be defined on the Tag javadoc) when the input is neither string, number, boolean. Thanks @felixbarny

@tylerbenson
Copy link

@felixbarny you beat me to it... This was going to be my suggestion. 😉

@codefromthecrypt
Copy link
Contributor Author

I will pick this up again tomorrow and cut a release that works ideally up to 0.33 as it will be hard to find a precise version everyone will use uniformly. The general idea is to use the approach of not adding @Override on new methods

@codefromthecrypt
Copy link
Contributor Author

knackered due to all the re-releasing.. openzipkin/zipkin#2629 will try this again tomorrow.

@codefromthecrypt
Copy link
Contributor Author

codefromthecrypt commented Jun 25, 2019

ps it is impossible to make a version that works both with 0.31 and 0.32 due to overloading

  @Override public BraveSpanBuilder withTag(String key, Number value) {
    if (Tags.PEER_PORT.getKey().equals(key)) {
      remotePort = value.intValue();
      return this;
    }
    return withTag(key, value.toString());
  }

  /* @Override 0.32 method: Intentionally no override to ensure 0.31 works! */
  public <T> BraveSpanBuilder withTag(io.opentracing.tag.Tag<T> tag, T value) {
    if (tag == null) throw new NullPointerException("tag == null");
    if (value == null) throw new NullPointerException("value == null");
    if (value instanceof String) return withTag(tag.getKey(), (String) value);
    if (value instanceof Number) return withTag(tag.getKey(), (Number) value);
    if (value instanceof Boolean) return withTag(tag.getKey(), (Boolean) value);
    throw new IllegalArgumentException("tag value not a string, number or boolean: " + tag);
  }

this would only work if it was a different method name.. because they OT the same method name for this useless addition, it is impossible to compile against both 0.32 and 0.31. You end up with class file for io.opentracing.tag.Tag not found.

[INFO] org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project opentracing-0.31: Compilation failure
[INFO] /Users/acole/oss/brave-opentracing/src/test/java/brave/opentracing/BraveTracerTest.java:[63,9] cannot access io.opentracing.tag.Tag
[INFO]   class file for io.opentracing.tag.Tag not found
[INFO] 
[INFO]     at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)

This is something we learned a long time ago in brave, as we made a similar mistake. openzipkin/brave#598

Adrian Cole added 2 commits June 25, 2019 16:55
It is very likely people will misconfigure their classpaths as there are
compatibility issues between versions of opentracing. This raises the
following message to tell people one way to resolve it.

> OpenTracing 0.31 detected. This version is compatible with io.opentracing:opentracing-api 0.32 or 0.33. Use latest io.opentracing.brave:brave-opentracing:0.33 or update you opentracing-api
@codefromthecrypt
Copy link
Contributor Author

Added error when opentracing 0.31 is present. cc @trustin @marcingrzejszczak

OpenTracing 0.31 detected. This version is compatible with io.opentracing:opentracing-api 0.32 or 0.33. Use latest io.opentracing.brave:brave-opentracing:0.33 or update you opentracing-api

@codefromthecrypt codefromthecrypt changed the title WIP opentracing 0.32 Support opentracing-api 0.32 and 0.33 Jun 25, 2019
@codefromthecrypt
Copy link
Contributor Author

Added notes about this

@codefromthecrypt codefromthecrypt merged commit 67cdd68 into master Jun 25, 2019
@codefromthecrypt codefromthecrypt deleted the opentracing-0.32 branch June 25, 2019 13:19
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.

Fix opentracing 0.32.0
3 participants