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

Trace DNS resolution in Netty 4.1 #4587

Merged
merged 3 commits into from
Nov 5, 2021

Conversation

mateuszrzeszutek
Copy link
Member

Previously, the netty 4.1 instrumentation created a single CONNECT span for both DNS resolution and the actual connection. This PR splits it into two spans: RESOLVE that captures DNS resolution and CONNECT capturing the actual connection.
I'm planning to implement the same change in reactor netty next - it will share a lot of classes with netty 4.1 (e.g. the instrumented AddressResolverGroup implementattion). Netty 3.8 and 4.0 don't seem to support any resolution abstraction (other than passing a InetSocketAddress) so I won't implement this change there.

@@ -24,21 +24,21 @@
Config.get().getBoolean("otel.instrumentation.netty.always-create-connect-span", false);
Copy link
Member Author

Choose a reason for hiding this comment

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

Can we still change property names? According to VERSIONING.md

Changes to configuration properties (...) will be considered breaking changes (unless they only affect telemetry produced by instrumentation)

This only affects generated telemetry, so maybe it'd be okay to rename it? I've been thinking about renaming this to sth like otel.instrumentation.<module>.connection-telemetry.enabled

Copy link
Member

@trask trask Nov 4, 2021

Choose a reason for hiding this comment

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

Yes we can rename this since it only affects telemetry shape

Copy link
Member Author

Choose a reason for hiding this comment

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

Nice. I'll do that in a separate PR, together with docs for the new property.

Copy link
Member

@trask trask left a comment

Choose a reason for hiding this comment

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

👍

cc @lmolkova as example of more http layering in practice

Comment on lines +59 to +63
public static void onExit(@Advice.This Bootstrap bootstrap) {
// this is already the default value, but we're calling the resolver() method to invoke its
// instrumentation
bootstrap.resolver(DefaultAddressResolverGroup.INSTANCE);
}
Copy link
Member

Choose a reason for hiding this comment

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

below alternative feels less strange, though I'm not sure what protection we get from muzzle for structure dependency like FieldValue? e.g. if the field had a different name for netty 4.1.20, would the CI muzzle check catch that? (or we'd only catch it if we ran tests against that version)

Suggested change
public static void onExit(@Advice.This Bootstrap bootstrap) {
// this is already the default value, but we're calling the resolver() method to invoke its
// instrumentation
bootstrap.resolver(DefaultAddressResolverGroup.INSTANCE);
}
public static void onExit(
@Advice.FieldValue(value = "resolver", readOnly = false) AddressResolverGroup<?> resolver) {
resolver = InstrumentedAddressResolverGroup.wrap(connectionInstrumenter(), resolver);
}

Copy link
Member Author

Choose a reason for hiding this comment

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

No protection at all, I'm afraid; ByteBuddy would just fail when applying this particular advice class and apply everything else.

Comment on lines +52 to +54
Instrumenter<NettyConnectionRequest, Channel> instrumenter =
Instrumenter.<NettyConnectionRequest, Channel>builder(
GlobalOpenTelemetry.get(), instrumentationName, NettyConnectionRequest::spanName)
Copy link
Member

Choose a reason for hiding this comment

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

I sort of see these as two different instrumenters, one for resolve and one for connect, but ok with this too

Copy link
Member Author

Choose a reason for hiding this comment

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

That was my first idea too, but then I noticed that they're basically the same; so I ended up with just reusing it and changing just the span name.

…ntelemetry/javaagent/instrumentation/netty/v4_1/client/InstrumentedAddressResolverGroup.java

Co-authored-by: Trask Stalnaker <trask.stalnaker@gmail.com>
@trask trask merged commit 958f1c0 into open-telemetry:main Nov 5, 2021
RashmiRam pushed a commit to RashmiRam/opentelemetry-auto-instr-java that referenced this pull request May 23, 2022
* Trace DNS resolution in Netty 4.1

* Fix reactor-netty 0.9 tests

* Update instrumentation/netty/netty-4.1/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/netty/v4_1/client/InstrumentedAddressResolverGroup.java

Co-authored-by: Trask Stalnaker <trask.stalnaker@gmail.com>

Co-authored-by: Trask Stalnaker <trask.stalnaker@gmail.com>
@mateuszrzeszutek mateuszrzeszutek deleted the netty-resolve branch November 18, 2022 10: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

2 participants