@@ -86,7 +86,7 @@ public Future<BidRequest> process(AuctionContext auctionContext, BidRequest bidR
8686 .orElse (null );
8787
8888 return fetchProfiles (accountId , profilesIds , timeoutMillis (bidRequest ))
89- .map (profiles -> emitMetrics (accountId , profiles , auctionContext ))
89+ .compose (profiles -> emitMetrics (accountId , profiles , auctionContext ))
9090 .map (profiles -> mergeResults (
9191 applyRequestProfiles (profilesIds .request (), profiles .getStoredIdToRequest (), bidRequest ),
9292 applyImpsProfiles (profilesIds .imps (), profiles .getStoredIdToImp (), bidRequest .getImp ())))
@@ -109,7 +109,7 @@ private AllProfilesIds profilesIds(BidRequest bidRequest, AuctionContext auction
109109
110110 if (auctionContext .getDebugContext ().isDebugEnabled () && !profilesIds .equals (initialProfilesIds )) {
111111 auctionContext .getDebugWarnings ().add ("Profiles exceeded the limit." );
112- metrics .updateProfileMetric (MetricName .err ); // TODO
112+ metrics .updateProfileMetric (MetricName .limit_exceeded );
113113 }
114114
115115 return profilesIds ;
@@ -171,26 +171,28 @@ private Future<StoredDataResult<Profile>> fetchProfiles(String accountId,
171171 .collect (Collectors .toSet ());
172172 final Timeout timeout = timeoutFactory .create (timeoutMillis );
173173
174- return applicationSettings .getProfiles (accountId , requestProfilesIds , impProfilesIds , timeout )
175- .compose (profiles -> profiles .getErrors ().isEmpty () || !failOnUnknown
176- ? Future .succeededFuture (profiles )
177- : Future .failedFuture (new InvalidProfileException (profiles .getErrors ())));
174+ return applicationSettings .getProfiles (accountId , requestProfilesIds , impProfilesIds , timeout );
178175 }
179176
180- private StoredDataResult <Profile > emitMetrics (String accountId ,
181- StoredDataResult <Profile > fetchResult ,
182- AuctionContext auctionContext ) {
177+ private Future < StoredDataResult <Profile > > emitMetrics (String accountId ,
178+ StoredDataResult <Profile > fetchResult ,
179+ AuctionContext auctionContext ) {
183180
184- if (!fetchResult .getErrors ().isEmpty ()) {
181+ final List <String > errors = fetchResult .getErrors ();
182+ if (!errors .isEmpty ()) {
185183 metrics .updateProfileMetric (MetricName .missing );
186184
187185 if (auctionContext .getDebugContext ().isDebugEnabled ()) {
188186 metrics .updateAccountProfileMetric (accountId , MetricName .missing );
189- auctionContext .getDebugWarnings ().addAll (fetchResult .getErrors ());
187+ auctionContext .getDebugWarnings ().addAll (errors );
188+ }
189+
190+ if (failOnUnknown ) {
191+ return Future .failedFuture (new InvalidProfileException (errors ));
190192 }
191193 }
192194
193- return fetchResult ;
195+ return Future . succeededFuture ( fetchResult ) ;
194196 }
195197
196198 private BidRequest applyRequestProfiles (List <String > profilesIds ,
0 commit comments