-
Notifications
You must be signed in to change notification settings - Fork 867
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add option to create span on new netty connection (#3707)
* Create span on new netty connection * add test for connection failure * add comment * remove commented out line * rebase * test fix * review comments * keep connection failure span as client span
- Loading branch information
Showing
22 changed files
with
1,039 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
...entelemetry/javaagent/instrumentation/netty/common/client/ConnectionCompleteListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.javaagent.instrumentation.netty.common.client; | ||
|
||
import io.netty.channel.Channel; | ||
import io.netty.channel.ChannelFuture; | ||
import io.netty.util.concurrent.Future; | ||
import io.netty.util.concurrent.GenericFutureListener; | ||
import io.opentelemetry.context.Context; | ||
|
||
public class ConnectionCompleteListener implements GenericFutureListener<Future<Void>> { | ||
private final Context context; | ||
private final Context parentContext; | ||
|
||
public ConnectionCompleteListener(Context context, Context parentContext) { | ||
this.context = context; | ||
this.parentContext = parentContext; | ||
} | ||
|
||
@Override | ||
public void operationComplete(Future<Void> future) { | ||
AbstractNettyHttpClientTracer tracer = NettyHttpClientTracerAccess.getTracer(); | ||
if (tracer == null) { | ||
return; | ||
} | ||
|
||
Channel channel = null; | ||
if (future instanceof ChannelFuture) { | ||
channel = ((ChannelFuture) future).channel(); | ||
} | ||
tracer.endConnectionSpan(context, parentContext, null, channel, future.cause()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.