Search in sources :

Example 41 with MetricPublisher

use of software.amazon.awssdk.metrics.MetricPublisher in project aws-sdk-java-v2 by aws.

the class AsyncClientMetricPublisherResolutionTest method testApiCall_publishersSetOnRequest_requestPublishersInvoked.

@Test
public void testApiCall_publishersSetOnRequest_requestPublishersInvoked() throws IOException {
    MetricPublisher publisher1 = mock(MetricPublisher.class);
    MetricPublisher publisher2 = mock(MetricPublisher.class);
    client = clientWithPublishers();
    try {
        client.allTypes(r -> r.overrideConfiguration(o -> o.addMetricPublisher(publisher1).addMetricPublisher(publisher2))).join();
    } catch (Throwable t) {
    // ignored, call fails because our mock HTTP client isn't set up
    } finally {
        verify(publisher1).publish(any(MetricCollection.class));
        verify(publisher2).publish(any(MetricCollection.class));
    }
}
Also used : ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) Arrays(java.util.Arrays) Mock(org.mockito.Mock) AwsCredentialsProvider(software.amazon.awssdk.auth.credentials.AwsCredentialsProvider) RunWith(org.junit.runner.RunWith) MetricPublisher(software.amazon.awssdk.metrics.MetricPublisher) WireMockRule(com.github.tomakehurst.wiremock.junit.WireMockRule) Mockito.verifyNoMoreInteractions(org.mockito.Mockito.verifyNoMoreInteractions) After(org.junit.After) URI(java.net.URI) Region(software.amazon.awssdk.regions.Region) ExpectedException(org.junit.rules.ExpectedException) Before(org.junit.Before) ProtocolRestJsonAsyncClientBuilder(software.amazon.awssdk.services.protocolrestjson.ProtocolRestJsonAsyncClientBuilder) MetricCollection(software.amazon.awssdk.metrics.MetricCollection) ProtocolRestJsonException(software.amazon.awssdk.services.protocolrestjson.model.ProtocolRestJsonException) IOException(java.io.IOException) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) Mockito.verify(org.mockito.Mockito.verify) Matchers.instanceOf(org.hamcrest.Matchers.instanceOf) Rule(org.junit.Rule) AwsBasicCredentials(software.amazon.awssdk.auth.credentials.AwsBasicCredentials) MockitoJUnitRunner(org.mockito.junit.MockitoJUnitRunner) ProtocolRestJsonAsyncClient(software.amazon.awssdk.services.protocolrestjson.ProtocolRestJsonAsyncClient) Mockito.mock(org.mockito.Mockito.mock) MetricCollection(software.amazon.awssdk.metrics.MetricCollection) MetricPublisher(software.amazon.awssdk.metrics.MetricPublisher) Test(org.junit.Test)

Example 42 with MetricPublisher

use of software.amazon.awssdk.metrics.MetricPublisher in project aws-sdk-java-v2 by aws.

the class AsyncCoreMetricsTest method testPaginatingApiCall_publisherOverriddenOnRequest_requestPublisherTakesPrecedence.

