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

Handle connection failures for Jersey and Resteasy #479

Merged
merged 2 commits into from Sep 13, 2018

Conversation

tylerbenson
Copy link
Contributor

CXF and other client frameworks will still lose the span and miss the error.

(See #437)

Project instr_project = project
subprojects { subProj ->
if (subProj.getParent() == instr_project) {
if (!skip.contains(name)) {
Copy link
Contributor

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.

Copy link
Contributor

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.

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 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");
Copy link
Contributor

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

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 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
Copy link
Contributor

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.

Copy link
Contributor

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)) {
Copy link
Contributor

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
Copy link
Contributor

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);
Copy link
Contributor

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);
Copy link
Contributor

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.
@tylerbenson tylerbenson dismissed mar-kolya’s stale review September 12, 2018 00:34

Please review again. Everything has been addressed.

@tylerbenson
Copy link
Contributor Author

Shoot. Forgot to merge this before the release.

@tylerbenson tylerbenson modified the milestones: 0.15.0, 0.16.0 Sep 13, 2018
@tylerbenson tylerbenson merged commit c1ab826 into master Sep 13, 2018
@tylerbenson tylerbenson deleted the tyler/broken-jax-rs-client branch September 13, 2018 05: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.

None yet

3 participants