|
32 | 32 | import com.uid2.shared.store.*; |
33 | 33 | import com.uid2.shared.store.reader.RotatingKeysetProvider; |
34 | 34 | import com.uid2.shared.store.salt.ISaltProvider; |
| 35 | +import io.micrometer.core.instrument.DistributionSummary; |
35 | 36 | import io.micrometer.core.instrument.Metrics; |
36 | 37 | import io.micrometer.core.instrument.simple.SimpleMeterRegistry; |
37 | 38 | import io.vertx.core.AsyncResult; |
@@ -2904,6 +2905,81 @@ void identityMapBatchRequestTooLargeForPhone(Vertx vertx, VertxTestContext testC |
2904 | 2905 | send(vertx, "v2/identity/map", req, 413, json -> testContext.completeNow()); |
2905 | 2906 | } |
2906 | 2907 |
|
| 2908 | + @Test |
| 2909 | + void identityMapV2InputMetricTaggedWithEmailDiiType(Vertx vertx, VertxTestContext testContext) { |
| 2910 | + fakeAuth(201, Role.MAPPER); |
| 2911 | + setupKeys(); |
| 2912 | + setupSalts(); |
| 2913 | + |
| 2914 | + JsonObject req = new JsonObject() |
| 2915 | + .put("email", new JsonArray().add("test1@uid2.com").add("test2@uid2.com")); |
| 2916 | + |
| 2917 | + send(vertx, "v2/identity/map", req, 200, json -> { |
| 2918 | + DistributionSummary summary = Metrics.globalRegistry |
| 2919 | + .get("uid2_operator_identity_map_inputs") |
| 2920 | + .tag("path", "/v2/identity/map") |
| 2921 | + .tag("dii_type", "email") |
| 2922 | + .summary(); |
| 2923 | + assertNotNull(summary); |
| 2924 | + assertEquals(2.0, summary.totalAmount()); |
| 2925 | + testContext.completeNow(); |
| 2926 | + }); |
| 2927 | + } |
| 2928 | + |
| 2929 | + @Test |
| 2930 | + void identityMapV2InputMetricTaggedWithEmailHashDiiType(Vertx vertx, VertxTestContext testContext) { |
| 2931 | + fakeAuth(201, Role.MAPPER); |
| 2932 | + setupKeys(); |
| 2933 | + setupSalts(); |
| 2934 | + |
| 2935 | + JsonObject req = new JsonObject() |
| 2936 | + .put("email_hash", new JsonArray() |
| 2937 | + .add(TokenUtils.getIdentityHashString("test1@uid2.com"))); |
| 2938 | + |
| 2939 | + send(vertx, "v2/identity/map", req, 200, json -> { |
| 2940 | + DistributionSummary summary = Metrics.globalRegistry |
| 2941 | + .get("uid2_operator_identity_map_inputs") |
| 2942 | + .tag("path", "/v2/identity/map") |
| 2943 | + .tag("dii_type", "email_hash") |
| 2944 | + .summary(); |
| 2945 | + assertNotNull(summary); |
| 2946 | + assertEquals(1.0, summary.totalAmount()); |
| 2947 | + testContext.completeNow(); |
| 2948 | + }); |
| 2949 | + } |
| 2950 | + |
| 2951 | + @Test |
| 2952 | + void identityMapV3InputMetricTaggedWithPathAndDiiType(Vertx vertx, VertxTestContext testContext) { |
| 2953 | + fakeAuth(201, Role.MAPPER); |
| 2954 | + SaltEntry salt = setupSalts(); |
| 2955 | + when(saltProviderSnapshot.getRotatingSalt(any())).thenReturn(salt); |
| 2956 | + |
| 2957 | + JsonObject req = new JsonObject() |
| 2958 | + .put("email", new JsonArray().add("test1@uid2.com").add("test2@uid2.com")) |
| 2959 | + .put("phone_hash", new JsonArray() |
| 2960 | + .add(TokenUtils.getIdentityHashString("+15555555555"))); |
| 2961 | + |
| 2962 | + send(vertx, "v3/identity/map", req, 200, json -> { |
| 2963 | + DistributionSummary emailSummary = Metrics.globalRegistry |
| 2964 | + .get("uid2_operator_identity_map_inputs") |
| 2965 | + .tag("path", "/v3/identity/map") |
| 2966 | + .tag("dii_type", "email") |
| 2967 | + .summary(); |
| 2968 | + assertNotNull(emailSummary); |
| 2969 | + assertEquals(2.0, emailSummary.totalAmount()); |
| 2970 | + |
| 2971 | + DistributionSummary phoneHashSummary = Metrics.globalRegistry |
| 2972 | + .get("uid2_operator_identity_map_inputs") |
| 2973 | + .tag("path", "/v3/identity/map") |
| 2974 | + .tag("dii_type", "phone_hash") |
| 2975 | + .summary(); |
| 2976 | + assertNotNull(phoneHashSummary); |
| 2977 | + assertEquals(1.0, phoneHashSummary.totalAmount()); |
| 2978 | + |
| 2979 | + testContext.completeNow(); |
| 2980 | + }); |
| 2981 | + } |
| 2982 | + |
2907 | 2983 | @ParameterizedTest |
2908 | 2984 | @ValueSource(booleans = {true, false}) |
2909 | 2985 | void identityMapOptoutDefaultOption(boolean useV4Uid, Vertx vertx, VertxTestContext testContext) { |
|
0 commit comments