@Test
public void testPaginatingApiCall_publisherOverriddenOnRequest_requestPublisherTakesPrecedence() throws Exception {
    stubSuccessfulResponse();
    MetricPublisher requestMetricPublisher = mock(MetricPublisher.class);
    PaginatedOperationWithResultKeyPublisher paginatedPublisher = client.paginatedOperationWithResultKeyPaginator(r -> r.overrideConfiguration(o -> o.addMetricPublisher(requestMetricPublisher)));
    CompletableFuture<Void> future = paginatedPublisher.subscribe(PaginatedOperationWithResultKeyResponse::items);
    future.get();
    verify(requestMetricPublisher).publish(any(MetricCollection.class));
    verifyNoMoreInteractions(mockPublisher);
}
Also used : ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) Mock(org.mockito.Mock) AwsCredentialsProvider(software.amazon.awssdk.auth.credentials.AwsCredentialsProvider) PaginatedOperationWithResultKeyPublisher(software.amazon.awssdk.services.protocolrestjson.paginators.PaginatedOperationWithResultKeyPublisher) RunWith(org.junit.runner.RunWith) CompletableFuture(java.util.concurrent.CompletableFuture) Supplier(java.util.function.Supplier) ArrayList(java.util.ArrayList) MetricPublisher(software.amazon.awssdk.metrics.MetricPublisher) WireMockRule(com.github.tomakehurst.wiremock.junit.WireMockRule) Mockito.verifyNoMoreInteractions(org.mockito.Mockito.verifyNoMoreInteractions) After(org.junit.After) URI(java.net.URI) Region(software.amazon.awssdk.regions.Region) PaginatedOperationWithResultKeyResponse(software.amazon.awssdk.services.protocolrestjson.model.PaginatedOperationWithResultKeyResponse) Before(org.junit.Before) MetricCollection(software.amazon.awssdk.metrics.MetricCollection) IOException(java.io.IOException) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) PaginatedOperationWithResultKeyIterable(software.amazon.awssdk.services.protocolrestjson.paginators.PaginatedOperationWithResultKeyIterable) Collectors(java.util.stream.Collectors) Mockito.verify(org.mockito.Mockito.verify) ExecutionException(java.util.concurrent.ExecutionException) List(java.util.List) Rule(org.junit.Rule) SimpleStruct(software.amazon.awssdk.services.protocolrestjson.model.SimpleStruct) AwsBasicCredentials(software.amazon.awssdk.auth.credentials.AwsBasicCredentials) MockitoJUnitRunner(org.mockito.junit.MockitoJUnitRunner) ProtocolRestJsonAsyncClient(software.amazon.awssdk.services.protocolrestjson.ProtocolRestJsonAsyncClient) Mockito.mock(org.mockito.Mockito.mock) MetricCollection(software.amazon.awssdk.metrics.MetricCollection) MetricPublisher(software.amazon.awssdk.metrics.MetricPublisher) PaginatedOperationWithResultKeyResponse(software.amazon.awssdk.services.protocolrestjson.model.PaginatedOperationWithResultKeyResponse) PaginatedOperationWithResultKeyPublisher(software.amazon.awssdk.services.protocolrestjson.paginators.PaginatedOperationWithResultKeyPublisher) Test(org.junit.Test)

Example 43 with MetricPublisher

use of software.amazon.awssdk.metrics.MetricPublisher in project aws-sdk-java-v2 by aws.

the class DefaultClientBuilderTest method buildIncludesClientOverrides.

