@@ -100,7 +100,7 @@ public class GatewayBridge {
100100 private final SubscriptionService subscriptionService ;
101101 private final EventProducerService producerService ;
102102 private final Supplier <ApiSecuritySampler > requestSamplerSupplier ;
103- private final ApiSecurityDownstreamSampler downstreamSampler ;
103+ private final Supplier < ApiSecurityDownstreamSampler > downstreamSamplerSupplier ;
104104 private final List <TraceSegmentPostProcessor > traceSegmentPostProcessors ;
105105
106106 // subscriber cache
@@ -129,12 +129,12 @@ public GatewayBridge(
129129 SubscriptionService subscriptionService ,
130130 EventProducerService producerService ,
131131 @ Nonnull Supplier <ApiSecuritySampler > requestSamplerSupplier ,
132- ApiSecurityDownstreamSampler downstreamSampler ,
132+ @ Nonnull Supplier < ApiSecurityDownstreamSampler > downstreamSamplerSupplier ,
133133 List <TraceSegmentPostProcessor > traceSegmentPostProcessors ) {
134134 this .subscriptionService = subscriptionService ;
135135 this .producerService = producerService ;
136136 this .requestSamplerSupplier = requestSamplerSupplier ;
137- this .downstreamSampler = downstreamSampler ;
137+ this .downstreamSamplerSupplier = downstreamSamplerSupplier ;
138138 this .traceSegmentPostProcessors = traceSegmentPostProcessors ;
139139 }
140140
@@ -332,7 +332,8 @@ private Flow<Boolean> onHttpClientSampling(RequestContext ctx_, final long reque
332332 return new Flow .ResultFlow <>(null );
333333 }
334334 ctx .increaseHttpClientRequestCount ();
335- return new Flow .ResultFlow <>(downstreamSampler .sampleHttpClientRequest (ctx , requestId ));
335+ final ApiSecurityDownstreamSampler sampler = downstreamSamplerSupplier .get ();
336+ return new Flow .ResultFlow <>(sampler .sampleHttpClientRequest (ctx , requestId ));
336337 }
337338
338339 private Flow <Void > onHttpClientRequest (RequestContext ctx_ , HttpClientRequest request ) {
@@ -346,8 +347,9 @@ private Flow<Void> onHttpClientRequest(RequestContext ctx_, HttpClientRequest re
346347 .add (KnownAddresses .IO_NET_URL , request .getUrl ())
347348 .add (KnownAddresses .IO_NET_REQUEST_METHOD , request .getMethod ())
348349 .add (KnownAddresses .IO_NET_REQUEST_HEADERS , request .getHeaders ());
349- ;
350- if (downstreamSampler .isSampled (ctx , request .getRequestId ())) {
350+
351+ final ApiSecurityDownstreamSampler sampler = downstreamSamplerSupplier .get ();
352+ if (sampler .isSampled (ctx , request .getRequestId ())) {
351353 final Object body = parseHttpClientBody (ctx , request );
352354 if (body != null ) {
353355 bundleBuilder .add (KnownAddresses .IO_NET_REQUEST_BODY , body );
@@ -387,7 +389,8 @@ private Flow<Void> onHttpClientResponse(RequestContext ctx_, HttpClientResponse
387389 .add (KnownAddresses .IO_NET_RESPONSE_STATUS , response .getStatus ())
388390 .add (KnownAddresses .IO_NET_RESPONSE_HEADERS , response .getHeaders ());
389391 // ignore the response if not sampled
390- if (downstreamSampler .isSampled (ctx , response .getRequestId ())) {
392+ final ApiSecurityDownstreamSampler sampler = downstreamSamplerSupplier .get ();
393+ if (sampler .isSampled (ctx , response .getRequestId ())) {
391394 final Object body = parseHttpClientBody (ctx , response );
392395 if (body != null ) {
393396 bundleBuilder .add (KnownAddresses .IO_NET_RESPONSE_BODY , body );
0 commit comments