Search in sources :

Example 1 with Telemetry

use of com.adobe.target.delivery.v1.model.Telemetry in project target-java-sdk by adobe.

the class DefaultTargetService method executeNotification.

@Override
public ResponseStatus executeNotification(TargetDeliveryRequest deliveryRequest) {
    TimingTool timer = new TimingTool();
    timer.timeStart(TIMING_EXECUTE_REQUEST);
    NotificationService.setBeaconToFalse(deliveryRequest.getDeliveryRequest());
    TargetDeliveryResponse targetDeliveryResponse;
    Telemetry telemetry = telemetryService.getTelemetry();
    if (!telemetry.getEntries().isEmpty()) {
        deliveryRequest.getDeliveryRequest().setTelemetry(telemetry);
    }
    ResponseWrapper response = callDeliveryApi(deliveryRequest);
    targetDeliveryResponse = getTargetDeliveryResponse(deliveryRequest, response.getHttpResponse());
    telemetryService.addTelemetry(deliveryRequest, timer, targetDeliveryResponse, response.getParsingTime(), response.getResponseSize());
    return new ResponseStatus(response.getHttpResponse().getStatus(), response.getHttpResponse().getStatusText());
}
Also used : TimingTool(com.adobe.target.edge.client.utils.TimingTool) TargetDeliveryResponse(com.adobe.target.edge.client.model.TargetDeliveryResponse) ResponseStatus(com.adobe.target.edge.client.http.ResponseStatus) ResponseWrapper(com.adobe.target.edge.client.http.ResponseWrapper) Telemetry(com.adobe.target.delivery.v1.model.Telemetry)

Example 2 with Telemetry

use of com.adobe.target.delivery.v1.model.Telemetry in project target-java-sdk by adobe.

the class DefaultTargetService method executeRequestAsync.

@Override
public CompletableFuture<TargetDeliveryResponse> executeRequestAsync(TargetDeliveryRequest deliveryRequest) {
    TimingTool timer = new TimingTool();
    timer.timeStart(TIMING_EXECUTE_REQUEST);
    Telemetry telemetry = telemetryService.getTelemetry();
    if (!telemetry.getEntries().isEmpty()) {
        deliveryRequest.getDeliveryRequest().setTelemetry(telemetry);
    }
    CompletableFuture<ResponseWrapper<DeliveryResponse>> responseCompletableFuture = callDeliveryApiAsync(deliveryRequest);
    return responseCompletableFuture.thenApply(response -> {
        TargetDeliveryResponse targetDeliveryResponse = getTargetDeliveryResponse(deliveryRequest, response.getHttpResponse());
        telemetryService.addTelemetry(deliveryRequest, timer, targetDeliveryResponse, response.getParsingTime(), response.getResponseSize());
        return targetDeliveryResponse;
    });
}
Also used : TimingTool(com.adobe.target.edge.client.utils.TimingTool) TargetDeliveryResponse(com.adobe.target.edge.client.model.TargetDeliveryResponse) ResponseWrapper(com.adobe.target.edge.client.http.ResponseWrapper) Telemetry(com.adobe.target.delivery.v1.model.Telemetry)

Example 3 with Telemetry

use of com.adobe.target.delivery.v1.model.Telemetry in project target-java-sdk by adobe.

the class DefaultTargetService method executeNotificationAsync.

@Override
public CompletableFuture<ResponseStatus> executeNotificationAsync(TargetDeliveryRequest deliveryRequest) {
    TimingTool timer = new TimingTool();
    timer.timeStart(TIMING_EXECUTE_REQUEST);
    NotificationService.setBeaconToFalse(deliveryRequest.getDeliveryRequest());
    Telemetry telemetry = telemetryService.getTelemetry();
    if (!telemetry.getEntries().isEmpty()) {
        deliveryRequest.getDeliveryRequest().setTelemetry(telemetry);
    }
    CompletableFuture<ResponseWrapper<DeliveryResponse>> responseCompletableFuture = callDeliveryApiAsync(deliveryRequest);
    return responseCompletableFuture.thenApply(response -> {
        TargetDeliveryResponse targetDeliveryResponse = getTargetDeliveryResponse(deliveryRequest, response.getHttpResponse());
        telemetryService.addTelemetry(deliveryRequest, timer, targetDeliveryResponse, response.getParsingTime(), response.getResponseSize());
        return new ResponseStatus(response.getHttpResponse().getStatus(), response.getHttpResponse().getStatusText());
    });
}
Also used : TimingTool(com.adobe.target.edge.client.utils.TimingTool) TargetDeliveryResponse(com.adobe.target.edge.client.model.TargetDeliveryResponse) ResponseStatus(com.adobe.target.edge.client.http.ResponseStatus) ResponseWrapper(com.adobe.target.edge.client.http.ResponseWrapper) Telemetry(com.adobe.target.delivery.v1.model.Telemetry)

Example 4 with Telemetry

use of com.adobe.target.delivery.v1.model.Telemetry in project target-java-sdk by adobe.

the class TelemetryService method getTelemetry.

public Telemetry getTelemetry() {
    List<TelemetryEntry> telemetryEntryList = new ArrayList<>();
    TelemetryEntry telemetryEntry;
    while ((telemetryEntry = storedTelemetries.poll()) != null) {
        telemetryEntryList.add(telemetryEntry);
    }
    return new Telemetry().entries(telemetryEntryList);
}
Also used : ArrayList(java.util.ArrayList) TelemetryEntry(com.adobe.target.delivery.v1.model.TelemetryEntry) Telemetry(com.adobe.target.delivery.v1.model.Telemetry)