@Test
public void buildIncludesClientOverrides() {
    List<ExecutionInterceptor> interceptors = new ArrayList<>();
    ExecutionInterceptor interceptor = new ExecutionInterceptor() {
    };
    interceptors.add(interceptor);
    RetryPolicy retryPolicy = RetryPolicy.builder().build();
    Map<String, List<String>> headers = new HashMap<>();
    List<String> headerValues = new ArrayList<>();
    headerValues.add("value");
    headers.put("client-override-test", headerValues);
    List<MetricPublisher> metricPublishers = new ArrayList<>();
    MetricPublisher metricPublisher = new MetricPublisher() {

        @Override
        public void publish(MetricCollection metricCollection) {
        }

        @Override
        public void close() {
        }
    };
    metricPublishers.add(metricPublisher);
    ExecutionAttribute<String> execAttribute = new ExecutionAttribute<>("test");
    ExecutionAttributes executionAttributes = ExecutionAttributes.builder().put(execAttribute, "value").build();
    Signer signer = (request, execAttributes) -> request;
    String suffix = "suffix";
    String prefix = "prefix";
    Duration apiCallTimeout = Duration.ofMillis(42);
    Duration apiCallAttemptTimeout = Duration.ofMillis(43);
    ProfileFile profileFile = ProfileFile.builder().content(new StringInputStream("")).type(ProfileFile.Type.CONFIGURATION).build();
    String profileName = "name";
    ClientOverrideConfiguration overrideConfig = ClientOverrideConfiguration.builder().executionInterceptors(interceptors).retryPolicy(retryPolicy).headers(headers).putAdvancedOption(SIGNER, signer).putAdvancedOption(USER_AGENT_SUFFIX, suffix).putAdvancedOption(USER_AGENT_PREFIX, prefix).apiCallTimeout(apiCallTimeout).apiCallAttemptTimeout(apiCallAttemptTimeout).putAdvancedOption(DISABLE_HOST_PREFIX_INJECTION, Boolean.TRUE).defaultProfileFile(profileFile).defaultProfileName(profileName).metricPublishers(metricPublishers).executionAttributes(executionAttributes).putAdvancedOption(ENDPOINT_OVERRIDDEN_OVERRIDE, Boolean.TRUE).build();
    SdkClientConfiguration config = testClientBuilder().overrideConfiguration(overrideConfig).build().clientConfiguration;
    assertThat(config.option(EXECUTION_INTERCEPTORS)).contains(interceptor);
    assertThat(config.option(RETRY_POLICY)).isEqualTo(retryPolicy);
    assertThat(config.option(ADDITIONAL_HTTP_HEADERS).get("client-override-test")).isEqualTo(headerValues);
    assertThat(config.option(SIGNER)).isEqualTo(signer);
    assertThat(config.option(USER_AGENT_SUFFIX)).isEqualTo(suffix);
    assertThat(config.option(USER_AGENT_PREFIX)).isEqualTo(prefix);
    assertThat(config.option(API_CALL_TIMEOUT)).isEqualTo(apiCallTimeout);
    assertThat(config.option(API_CALL_ATTEMPT_TIMEOUT)).isEqualTo(apiCallAttemptTimeout);
    assertThat(config.option(DISABLE_HOST_PREFIX_INJECTION)).isEqualTo(Boolean.TRUE);
    assertThat(config.option(PROFILE_FILE)).isEqualTo(profileFile);
    assertThat(config.option(PROFILE_NAME)).isEqualTo(profileName);
    assertThat(config.option(METRIC_PUBLISHERS)).contains(metricPublisher);
    assertThat(config.option(EXECUTION_ATTRIBUTES).getAttribute(execAttribute)).isEqualTo("value");
    assertThat(config.option(ENDPOINT_OVERRIDDEN)).isEqualTo(Boolean.TRUE);
}
Also used : ProfileFile(software.amazon.awssdk.profiles.ProfileFile) Arrays(java.util.Arrays) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) AttributeMap(software.amazon.awssdk.utils.AttributeMap) ADDITIONAL_HTTP_HEADERS(software.amazon.awssdk.core.client.config.SdkClientOption.ADDITIONAL_HTTP_HEADERS) NoOpSigner(software.amazon.awssdk.core.signer.NoOpSigner) MetricPublisher(software.amazon.awssdk.metrics.MetricPublisher) Duration(java.time.Duration) Map(java.util.Map) Assertions(org.assertj.core.api.Assertions) SdkClientOption(software.amazon.awssdk.core.client.config.SdkClientOption) URI(java.net.URI) Method(java.lang.reflect.Method) RETRY_POLICY(software.amazon.awssdk.core.client.config.SdkClientOption.RETRY_POLICY) MetricCollection(software.amazon.awssdk.metrics.MetricCollection) ExecutionInterceptor(software.amazon.awssdk.core.interceptor.ExecutionInterceptor) List(java.util.List) StringInputStream(software.amazon.awssdk.utils.StringInputStream) PropertyDescriptor(java.beans.PropertyDescriptor) Optional(java.util.Optional) API_CALL_ATTEMPT_TIMEOUT(software.amazon.awssdk.core.client.config.SdkClientOption.API_CALL_ATTEMPT_TIMEOUT) MockitoJUnitRunner(org.mockito.junit.MockitoJUnitRunner) Mockito.mock(org.mockito.Mockito.mock) Signer(software.amazon.awssdk.core.signer.Signer) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) Mock(org.mockito.Mock) RunWith(org.junit.runner.RunWith) HashMap(java.util.HashMap) SdkClientConfiguration(software.amazon.awssdk.core.client.config.SdkClientConfiguration) SdkAdvancedClientOption(software.amazon.awssdk.core.client.config.SdkAdvancedClientOption) ArrayList(java.util.ArrayList) Introspector(java.beans.Introspector) Assertions.assertThatThrownBy(org.assertj.core.api.Assertions.assertThatThrownBy) METRIC_PUBLISHERS(software.amazon.awssdk.core.client.config.SdkClientOption.METRIC_PUBLISHERS) PROFILE_NAME(software.amazon.awssdk.core.client.config.SdkClientOption.PROFILE_NAME) BeanInfo(java.beans.BeanInfo) PROFILE_FILE(software.amazon.awssdk.core.client.config.SdkClientOption.PROFILE_FILE) ExecutionAttribute(software.amazon.awssdk.core.interceptor.ExecutionAttribute) ExecutionAttributes(software.amazon.awssdk.core.interceptor.ExecutionAttributes) SdkAsyncHttpClient(software.amazon.awssdk.http.async.SdkAsyncHttpClient) EXECUTION_INTERCEPTORS(software.amazon.awssdk.core.client.config.SdkClientOption.EXECUTION_INTERCEPTORS) Before(org.junit.Before) USER_AGENT_PREFIX(software.amazon.awssdk.core.client.config.SdkAdvancedClientOption.USER_AGENT_PREFIX) ENDPOINT_OVERRIDDEN(software.amazon.awssdk.core.client.config.SdkClientOption.ENDPOINT_OVERRIDDEN) API_CALL_TIMEOUT(software.amazon.awssdk.core.client.config.SdkClientOption.API_CALL_TIMEOUT) Mockito.times(org.mockito.Mockito.times) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) SdkHttpClient(software.amazon.awssdk.http.SdkHttpClient) ENDPOINT_OVERRIDDEN_OVERRIDE(software.amazon.awssdk.core.internal.SdkInternalTestAdvancedClientOption.ENDPOINT_OVERRIDDEN_OVERRIDE) SdkHttpConfigurationOption(software.amazon.awssdk.http.SdkHttpConfigurationOption) USER_AGENT_SUFFIX(software.amazon.awssdk.core.client.config.SdkAdvancedClientOption.USER_AGENT_SUFFIX) Mockito.verify(org.mockito.Mockito.verify) SIGNER(software.amazon.awssdk.core.client.config.SdkAdvancedClientOption.SIGNER) EXECUTION_ATTRIBUTES(software.amazon.awssdk.core.client.config.SdkClientOption.EXECUTION_ATTRIBUTES) Mockito.never(org.mockito.Mockito.never) RetryPolicy(software.amazon.awssdk.core.retry.RetryPolicy) RetryMode(software.amazon.awssdk.core.retry.RetryMode) DISABLE_HOST_PREFIX_INJECTION(software.amazon.awssdk.core.client.config.SdkAdvancedClientOption.DISABLE_HOST_PREFIX_INJECTION) ClientOverrideConfiguration(software.amazon.awssdk.core.client.config.ClientOverrideConfiguration) ExecutionAttributes(software.amazon.awssdk.core.interceptor.ExecutionAttributes) SdkClientConfiguration(software.amazon.awssdk.core.client.config.SdkClientConfiguration) HashMap(java.util.HashMap) ClientOverrideConfiguration(software.amazon.awssdk.core.client.config.ClientOverrideConfiguration) ExecutionAttribute(software.amazon.awssdk.core.interceptor.ExecutionAttribute) ArrayList(java.util.ArrayList) MetricPublisher(software.amazon.awssdk.metrics.MetricPublisher) ExecutionInterceptor(software.amazon.awssdk.core.interceptor.ExecutionInterceptor) Duration(java.time.Duration) MetricCollection(software.amazon.awssdk.metrics.MetricCollection) NoOpSigner(software.amazon.awssdk.core.signer.NoOpSigner) Signer(software.amazon.awssdk.core.signer.Signer) StringInputStream(software.amazon.awssdk.utils.StringInputStream) List(java.util.List) ArrayList(java.util.ArrayList) RetryPolicy(software.amazon.awssdk.core.retry.RetryPolicy) ProfileFile(software.amazon.awssdk.profiles.ProfileFile) Test(org.junit.Test)

