Search in sources :

Example 1 with DeleteObjectsResponse

use of software.amazon.awssdk.services.s3.model.DeleteObjectsResponse in project cwa-server by corona-warn-app.

the class S3ClientWrapperTest method removeObjectsThrowsOnDeletionErrors.

@Test
void removeObjectsThrowsOnDeletionErrors() {
    DeleteObjectsResponse actResponse = DeleteObjectsResponse.builder().errors(S3Error.builder().build()).build();
    when(s3Client.deleteObjects(any(DeleteObjectsRequest.class))).thenReturn(actResponse);
    List<String> targetObjects = List.of(VALID_NAME);
    assertThatExceptionOfType(ObjectStoreOperationFailedException.class).isThrownBy(() -> s3ClientWrapper.removeObjects(VALID_BUCKET_NAME, targetObjects));
}
Also used : DeleteObjectsResponse(software.amazon.awssdk.services.s3.model.DeleteObjectsResponse) DeleteObjectsRequest(software.amazon.awssdk.services.s3.model.DeleteObjectsRequest) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 2 with DeleteObjectsResponse

use of software.amazon.awssdk.services.s3.model.DeleteObjectsResponse in project newrelic-java-agent by newrelic.

the class S3AsyncClient_Instrumentation method deleteObjects.

public CompletableFuture<DeleteObjectsResponse> deleteObjects(DeleteObjectsRequest deleteObjectsRequest) {
    String uri = "s3://" + deleteObjectsRequest.bucket();
    Segment segment = NewRelic.getAgent().getTransaction().startSegment("S3", "deleteObjects");
    AgentBridge.getAgent().getTracedMethod().setTrackChildThreads(false);
    CompletableFuture<DeleteObjectsResponse> result = Weaver.callOriginal();
    return result.whenComplete(new S3ResponseResultWrapper<>(segment, uri, "deleteObjects"));
}
Also used : DeleteObjectsResponse(software.amazon.awssdk.services.s3.model.DeleteObjectsResponse) Segment(com.newrelic.api.agent.Segment)

Example 3 with DeleteObjectsResponse

use of software.amazon.awssdk.services.s3.model.DeleteObjectsResponse in project newrelic-java-agent by newrelic.

the class S3Client_Instrumentation method deleteObjects.

@Trace
public DeleteObjectsResponse deleteObjects(DeleteObjectsRequest deleteObjectsRequest) {
    String uri = "s3://" + deleteObjectsRequest.bucket();
    try {
        DeleteObjectsResponse deleteObjectsResponse = Weaver.callOriginal();
        S3MetricUtil.reportExternalMetrics(NewRelic.getAgent().getTracedMethod(), uri, deleteObjectsResponse, "deleteObjects");
        return deleteObjectsResponse;
    } catch (Exception e) {
        S3MetricUtil.reportExternalMetrics(NewRelic.getAgent().getTracedMethod(), uri, "deleteObjects");
        throw e;
    }
}
Also used : DeleteObjectsResponse(software.amazon.awssdk.services.s3.model.DeleteObjectsResponse) NoSuchKeyException(software.amazon.awssdk.services.s3.model.NoSuchKeyException) S3Exception(software.amazon.awssdk.services.s3.model.S3Exception) AwsServiceException(software.amazon.awssdk.awscore.exception.AwsServiceException) SdkClientException(software.amazon.awssdk.core.exception.SdkClientException) Trace(com.newrelic.api.agent.Trace)

Aggregations

DeleteObjectsResponse (software.amazon.awssdk.services.s3.model.DeleteObjectsResponse)3 Segment (com.newrelic.api.agent.Segment)1 Trace (com.newrelic.api.agent.Trace)1 Test (org.junit.jupiter.api.Test)1 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)1 AwsServiceException (software.amazon.awssdk.awscore.exception.AwsServiceException)1 SdkClientException (software.amazon.awssdk.core.exception.SdkClientException)1 DeleteObjectsRequest (software.amazon.awssdk.services.s3.model.DeleteObjectsRequest)1 NoSuchKeyException (software.amazon.awssdk.services.s3.model.NoSuchKeyException)1 S3Exception (software.amazon.awssdk.services.s3.model.S3Exception)1