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

merge master #2

Merged
merged 30 commits into from
May 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
08cbce6
Fix enforce-valid-account config logic (#1836)
mtuchkova Apr 25, 2022
1a9e1a9
Prebid Server prepare release 1.87.0
Compile-Ninja Apr 26, 2022
7cbd805
Prebid Server prepare for next development iteration (#1838)
Compile-Ninja Apr 26, 2022
9107570
Price Floors: Provider contract change (#1837)
Compile-Ninja Apr 26, 2022
344f16e
Tests: Fix unused param (#1840)
Net-burst Apr 26, 2022
ac8b652
Prebid Server prepare release 1.87.1
Compile-Ninja Apr 27, 2022
4ad67bf
Prebid Server prepare for next development iteration (#1843)
Compile-Ninja Apr 27, 2022
0c937bd
Colossus: Add `colossusssp` alias (#1824)
bretg Apr 28, 2022
0ef619e
Amx: Add support for native format (#1842)
marki1an Apr 28, 2022
d916db1
Yahoossp: Endpoint change. (#1825)
oath-jac Apr 28, 2022
ddd8a77
ExchangeService: Increase test coverage (#1806)
marki1an May 3, 2022
5b19ae7
Yieldlab: Fix GDPR handling for AMP (#1821)
marki1an May 3, 2022
7cc41e4
Adtelligent: Add PGAM alias (#1807)
marki1an May 3, 2022
53bda0d
Replace creation of `ObjectMapper` with configured instance. (#1831)
CTMBNara May 3, 2022
8ecf100
Tests: Cover PBS doesn't resend a report when del stats responses wit…
hupaloo May 3, 2022
fe53ff8
Tests: Relax timeouts (#1848)
Net-burst May 5, 2022
7900105
PubMatic: Add support for "Acat" ext parameter (#1813)
marki1an May 5, 2022
89f47da
AAX: New Adapter (#1819)
product-aax May 5, 2022
d789f3c
PG: Fix `ufpd` targeting lookup. (#1832)
CTMBNara May 5, 2022
4a84b96
ImproveDigital: Google additional consent support (#1816)
marki1an May 5, 2022
0f72255
Adnuntius: Fixed invalid json property naming (#1849)
And1sS May 5, 2022
197fa0d
Use labels in prometheus metrics (#1681)
rmattis May 5, 2022
54a651b
Tests: Add mechanism to launch containers on a static port (#1844)
marki1an May 5, 2022
9a30a96
Pass server info to request (#1758)
CTMBNara May 5, 2022
59e04b2
Colossus: Add new param (#1818)
marki1an May 5, 2022
007d5d2
Sharethrough: Revamp connecting to new Endpoint (#1772)
marki1an May 5, 2022
1a777ca
Prebid Server prepare release 1.88.0
Compile-Ninja May 11, 2022
807706c
Prebid Server prepare for next development iteration (#1854)
Compile-Ninja May 11, 2022
05b41d9
Refactor Adjustment factor resolving logic (#1856)
And1sS May 12, 2022
77787cd
Add additional metrcis for rejected responses (#1778)
CTMBNara May 12, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .github/workflows/pr-functional-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ jobs:
${{ runner.os }}-maven-

- name: Build with Maven
run: mvn -B verify -DskipUnitTests=true -Dmax.containers.count=5 --file extra/pom.xml
run: mvn -B verify -DskipUnitTests=true -Dtests.max-container-count=5 --file extra/pom.xml
1 change: 1 addition & 0 deletions docs/config-app.md
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ For `console` backend type available next options:

For `prometheus` backend type available next options:
- `metrics.prometheus.port` - if a port is specified a prometheus reporter will start on that port
- `metrics.prometheus.labels.enabled` - If set to `true` it enables tags/labels for prometheus metrics instead of including them in the metrics path

It is possible to define how many account-level metrics will be submitted on per-account basis.
See [metrics documentation](metrics.md) for complete list of metrics submitted at each verbosity level.
Expand Down
2 changes: 1 addition & 1 deletion docs/developers/functional-tests.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Functional tests need to have name template **.\*Spec.groovy**
**Properties:**

`launchContainers` - responsible for starting the MockServer and the MySQLContainer container. Default value is false to not launch containers for unit tests.
`max.containers.count` - maximum number of simultaneously running PBS containers. Default value is 2.
`tests.max-container-count` - maximum number of simultaneously running PBS containers. Default value is 2.
`skipFunctionalTests` - allow to skip funtional tests. Default value is false.
`skipUnitTests` - allow to skip unit tests. Default value is false.

Expand Down
6 changes: 3 additions & 3 deletions extra/bundle/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.prebid</groupId>
<artifactId>prebid-server-aggregator</artifactId>
<version>1.87.0-SNAPSHOT</version>
<version>1.89.0-SNAPSHOT</version>
<relativePath>../../extra/pom.xml</relativePath>
</parent>

Expand Down Expand Up @@ -77,12 +77,12 @@
<dependency>
<groupId>org.prebid</groupId>
<artifactId>prebid-server</artifactId>
<version>1.87.0-SNAPSHOT</version>
<version>1.89.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.prebid.server.hooks.modules</groupId>
<artifactId>ortb2-blocking</artifactId>
<version>1.87.0-SNAPSHOT</version>
<version>1.89.0-SNAPSHOT</version>
</dependency>
</dependencies>

Expand Down
2 changes: 1 addition & 1 deletion extra/modules/ortb2-blocking/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.prebid.server.hooks.modules</groupId>
<artifactId>all-modules</artifactId>
<version>1.87.0-SNAPSHOT</version>
<version>1.89.0-SNAPSHOT</version>
</parent>

<artifactId>ortb2-blocking</artifactId>
Expand Down
4 changes: 2 additions & 2 deletions extra/modules/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.prebid</groupId>
<artifactId>prebid-server-aggregator</artifactId>
<version>1.87.0-SNAPSHOT</version>
<version>1.89.0-SNAPSHOT</version>
<relativePath>../../extra/pom.xml</relativePath>
</parent>

Expand All @@ -26,7 +26,7 @@
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>

<prebid-server.version>1.87.0-SNAPSHOT</prebid-server.version>
<prebid-server.version>1.89.0-SNAPSHOT</prebid-server.version>

<lombok.version>1.18.22</lombok.version>

Expand Down
2 changes: 1 addition & 1 deletion extra/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>org.prebid</groupId>
<artifactId>prebid-server-aggregator</artifactId>
<version>1.87.0-SNAPSHOT</version>
<version>1.89.0-SNAPSHOT</version>
<packaging>pom</packaging>

<scm>
Expand Down
28 changes: 23 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.prebid</groupId>
<artifactId>prebid-server-aggregator</artifactId>
<version>1.87.0-SNAPSHOT</version>
<version>1.89.0-SNAPSHOT</version>
<relativePath>extra/pom.xml</relativePath>
</parent>

Expand Down Expand Up @@ -51,7 +51,7 @@
<metrics-influxdb.version>1.2.2</metrics-influxdb.version>
<consent-string-sdk.version>2.0.2</consent-string-sdk.version>
<iabtcf.version>2.0.7</iabtcf.version>
<metrics-prometheus.version>0.5.0</metrics-prometheus.version>
<metrics-prometheus.version>0.12.0</metrics-prometheus.version>
<maxmind-client.version>2.12.0</maxmind-client.version>
<logback.version>1.2.9</logback.version>
<log4j.version>2.17.1</log4j.version>
Expand All @@ -67,8 +67,8 @@
<jetty.version>9.4.44.v20210927</jetty.version>
<restassured.version>4.4.0</restassured.version>
<h2.version>2.1.210</h2.version>
<spock.version>2.0-groovy-3.0</spock.version>
<testcontainers.version>1.16.3</testcontainers.version>
<spock.version>2.1-groovy-3.0</spock.version>
<testcontainers.version>1.17.1</testcontainers.version>
<mockserver-client.version>5.11.2</mockserver-client.version>
<allure.version>2.17.2</allure.version>
<aspectj.version>1.9.7</aspectj.version>
Expand Down Expand Up @@ -756,7 +756,8 @@
<allure.results.directory>target/allure-results</allure.results.directory>
<mockserver.version>${mockserver-client.version}</mockserver.version>
<pbs.version>${project.version}</pbs.version>
<max.containers.count>2</max.containers.count>
<tests.max-container-count>2</tests.max-container-count>
<tests.fixed-container-ports>false</tests.fixed-container-ports>
</systemPropertyVariables>
</configuration>
<executions>
Expand Down Expand Up @@ -827,5 +828,22 @@
<maven.compiler.target>${java.version}</maven.compiler.target>
</properties>
</profile>
<profile>
<!-- Run only one application container instance on fixed ports for debugging purposes -->
<id>Container debugging</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<configuration>
<systemPropertyVariables>
<tests.fixed-container-ports>true</tests.fixed-container-ports>
</systemPropertyVariables>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
package org.prebid.server.auction;

import org.apache.commons.collections4.MapUtils;
import org.prebid.server.proto.openrtb.ext.request.ExtRequestBidAdjustmentFactors;
import org.prebid.server.proto.openrtb.ext.request.ImpMediaType;

import java.math.BigDecimal;
import java.util.Collections;
import java.util.Comparator;
import java.util.EnumMap;
import java.util.EnumSet;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.function.Function;

public class AdjustmentFactorResolver {

public BigDecimal resolve(ImpMediaType impMediaType,
ExtRequestBidAdjustmentFactors adjustmentFactors,
String bidder) {

final Set<ImpMediaType> impMediaTypes = impMediaType != null
? EnumSet.of(impMediaType)
: Collections.emptySet();

return resolve(impMediaTypes, adjustmentFactors, bidder);
}

public BigDecimal resolve(Set<ImpMediaType> impMediaTypes,
ExtRequestBidAdjustmentFactors adjustmentFactors,
String bidder) {

final EnumMap<ImpMediaType, Map<String, BigDecimal>> adjustmentFactorsByMediaTypes =
adjustmentFactors.getMediatypes();

final BigDecimal bidderAdjustmentFactor = adjustmentFactors.getAdjustments().get(bidder);
final BigDecimal effectiveBidderAdjustmentFactor = bidderAdjustmentFactor != null
? bidderAdjustmentFactor
: BigDecimal.ONE;

if (MapUtils.isEmpty(adjustmentFactorsByMediaTypes)) {
return effectiveBidderAdjustmentFactor;
}

final BigDecimal mediaTypeMinFactor = impMediaTypes.stream()
.map(adjustmentFactorsByMediaTypes::get)
.map(bidderToFactor -> MapUtils.isNotEmpty(bidderToFactor)
? bidderToFactor.get(bidder)
: effectiveBidderAdjustmentFactor)
.filter(Objects::nonNull)
.min(Comparator.comparing(Function.identity()))
.orElse(null);

return createFactorValue(mediaTypeMinFactor, bidderAdjustmentFactor);
}

private static BigDecimal createFactorValue(BigDecimal mediaTypeFactor, BigDecimal adjustmentFactor) {
if (mediaTypeFactor != null && adjustmentFactor != null) {
return mediaTypeFactor.min(adjustmentFactor);
} else if (mediaTypeFactor != null) {
return mediaTypeFactor;
} else if (adjustmentFactor != null) {
return adjustmentFactor;
}

return BigDecimal.ONE;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1174,8 +1174,8 @@ private boolean checkEchoVideoAttrs(Imp imp) {
final Boolean echoVideoAttrs = options != null ? options.getEchoVideoAttrs() : null;
return BooleanUtils.toBoolean(echoVideoAttrs);
} catch (JsonProcessingException e) {
throw new InvalidRequestException(String.format(
"Incorrect Imp extension format for Imp with id %s: %s", imp.getId(), e.getMessage()));
throw new InvalidRequestException(
"Incorrect Imp extension format for Imp with id " + imp.getId() + ": " + e.getMessage());
}
}
return false;
Expand Down
83 changes: 17 additions & 66 deletions src/main/java/org/prebid/server/auction/ExchangeService.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import com.iab.openrtb.request.Site;
import com.iab.openrtb.request.Source;
import com.iab.openrtb.request.User;
import com.iab.openrtb.request.Video;
import com.iab.openrtb.response.Bid;
import com.iab.openrtb.response.BidResponse;
import com.iab.openrtb.response.SeatBid;
Expand Down Expand Up @@ -95,7 +94,6 @@
import org.prebid.server.proto.openrtb.ext.request.ExtUserEid;
import org.prebid.server.proto.openrtb.ext.request.ImpMediaType;
import org.prebid.server.proto.openrtb.ext.request.TraceLevel;
import org.prebid.server.proto.openrtb.ext.response.BidType;
import org.prebid.server.proto.openrtb.ext.response.ExtBidResponse;
import org.prebid.server.proto.openrtb.ext.response.ExtBidResponsePrebid;
import org.prebid.server.proto.openrtb.ext.response.ExtModules;
Expand Down Expand Up @@ -127,6 +125,7 @@
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import java.util.function.Function;
import java.util.function.Supplier;
Expand Down Expand Up @@ -169,6 +168,7 @@ public class ExchangeService {
private final HttpInteractionLogger httpInteractionLogger;
private final PriceFloorAdjuster priceFloorAdjuster;
private final PriceFloorEnforcer priceFloorEnforcer;
private final AdjustmentFactorResolver adjustmentFactorResolver;
private final Metrics metrics;
private final Clock clock;
private final JacksonMapper mapper;
Expand All @@ -192,6 +192,7 @@ public ExchangeService(long expectedCacheTime,
HttpInteractionLogger httpInteractionLogger,
PriceFloorAdjuster priceFloorAdjuster,
PriceFloorEnforcer priceFloorEnforcer,
AdjustmentFactorResolver adjustmentFactorResolver,
Metrics metrics,
Clock clock,
JacksonMapper mapper,
Expand All @@ -218,6 +219,7 @@ public ExchangeService(long expectedCacheTime,
this.httpInteractionLogger = Objects.requireNonNull(httpInteractionLogger);
this.priceFloorAdjuster = Objects.requireNonNull(priceFloorAdjuster);
this.priceFloorEnforcer = Objects.requireNonNull(priceFloorEnforcer);
this.adjustmentFactorResolver = Objects.requireNonNull(adjustmentFactorResolver);
this.metrics = Objects.requireNonNull(metrics);
this.clock = Objects.requireNonNull(clock);
this.mapper = Objects.requireNonNull(mapper);
Expand Down Expand Up @@ -1127,10 +1129,9 @@ private ExtRequest prepareExt(String bidder,
final ObjectNode bidders = prebidParameters != null
? mapper.mapper().valueToTree(ExtPrebidBidders.of(prebidParameters))
: null;

final ExtRequestPrebid.ExtRequestPrebidBuilder extPrebidBuilder = extPrebid != null
? extPrebid.toBuilder()
: ExtRequestPrebid.builder();
final ExtRequestPrebid.ExtRequestPrebidBuilder extPrebidBuilder = Optional.ofNullable(extPrebid)
.map(ExtRequestPrebid::toBuilder)
.orElse(ExtRequestPrebid.builder());

return ExtRequest.of(
extPrebidBuilder
Expand Down Expand Up @@ -1369,8 +1370,8 @@ private AuctionParticipation validBidderResponse(AuctionParticipation auctionPar

private BidderError makeValidationBidderError(Bid bid, ValidationResult validationResult) {
final String validationErrors = Stream.concat(
validationResult.getErrors().stream().map(message -> "Error: " + message),
validationResult.getWarnings().stream().map(message -> "Warning: " + message))
validationResult.getErrors().stream().map(message -> "Error: " + message),
validationResult.getWarnings().stream().map(message -> "Warning: " + message))
.collect(Collectors.joining(". "));

final String bidId = ObjectUtil.getIfNotNullOrDefault(bid, Bid::getId, () -> "unknown");
Expand Down Expand Up @@ -1463,70 +1464,20 @@ private BidderBid updateBidderBidWithBidPriceChanges(BidderBid bidderBid,
return bidderBid.toBuilder().bid(bidBuilder.build()).build();
}

private static ImpMediaType resolveBidAdjustmentMediaType(String bidImpId,
List<Imp> imps,
BidType bidType) {

switch (bidType) {
case banner:
return ImpMediaType.banner;
case xNative:
return ImpMediaType.xNative;
case audio:
return ImpMediaType.audio;
case video:
return resolveBidAdjustmentVideoMediaType(bidImpId, imps);
default:
throw new PreBidException("BidType not present for bidderBid");
}
}

private static ImpMediaType resolveBidAdjustmentVideoMediaType(String bidImpId, List<Imp> imps) {
final Video bidImpVideo = imps.stream()
.filter(imp -> imp.getId().equals(bidImpId))
.map(Imp::getVideo)
.filter(Objects::nonNull)
.findFirst()
.orElse(null);

if (bidImpVideo == null) {
private BigDecimal bidAdjustmentForBidder(String bidder, BidRequest bidRequest, BidderBid bidderBid) {
final ExtRequestBidAdjustmentFactors adjustmentFactors = extBidAdjustmentFactors(bidRequest);
if (adjustmentFactors == null) {
return null;
}
final ImpMediaType mediaType = ImpMediaTypeResolver.resolve(
bidderBid.getBid().getImpid(), bidRequest.getImp(), bidderBid.getType());

final Integer placement = bidImpVideo.getPlacement();
return placement == null || Objects.equals(placement, 1)
? ImpMediaType.video
: ImpMediaType.video_outstream;
return adjustmentFactorResolver.resolve(mediaType, adjustmentFactors, bidder);
}

private static BigDecimal bidAdjustmentForBidder(String bidder,
BidRequest bidRequest,
BidderBid bidderBid) {
private static ExtRequestBidAdjustmentFactors extBidAdjustmentFactors(BidRequest bidRequest) {
final ExtRequestPrebid prebid = extRequestPrebid(bidRequest);
final ExtRequestBidAdjustmentFactors extBidAdjustmentFactors = prebid != null
? prebid.getBidadjustmentfactors()
: null;
if (extBidAdjustmentFactors == null) {
return null;
}
final ImpMediaType mediaType =
resolveBidAdjustmentMediaType(bidderBid.getBid().getImpid(), bidRequest.getImp(), bidderBid.getType());

return resolveBidAdjustmentFactor(extBidAdjustmentFactors, mediaType, bidder);
}

private static BigDecimal resolveBidAdjustmentFactor(ExtRequestBidAdjustmentFactors extBidAdjustmentFactors,
ImpMediaType mediaType,
String bidder) {
final Map<ImpMediaType, Map<String, BigDecimal>> mediatypes =
extBidAdjustmentFactors.getMediatypes();
final Map<String, BigDecimal> adjustmentsByMediatypes = mediatypes != null ? mediatypes.get(mediaType) : null;
final BigDecimal adjustmentFactorByMediaType =
adjustmentsByMediatypes != null ? adjustmentsByMediatypes.get(bidder) : null;
if (adjustmentFactorByMediaType != null) {
return adjustmentFactorByMediaType;
}
return extBidAdjustmentFactors.getAdjustments().get(bidder);
return prebid != null ? prebid.getBidadjustmentfactors() : null;
}

private static BigDecimal adjustPrice(BigDecimal priceAdjustmentFactor, BigDecimal price) {
Expand Down
Loading