Example 44 with MetricPublisher

use of software.amazon.awssdk.metrics.MetricPublisher in project aws-sdk-java-v2 by aws.

the class DefaultClientBuilderTest method overrideConfigurationReturnsSetValues.

@Test
public void overrideConfigurationReturnsSetValues() {
    List<ExecutionInterceptor> interceptors = new ArrayList<>();
    RetryPolicy retryPolicy = RetryPolicy.builder().build();
    Map<String, List<String>> headers = new HashMap<>();
    List<MetricPublisher> metricPublishers = new ArrayList<>();
    ExecutionAttributes executionAttributes = new ExecutionAttributes();
    Signer signer = (request, execAttributes) -> request;
    String suffix = "suffix";
    String prefix = "prefix";
    Duration apiCallTimeout = Duration.ofMillis(42);
    Duration apiCallAttemptTimeout = Duration.ofMillis(43);
    ProfileFile profileFile = ProfileFile.builder().content(new StringInputStream("")).type(ProfileFile.Type.CONFIGURATION).build();
    String profileName = "name";
    ClientOverrideConfiguration overrideConfig = ClientOverrideConfiguration.builder().executionInterceptors(interceptors).retryPolicy(retryPolicy).headers(headers).putAdvancedOption(SIGNER, signer).putAdvancedOption(USER_AGENT_SUFFIX, suffix).putAdvancedOption(USER_AGENT_PREFIX, prefix).apiCallTimeout(apiCallTimeout).apiCallAttemptTimeout(apiCallAttemptTimeout).putAdvancedOption(DISABLE_HOST_PREFIX_INJECTION, Boolean.TRUE).defaultProfileFile(profileFile).defaultProfileName(profileName).metricPublishers(metricPublishers).executionAttributes(executionAttributes).putAdvancedOption(ENDPOINT_OVERRIDDEN_OVERRIDE, Boolean.TRUE).build();
    TestClientBuilder builder = testClientBuilder().overrideConfiguration(overrideConfig);
    ClientOverrideConfiguration builderOverrideConfig = builder.overrideConfiguration();
    assertThat(builderOverrideConfig.executionInterceptors()).isEqualTo(interceptors);
    assertThat(builderOverrideConfig.retryPolicy()).isEqualTo(Optional.of(retryPolicy));
    assertThat(builderOverrideConfig.headers()).isEqualTo(headers);
    assertThat(builderOverrideConfig.advancedOption(SIGNER)).isEqualTo(Optional.of(signer));
    assertThat(builderOverrideConfig.advancedOption(USER_AGENT_SUFFIX)).isEqualTo(Optional.of(suffix));
    assertThat(builderOverrideConfig.apiCallTimeout()).isEqualTo(Optional.of(apiCallTimeout));
    assertThat(builderOverrideConfig.apiCallAttemptTimeout()).isEqualTo(Optional.of(apiCallAttemptTimeout));
    assertThat(builderOverrideConfig.advancedOption(DISABLE_HOST_PREFIX_INJECTION)).isEqualTo(Optional.of(Boolean.TRUE));
    assertThat(builderOverrideConfig.defaultProfileFile()).isEqualTo(Optional.of(profileFile));
    assertThat(builderOverrideConfig.defaultProfileName()).isEqualTo(Optional.of(profileName));
    assertThat(builderOverrideConfig.metricPublishers()).isEqualTo(metricPublishers);
    assertThat(builderOverrideConfig.executionAttributes().getAttributes()).isEqualTo(executionAttributes.getAttributes());
    assertThat(builderOverrideConfig.advancedOption(ENDPOINT_OVERRIDDEN_OVERRIDE)).isEqualTo(Optional.of(Boolean.TRUE));
}
Also used : ProfileFile(software.amazon.awssdk.profiles.ProfileFile) Arrays(java.util.Arrays) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) AttributeMap(software.amazon.awssdk.utils.AttributeMap) ADDITIONAL_HTTP_HEADERS(software.amazon.awssdk.core.client.config.SdkClientOption.ADDITIONAL_HTTP_HEADERS) NoOpSigner(software.amazon.awssdk.core.signer.NoOpSigner) MetricPublisher(software.amazon.awssdk.metrics.MetricPublisher) Duration(java.time.Duration) Map(java.util.Map) Assertions(org.assertj.core.api.Assertions) SdkClientOption(software.amazon.awssdk.core.client.config.SdkClientOption) URI(java.net.URI) Method(java.lang.reflect.Method) RETRY_POLICY(software.amazon.awssdk.core.client.config.SdkClientOption.RETRY_POLICY) MetricCollection(software.amazon.awssdk.metrics.MetricCollection) ExecutionInterceptor(software.amazon.awssdk.core.interceptor.ExecutionInterceptor) List(java.util.List) StringInputStream(software.amazon.awssdk.utils.StringInputStream) PropertyDescriptor(java.beans.PropertyDescriptor) Optional(java.util.Optional) API_CALL_ATTEMPT_TIMEOUT(software.amazon.awssdk.core.client.config.SdkClientOption.API_CALL_ATTEMPT_TIMEOUT) MockitoJUnitRunner(org.mockito.junit.MockitoJUnitRunner) Mockito.mock(org.mockito.Mockito.mock) Signer(software.amazon.awssdk.core.signer.Signer) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) Mock(org.mockito.Mock) RunWith(org.junit.runner.RunWith) HashMap(java.util.HashMap) SdkClientConfiguration(software.amazon.awssdk.core.client.config.SdkClientConfiguration) SdkAdvancedClientOption(software.amazon.awssdk.core.client.config.SdkAdvancedClientOption) ArrayList(java.util.ArrayList) Introspector(java.beans.Introspector) Assertions.assertThatThrownBy(org.assertj.core.api.Assertions.assertThatThrownBy) METRIC_PUBLISHERS(software.amazon.awssdk.core.client.config.SdkClientOption.METRIC_PUBLISHERS) PROFILE_NAME(software.amazon.awssdk.core.client.config.SdkClientOption.PROFILE_NAME) BeanInfo(java.beans.BeanInfo) PROFILE_FILE(software.amazon.awssdk.core.client.config.SdkClientOption.PROFILE_FILE) ExecutionAttribute(software.amazon.awssdk.core.interceptor.ExecutionAttribute) ExecutionAttributes(software.amazon.awssdk.core.interceptor.ExecutionAttributes) SdkAsyncHttpClient(software.amazon.awssdk.http.async.SdkAsyncHttpClient) EXECUTION_INTERCEPTORS(software.amazon.awssdk.core.client.config.SdkClientOption.EXECUTION_INTERCEPTORS) Before(org.junit.Before) USER_AGENT_PREFIX(software.amazon.awssdk.core.client.config.SdkAdvancedClientOption.USER_AGENT_PREFIX) ENDPOINT_OVERRIDDEN(software.amazon.awssdk.core.client.config.SdkClientOption.ENDPOINT_OVERRIDDEN) API_CALL_TIMEOUT(software.amazon.awssdk.core.client.config.SdkClientOption.API_CALL_TIMEOUT) Mockito.times(org.mockito.Mockito.times) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) SdkHttpClient(software.amazon.awssdk.http.SdkHttpClient) ENDPOINT_OVERRIDDEN_OVERRIDE(software.amazon.awssdk.core.internal.SdkInternalTestAdvancedClientOption.ENDPOINT_OVERRIDDEN_OVERRIDE) SdkHttpConfigurationOption(software.amazon.awssdk.http.SdkHttpConfigurationOption) USER_AGENT_SUFFIX(software.amazon.awssdk.core.client.config.SdkAdvancedClientOption.USER_AGENT_SUFFIX) Mockito.verify(org.mockito.Mockito.verify) SIGNER(software.amazon.awssdk.core.client.config.SdkAdvancedClientOption.SIGNER) EXECUTION_ATTRIBUTES(software.amazon.awssdk.core.client.config.SdkClientOption.EXECUTION_ATTRIBUTES) Mockito.never(org.mockito.Mockito.never) RetryPolicy(software.amazon.awssdk.core.retry.RetryPolicy) RetryMode(software.amazon.awssdk.core.retry.RetryMode) DISABLE_HOST_PREFIX_INJECTION(software.amazon.awssdk.core.client.config.SdkAdvancedClientOption.DISABLE_HOST_PREFIX_INJECTION) ClientOverrideConfiguration(software.amazon.awssdk.core.client.config.ClientOverrideConfiguration) ExecutionAttributes(software.amazon.awssdk.core.interceptor.ExecutionAttributes) HashMap(java.util.HashMap) ClientOverrideConfiguration(software.amazon.awssdk.core.client.config.ClientOverrideConfiguration) ArrayList(java.util.ArrayList) MetricPublisher(software.amazon.awssdk.metrics.MetricPublisher) ExecutionInterceptor(software.amazon.awssdk.core.interceptor.ExecutionInterceptor) Duration(java.time.Duration) NoOpSigner(software.amazon.awssdk.core.signer.NoOpSigner) Signer(software.amazon.awssdk.core.signer.Signer) StringInputStream(software.amazon.awssdk.utils.StringInputStream) List(java.util.List) ArrayList(java.util.ArrayList) RetryPolicy(software.amazon.awssdk.core.retry.RetryPolicy) ProfileFile(software.amazon.awssdk.profiles.ProfileFile) Test(org.junit.Test)

