Browse code

POPIT-166 Fix: add latd to PushSupport log

David Phan authored on 11/06/2018 09:20:09
Showing 3 changed files
... ...
@@ -170,7 +170,7 @@ public class PingProtocol implements IEasProtocol<PingRequest, PingResponse> {
170 170
 			Requests.tag(bs.getRequest(), "async", "true");
171 171
 			Requests.tag(bs.getRequest(), "timeout", intervalSeconds + "s");
172 172
 
173
-			PushSupport.register(intervalSeconds * 1000, bs.getDeviceId().getInternalId(), cols,
173
+			PushSupport.register(bs.getLoginAtDomain(), intervalSeconds * 1000, bs.getDeviceId().getInternalId(), cols,
174 174
 					new PingReplyHandler(bs, responseHandler));
175 175
 
176 176
 		} else {
... ...
@@ -201,9 +201,7 @@ public class SyncProtocol implements IEasProtocol<SyncRequest, SyncResponse> {
201 201
 					executeSync(bs, sr, responseHandler);
202 202
 				}
203 203
 			});
204
-
205 204
 		} else {
206
-
207 205
 			logger.info("Sync push mode. user: {}, device: {}, collections size: {}", bs.getLoginAtDomain(),
208 206
 					bs.getDevId(), bs.getLastMonitored().size());
209 207
 
... ...
@@ -219,8 +217,8 @@ public class SyncProtocol implements IEasProtocol<SyncRequest, SyncResponse> {
219 219
 				cols.add(csr.getCollectionId());
220 220
 			}
221 221
 
222
-			PushSupport.register(sr.waitIntervalSeconds * 1000, bs.getDeviceId().getInternalId(), cols,
223
-					new SyncReplyHandler(this, bs, responseHandler, Sets.newHashSet(bs.getLastMonitored())));
222
+			PushSupport.register(bs.getLoginAtDomain(), sr.waitIntervalSeconds * 1000, bs.getDeviceId().getInternalId(),
223
+					cols, new SyncReplyHandler(this, bs, responseHandler, Sets.newHashSet(bs.getLastMonitored())));
224 224
 		}
225 225
 
226 226
 	}
... ...
@@ -22,6 +22,7 @@ import java.util.Set;
22 22
 
23 23
 import org.slf4j.Logger;
24 24
 import org.slf4j.LoggerFactory;
25
+import org.slf4j.MDC;
25 26
 import org.vertx.java.core.AsyncResult;
26 27
 import org.vertx.java.core.Handler;
27 28
 import org.vertx.java.core.eventbus.EventBus;
... ...
@@ -38,16 +39,18 @@ public class PushSupport {
38 38
 	private static final Logger logger = LoggerFactory.getLogger(PushSupport.class);
39 39
 	private static final EventBus eb = VertxPlatform.eventBus();
40 40
 
41
-	public static void register(long timeoutMs, String partnershipId, Set<Integer> collections,
41
+	public static void register(String latd, long timeoutMs, String partnershipId, Set<Integer> collections,
42 42
 			Handler<AsyncResult<Message<LocalJsonObject<PushTrigger>>>> replyHandler) {
43 43
 
44
+		MDC.put("user", latd.replace("@", "_at_"));
45
+
44 46
 		PushRegistrationRequest pushReq = new PushRegistrationRequest();
45 47
 		pushReq.collectionIds = collections;
46 48
 		pushReq.partnershipId = partnershipId;
47 49
 		pushReq.timeoutMs = timeoutMs;
48 50
 
49 51
 		LocalJsonObject<PushRegistrationRequest> jso = new LocalJsonObject<>(pushReq);
50
-		logger.info("Setting up push on {} collections, with a timeout of {}s.", collections.size(),
52
+		logger.info("[{}] Setting up push on collections {}, with a timeout of {}s.", latd, collections,
51 53
 				pushReq.timeoutMs / 1000);
52 54
 
53 55
 		eb.sendWithTimeout(EasBusEndpoints.PUSH_REGISTRATION, jso, timeoutMs, replyHandler);