|
26 | 26 | import org.prebid.server.exception.PreBidException; |
27 | 27 | import org.prebid.server.execution.Timeout; |
28 | 28 | import org.prebid.server.json.JacksonMapper; |
| 29 | +import org.prebid.server.log.ConditionalLogger; |
29 | 30 | import org.prebid.server.log.Logger; |
30 | 31 | import org.prebid.server.log.LoggerFactory; |
31 | 32 | import org.prebid.server.model.CaseInsensitiveMultiMap; |
|
62 | 63 | public class HttpBidderRequester { |
63 | 64 |
|
64 | 65 | private static final Logger logger = LoggerFactory.getLogger(HttpBidderRequester.class); |
| 66 | + private static final ConditionalLogger conditionalLogger = new ConditionalLogger(logger); |
65 | 67 |
|
66 | 68 | private final HttpClient httpClient; |
67 | 69 | private final BidderRequestCompletionTrackerFactory completionTrackerFactory; |
68 | 70 | private final BidderErrorNotifier bidderErrorNotifier; |
69 | 71 | private final HttpBidderRequestEnricher requestEnricher; |
70 | 72 | private final JacksonMapper mapper; |
| 73 | + private final double logSamplingRate; |
71 | 74 |
|
72 | 75 | public HttpBidderRequester(HttpClient httpClient, |
73 | 76 | BidderRequestCompletionTrackerFactory completionTrackerFactory, |
74 | 77 | BidderErrorNotifier bidderErrorNotifier, |
75 | 78 | HttpBidderRequestEnricher requestEnricher, |
76 | | - JacksonMapper mapper) { |
| 79 | + JacksonMapper mapper, |
| 80 | + double logSamplingRate) { |
77 | 81 |
|
78 | 82 | this.httpClient = Objects.requireNonNull(httpClient); |
79 | 83 | this.completionTrackerFactory = completionTrackerFactoryOrFallback(completionTrackerFactory); |
80 | 84 | this.bidderErrorNotifier = Objects.requireNonNull(bidderErrorNotifier); |
81 | 85 | this.requestEnricher = Objects.requireNonNull(requestEnricher); |
82 | 86 | this.mapper = Objects.requireNonNull(mapper); |
| 87 | + this.logSamplingRate = logSamplingRate; |
83 | 88 | } |
84 | 89 |
|
85 | 90 | /** |
@@ -241,9 +246,9 @@ private static byte[] gzip(byte[] value) { |
241 | 246 | /** |
242 | 247 | * Produces {@link Future} with {@link BidderCall} containing request and error description. |
243 | 248 | */ |
244 | | - private static <T> Future<BidderCall<T>> failResponse(Throwable exception, HttpRequest<T> httpRequest) { |
245 | | - logger.warn("Error occurred while sending HTTP request to a bidder url: {} with message: {}", |
246 | | - httpRequest.getUri(), exception.getMessage()); |
| 249 | + private <T> Future<BidderCall<T>> failResponse(Throwable exception, HttpRequest<T> httpRequest) { |
| 250 | + conditionalLogger.warn("Error occurred while sending HTTP request to a bidder url: %s with message: %s" |
| 251 | + .formatted(httpRequest.getUri(), exception.getMessage()), logSamplingRate); |
247 | 252 | logger.debug("Error occurred while sending HTTP request to a bidder url: {}", |
248 | 253 | exception, httpRequest.getUri()); |
249 | 254 |
|
|
0 commit comments