Example 45 with MetricPublisher

use of software.amazon.awssdk.metrics.MetricPublisher in project aws-sdk-java-v2 by aws.

the class RequestOverrideConfigurationTest method addMetricPublisher_listPreviouslyAdded_appendedToList.

@Test
public void addMetricPublisher_listPreviouslyAdded_appendedToList() {
    List<MetricPublisher> publishers = new ArrayList<>();
    publishers.add(mock(MetricPublisher.class));
    publishers.add(mock(MetricPublisher.class));
    MetricPublisher thirdAdded = mock(MetricPublisher.class);
    SdkRequestOverrideConfiguration.Builder builder = SdkRequestOverrideConfiguration.builder();
    builder.metricPublishers(publishers);
    builder.addMetricPublisher(thirdAdded);
    SdkRequestOverrideConfiguration overrideConfig = builder.build();
    assertThat(overrideConfig.metricPublishers()).containsExactly(publishers.get(0), publishers.get(1), thirdAdded);
}
Also used : ArrayList(java.util.ArrayList) MetricPublisher(software.amazon.awssdk.metrics.MetricPublisher) Test(org.junit.jupiter.api.Test)

Aggregations

MetricPublisher (software.amazon.awssdk.metrics.MetricPublisher)80 MetricCollector (software.amazon.awssdk.metrics.MetricCollector)64 NoOpMetricCollector (software.amazon.awssdk.metrics.NoOpMetricCollector)64 AwsServiceException (software.amazon.awssdk.awscore.exception.AwsServiceException)59 ClientExecutionParams (software.amazon.awssdk.core.client.handler.ClientExecutionParams)47 List (java.util.List)40 CompletableFuture (java.util.concurrent.CompletableFuture)36 SdkClientConfiguration (software.amazon.awssdk.core.client.config.SdkClientConfiguration)36 SdkClientOption (software.amazon.awssdk.core.client.config.SdkClientOption)36 CoreMetric (software.amazon.awssdk.core.metrics.CoreMetric)36 JsonOperationMetadata (software.amazon.awssdk.protocols.json.JsonOperationMetadata)35 Collections (java.util.Collections)34 Logger (org.slf4j.Logger)34 LoggerFactory (org.slf4j.LoggerFactory)34 Generated (software.amazon.awssdk.annotations.Generated)34 SdkInternalApi (software.amazon.awssdk.annotations.SdkInternalApi)34 AwsAsyncClientHandler (software.amazon.awssdk.awscore.client.handler.AwsAsyncClientHandler)34 RequestOverrideConfiguration (software.amazon.awssdk.core.RequestOverrideConfiguration)34 AsyncClientHandler (software.amazon.awssdk.core.client.handler.AsyncClientHandler)34 HttpResponseHandler (software.amazon.awssdk.core.http.HttpResponseHandler)34