Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sample HttpBidderRequester Logs #3546

Merged
merged 1 commit into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions src/main/java/org/prebid/server/bidder/HttpBidderRequester.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.prebid.server.exception.PreBidException;
import org.prebid.server.execution.Timeout;
import org.prebid.server.json.JacksonMapper;
import org.prebid.server.log.ConditionalLogger;
import org.prebid.server.log.Logger;
import org.prebid.server.log.LoggerFactory;
import org.prebid.server.model.CaseInsensitiveMultiMap;
Expand Down Expand Up @@ -62,24 +63,28 @@
public class HttpBidderRequester {

private static final Logger logger = LoggerFactory.getLogger(HttpBidderRequester.class);
private static final ConditionalLogger conditionalLogger = new ConditionalLogger(logger);

private final HttpClient httpClient;
private final BidderRequestCompletionTrackerFactory completionTrackerFactory;
private final BidderErrorNotifier bidderErrorNotifier;
private final HttpBidderRequestEnricher requestEnricher;
private final JacksonMapper mapper;
private final double logSamplingRate;

public HttpBidderRequester(HttpClient httpClient,
BidderRequestCompletionTrackerFactory completionTrackerFactory,
BidderErrorNotifier bidderErrorNotifier,
HttpBidderRequestEnricher requestEnricher,
JacksonMapper mapper) {
JacksonMapper mapper,
double logSamplingRate) {

this.httpClient = Objects.requireNonNull(httpClient);
this.completionTrackerFactory = completionTrackerFactoryOrFallback(completionTrackerFactory);
this.bidderErrorNotifier = Objects.requireNonNull(bidderErrorNotifier);
this.requestEnricher = Objects.requireNonNull(requestEnricher);
this.mapper = Objects.requireNonNull(mapper);
this.logSamplingRate = logSamplingRate;
}

/**
Expand Down Expand Up @@ -241,9 +246,9 @@ private static byte[] gzip(byte[] value) {
/**
* Produces {@link Future} with {@link BidderCall} containing request and error description.
*/
private static <T> Future<BidderCall<T>> failResponse(Throwable exception, HttpRequest<T> httpRequest) {
logger.warn("Error occurred while sending HTTP request to a bidder url: {} with message: {}",
httpRequest.getUri(), exception.getMessage());
private <T> Future<BidderCall<T>> failResponse(Throwable exception, HttpRequest<T> httpRequest) {
conditionalLogger.warn("Error occurred while sending HTTP request to a bidder url: %s with message: %s"
.formatted(httpRequest.getUri(), exception.getMessage()), logSamplingRate);
logger.debug("Error occurred while sending HTTP request to a bidder url: {}",
exception, httpRequest.getUri());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -752,11 +752,13 @@ HttpBidderRequester httpBidderRequester(
HttpBidderRequestEnricher requestEnricher,
JacksonMapper mapper) {

return new HttpBidderRequester(httpClient,
return new HttpBidderRequester(
httpClient,
bidderRequestCompletionTrackerFactory,
bidderErrorNotifier,
requestEnricher,
mapper);
mapper,
logSamplingRate);
}

@Bean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public void setUp() {
expiredTimeout = timeoutFactory.create(clock.instant().minusMillis(1500L).toEpochMilli(), 1000L);

target = new HttpBidderRequester(
httpClient, null, bidderErrorNotifier, requestEnricher, jacksonMapper);
httpClient, null, bidderErrorNotifier, requestEnricher, jacksonMapper, 0.0);
given(bidder.makeBidderResponse(any(BidderCall.class), any(BidRequest.class))).willCallRealMethod();
}

Expand Down Expand Up @@ -506,7 +506,8 @@ public void processBids(List<BidderBid> bids) {
},
bidderErrorNotifier,
requestEnricher,
jacksonMapper);
jacksonMapper,
0.0);

final BidRequest bidRequest = bidRequestWithDeals("deal1", "deal2");
final BidderRequest bidderRequest = BidderRequest.builder()
Expand Down
Loading