Example 5 with Telemetry

use of com.adobe.target.delivery.v1.model.Telemetry in project target-java-sdk by adobe.

the class TelemetryServiceTest method testTelemetryForServerSide.

/**
 * Test case to call get offers for server side, in first request we capture the telemetry & in
 * next call we send it with any getOffers() call or sendNotifications() call
 *
 * @throws NoSuchFieldException
 */
@Test
void testTelemetryForServerSide() throws NoSuchFieldException {
    setup(true, DecisioningMethod.SERVER_SIDE, "testTelemetryForServerSide");
    Context context = getContext();
    PrefetchRequest prefetchRequest = getPrefetchViewsRequest();
    ExecuteRequest executeRequest = getMboxExecuteRequest();
    String nonDefaultToken = "non-default-token";
    TargetDeliveryRequest targetDeliveryRequest = TargetDeliveryRequest.builder().context(context).prefetch(prefetchRequest).execute(executeRequest).property(new Property().token(nonDefaultToken)).decisioningMethod(DecisioningMethod.SERVER_SIDE).build();
    TargetDeliveryResponse targetDeliveryResponse1 = targetJavaClient.getOffers(targetDeliveryRequest);
    assertNull(targetDeliveryResponse1.getRequest().getTelemetry());
    // In next call we see telemetry data added to the deliveryRequest
    TargetDeliveryResponse targetDeliveryResponse2 = targetJavaClient.getOffers(targetDeliveryRequest);
    verify(telemetryServiceSpy, atLeast(2)).getTelemetry();
    verify(telemetryServiceSpy, times(2)).addTelemetry(any(TargetDeliveryRequest.class), any(TimingTool.class), any(TargetDeliveryResponse.class), any(Double.class), any(Long.class));
    assertEquals(1, telemetryServiceSpy.getTelemetry().getEntries().size());
    assertNotNull(targetDeliveryResponse2);
    assertNotNull(targetDeliveryResponse2.getRequest());
    assertNotNull(targetDeliveryResponse2.getRequest().getTelemetry());
    assertEquals(1, targetDeliveryResponse2.getRequest().getTelemetry().getEntries().size());
}
Also used : Context(com.adobe.target.delivery.v1.model.Context) TargetTestDeliveryRequestUtils.getContext(com.adobe.target.edge.client.utils.TargetTestDeliveryRequestUtils.getContext) PrefetchRequest(com.adobe.target.delivery.v1.model.PrefetchRequest) TargetTestDeliveryRequestUtils.getMboxExecuteRequest(com.adobe.target.edge.client.utils.TargetTestDeliveryRequestUtils.getMboxExecuteRequest) ExecuteRequest(com.adobe.target.delivery.v1.model.ExecuteRequest) TargetDeliveryResponse(com.adobe.target.edge.client.model.TargetDeliveryResponse) TimingTool(com.adobe.target.edge.client.utils.TimingTool) TargetDeliveryRequest(com.adobe.target.edge.client.model.TargetDeliveryRequest) Property(com.adobe.target.delivery.v1.model.Property) Test(org.junit.jupiter.api.Test)

Aggregations

Context (com.adobe.target.delivery.v1.model.Context)11 TargetDeliveryRequest (com.adobe.target.edge.client.model.TargetDeliveryRequest)11 TargetDeliveryResponse (com.adobe.target.edge.client.model.TargetDeliveryResponse)11 TargetTestDeliveryRequestUtils.getContext (com.adobe.target.edge.client.utils.TargetTestDeliveryRequestUtils.getContext)11 TimingTool (com.adobe.target.edge.client.utils.TimingTool)11 Test (org.junit.jupiter.api.Test)11 Telemetry (com.adobe.target.delivery.v1.model.Telemetry)10 ExecuteRequest (com.adobe.target.delivery.v1.model.ExecuteRequest)9 PrefetchRequest (com.adobe.target.delivery.v1.model.PrefetchRequest)9 TargetTestDeliveryRequestUtils.getMboxExecuteRequest (com.adobe.target.edge.client.utils.TargetTestDeliveryRequestUtils.getMboxExecuteRequest)9 MboxRequest (com.adobe.target.delivery.v1.model.MboxRequest)5 Property (com.adobe.target.delivery.v1.model.Property)4 TelemetryEntry (com.adobe.target.delivery.v1.model.TelemetryEntry)4 DeliveryResponse (com.adobe.target.delivery.v1.model.DeliveryResponse)3 ResponseWrapper (com.adobe.target.edge.client.http.ResponseWrapper)3 Notification (com.adobe.target.delivery.v1.model.Notification)2 ResponseStatus (com.adobe.target.edge.client.http.ResponseStatus)2 TargetTestDeliveryRequestUtils.getNoContentDeliveryResponse (com.adobe.target.edge.client.utils.TargetTestDeliveryRequestUtils.getNoContentDeliveryResponse)2 TargetTestDeliveryRequestUtils.getTestDeliveryResponse (com.adobe.target.edge.client.utils.TargetTestDeliveryRequestUtils.getTestDeliveryResponse)2 ArrayList (java.util.ArrayList)2