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
Handle connection failures for Jersey and Resteasy #479
Conversation
44039f3
to
ec8b8dc
Compare
de5c70c
to
b34faac
Compare
Project instr_project = project | ||
subprojects { subProj -> | ||
if (subProj.getParent() == instr_project) { | ||
if (!skip.contains(name)) { |
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.
Could you please add a comment about that this is achieving?
From what I see currently is that you script connection-error-handling
subproject there - but it contains code so it is unclear how this actually gets included into the agent.
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.
Looks like this change is there to prevent the connection-error-handling
project itself from being added, but its two children, jersey and resteasy, will still be added. Some kind of comment or formalization of this "only add the leaf projects" would be nice.
Another problem is this change will cause the scala-testing
and akka-testing
projects to be added to the agent's jar.
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 can add a comment.
@realark I moved the source for scala and akka testing projects into the test folder, so those projects don't have any production source or dependencies.
public final class JerseyClientConnectionErrorInstrumentation extends Instrumenter.Default { | ||
|
||
public JerseyClientConnectionErrorInstrumentation() { | ||
super("jax-rs", "jaxrs", "jax-rs-client"); |
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.
You may want to consider adding a way to disable this part of the instrumentation without disable all of jax-rs
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 considered that, but I think it's not a good idea to have the client instrumentation enabled without this, which is why I didn't add it.
} | ||
|
||
public static class WrappedFuture<T> implements Future<T> { | ||
public static final String SPAN_PROPERTY_NAME = "datadog.trace.jaxrs.span"; // Copied elsewhere |
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.
It looks like you could add compile
(or compileOnly
) dependency on :dd-java-agent:instrumentation:jax-rs-client
into this project and avoid this copy-paste.
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.
👍
Project instr_project = project | ||
subprojects { subProj -> | ||
if (subProj.getParent() == instr_project) { | ||
if (!skip.contains(name)) { |
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.
Looks like this change is there to prevent the connection-error-handling
project itself from being added, but its two children, jersey and resteasy, will still be added. Some kind of comment or formalization of this "only add the leaf projects" would be nice.
Another problem is this change will cause the scala-testing
and akka-testing
projects to be added to the agent's jar.
} | ||
|
||
public static class WrappedFuture<T> implements Future<T> { | ||
public static final String SPAN_PROPERTY_NAME = "datadog.trace.jaxrs.span"; // Copied elsewhere |
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.
👍
public static void handleError( | ||
@Advice.FieldValue("configuration") final ClientConfiguration context, | ||
@Advice.Return(readOnly = false) Future future) { | ||
future = new WrappedFuture(future, context); |
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.
(Same CallDepthThreadLocalMap question)
public static void handleError( | ||
@Advice.FieldValue("requestContext") final ClientRequest context, | ||
@Advice.Return(readOnly = false) Future future) { | ||
future = new WrappedFuture(future, context); |
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.
Do we need to guard against nested calls with CallDepthThreadLocalMap?
CXF and other client frameworks will still lose the span and miss the error.
b34faac
to
6a03eb5
Compare
6a03eb5
to
de21c7b
Compare
Please review again. Everything has been addressed.
Shoot. Forgot to merge this before the release. |
CXF and other client frameworks will still lose the span and miss the error.
(See #437)