Skip to content

Netty 3.8-3.10 instrumentation#1327

Merged
devinsba merged 15 commits into
masterfrom
devinsba/netty-3.9
Mar 23, 2020
Merged

Netty 3.8-3.10 instrumentation#1327
devinsba merged 15 commits into
masterfrom
devinsba/netty-3.9

Conversation

@devinsba
Copy link
Copy Markdown
Contributor

@devinsba devinsba commented Mar 20, 2020

Creates new Netty 3.8 through 3.10 instrumentation, allowing for instrumentation of Play 2.3 which depends on this. Mostly copies the netty 4.0 instrumentation

@devinsba devinsba requested a review from a team as a code owner March 20, 2020 09:52
Comment thread dd-java-agent/instrumentation/netty-3.9/netty-3.9.gradle Outdated
@devinsba devinsba changed the title Netty 3.9 instrumentation Netty 3.8+3.9 instrumentation Mar 20, 2020
@devinsba devinsba requested a review from tylerbenson March 20, 2020 18:30
Comment thread dd-java-agent/instrumentation/netty-3.8/src/test/groovy/Netty39ClientTest.groovy Outdated
@devinsba devinsba changed the title Netty 3.8+3.9 instrumentation Netty 3.8-3.10 instrumentation Mar 23, 2020
@devinsba devinsba requested review from a team and tylerbenson March 23, 2020 14:58
}

@Override
public ElementMatcher<ClassLoader> classLoaderMatcher() {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Not necessarily for this PR, but now, that having a classLoaderMatcher check is the norm to combat matching costs. I think we should make the concept of key class for a library a required part of almost every instrumentation.

I also think we should revisit the idea of a Library as a first class concept as well. While at first, I think this seems like more work. I think right now we end up duplicating some classLoaderMatcher code because we lack the concept of a library.

try (final AgentScope scope = activateSpan(span, false)) {
DECORATE.onResponse(span, (HttpResponse) msg.getMessage());
DECORATE.beforeFinish(span);
span.finish();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

finally?

Copy link
Copy Markdown
Contributor Author

@devinsba devinsba Mar 23, 2020

Choose a reason for hiding this comment

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

I think the span needs to be finished while it's in scope. Not 100% sure on that with our impl but it's a common pattern I've seen

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This code is the same in the other 2 versions of the netty instrumentation


@Override
protected URI url(final HttpRequest request) throws URISyntaxException {
final URI uri = new URI(request.getUri());
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Probably not for this PR, but we probably shouldn't build URI just to extract pieces to tags later.
That creates a hot allocation point under load.

}

@Override
protected Integer status(final HttpResponse httpResponse) {
Copy link
Copy Markdown
Contributor

@dougqh dougqh Mar 23, 2020

Choose a reason for hiding this comment

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

Again, probably not this PR.

But why does this return Integer rather than int?
Also, we might want to create our Integer cache for HttpStatus codes, since most of them lie outside the default cache range.

@dougqh
Copy link
Copy Markdown
Contributor

dougqh commented Mar 23, 2020

I'm having a bit of trouble following the span.finish / scope.close logic.
I'd generally expect those operations to be inside a finally block, but not tracing expert, so maybe there's something that I don't understand.

@devinsba
Copy link
Copy Markdown
Contributor Author

One of the reasons that span close or scope close might happen inside the try and not in finally is that they may need to be done while a specific scope (the one from the try-with-resources) is on top of the stack, so then we need to do the close within the try because the resource is closed before the finally is executed

@devinsba devinsba requested a review from dougqh March 23, 2020 18:59
@dougqh
Copy link
Copy Markdown
Contributor

dougqh commented Mar 23, 2020

One of the reasons that span close or scope close might happen inside the try and not in finally is that they may need to be done while a specific scope (the one from the try-with-resources) is on top of the stack, so then we need to do the close within the try because the resource is closed before the finally is executed

Yes, I was just suspicious because I know we've had some issues with memory leaks related to unclosed scopes. I don't doubt that this is normal pattern in our tracer, but I'm wondering if those are slow leaks from exception handling. Anyway, we can revisit that matter in another PR if necessary.

@devinsba devinsba merged commit 2b5037e into master Mar 23, 2020
@devinsba devinsba deleted the devinsba/netty-3.9 branch March 23, 2020 19:12
@randomanderson randomanderson added this to the 0.47.0 milestone Mar 23, 2020
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.

5 participants