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

Add instrumentation for Armeria WebClient. #920

Merged

Conversation

anuraaga
Copy link
Contributor

@anuraaga anuraaga commented Aug 7, 2020

Also updates the server to suppress user-provided decorator when auto instrumenting.

Went ahead and followed the pattern of GrpcTest by just testing server / client in the same test since it was simple. May extract as I add more sophisticated tests in a future PR (Armeria custom context storage class is coming!)

}

@Advice.OnMethodExit
public static void handleSuppression(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This craziness is the only pattern I could find for suppressing a non-void method

Copy link
Contributor

Choose a reason for hiding this comment

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

Please add some documentation about what you are trying to achieve here


abstract void configureServer(ServerBuilder sb)
abstract ServerBuilder configureServer(ServerBuilder serverBuilder)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Returning ServerBuilder here allows checking my suppression didn't return null

@anuraaga anuraaga force-pushed the armeria-client-instrumentation branch from 4a7a083 to 5d6478f Compare August 7, 2020 08:43
.getClass()
.getName()
.equals(
"io.opentelemetry.instrumentation.armeria.v1_0.server.OpenTelemetryService$Decorator");
Copy link
Member

Choose a reason for hiding this comment

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

i think #892 will break this because it will shade this constant also. there are ways to prevent the string from getting shaded (e.g. make it a constant NAME = "_io.opentelemetry...".substring(1)".

another option for suppressing library instrumentation that might be easier to generalize, is to make the coordination more explicit, e.g. have a method in instrumentation-api like isAutoEnabled(instrumentationName), and the library instrumentation can explicitly check that to see if there is auto instrumentation with the same name enabled

in this case i guess that would mean returning a no-op decorator, or changing the API to expose a method that registers a decorator on the ServerBuilder so we can no-op the registration in this case

I'll add this note to #903, no need to decide/address in this PR

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 ended up needing yet a different pattern because of the shading change making the classnames the same. I guess it's actually a bit more robust now and we'll revisit in #903 for an inversion of control.

@@ -20,5 +20,6 @@ dependencies {

compileOnly group: 'com.linecorp.armeria', name: 'armeria', version: '0.99.8'

testImplementation project(path: ':instrumentation:armeria-1.0:library')
Copy link
Contributor

Choose a reason for hiding this comment

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

path: is not needed here

packageName + ".shaded.client.ArmeriaClientTracer$ArmeriaSetter",
packageName + ".shaded.client.OpenTelemetryClient",
packageName + ".shaded.client.OpenTelemetryClient$Decorator",
// .thenAccept(log -> lambda
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure if this comment is helping or confusing :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Tried a bit harder

}

@Advice.OnMethodExit
public static void handleSuppression(
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add some documentation about what you are trying to achieve here

return "io.opentelemetry.armeria-1.0";
}

private enum ArmeriaSetter implements Setter<ClientRequestContext> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Although this is a nice way to ensure only one instance of the class exists in JVM, it differs from all other instrumentations. Unless there is some strong reason for such differences, I prefer to have uniform codebase.

});
}

try (Scope ignored = clientTracer.startScope(span, ctx)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Just to be sure: you start new scope even if span is not recording?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah - I think it's required for logs injection

Copy link
Member

Choose a reason for hiding this comment

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

ah, interesting, hadn't thought of that 👍

@anuraaga anuraaga merged commit c4a494c into open-telemetry:master Aug 12, 2020
mabdinur pushed a commit to mabdinur/opentelemetry-java-instrumentation that referenced this pull request Aug 17, 2020
* Add instrumentation for Armeria WebClient.

* Format:

* httpurlconnection

* Docs and consistency:
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