|
21 | 21 | import net.bytebuddy.matcher.ElementMatcher; |
22 | 22 | import org.apache.hc.core5.concurrent.FutureCallback; |
23 | 23 | import org.apache.hc.core5.http.nio.AsyncRequestProducer; |
| 24 | +import org.apache.hc.core5.http.protocol.BasicHttpContext; |
24 | 25 | import org.apache.hc.core5.http.protocol.HttpContext; |
25 | 26 |
|
26 | 27 | @AutoService(InstrumenterModule.class) |
@@ -91,14 +92,18 @@ public static class ClientAdvice { |
91 | 92 | @Advice.OnMethodEnter(suppress = Throwable.class) |
92 | 93 | public static AgentScope methodEnter( |
93 | 94 | @Advice.Argument(value = 0, readOnly = false) AsyncRequestProducer requestProducer, |
94 | | - @Advice.Argument(3) HttpContext context, |
| 95 | + @Advice.Argument(value = 3, readOnly = false) HttpContext context, |
95 | 96 | @Advice.Argument(value = 4, readOnly = false) FutureCallback<?> futureCallback) { |
96 | 97 |
|
97 | 98 | final AgentScope parentScope = activeScope(); |
98 | 99 | final AgentSpan clientSpan = startSpan(HTTP_REQUEST); |
99 | 100 | final AgentScope clientScope = activateSpan(clientSpan); |
100 | 101 | DECORATE.afterStart(clientSpan); |
101 | 102 |
|
| 103 | + if (context == null) { |
| 104 | + context = new BasicHttpContext(); |
| 105 | + } |
| 106 | + |
102 | 107 | requestProducer = new DelegatingRequestProducer(clientSpan, requestProducer); |
103 | 108 | futureCallback = |
104 | 109 | new TraceContinuedFutureCallback<>(parentScope, clientSpan, context, futureCallback); |
|
0 commit comments