Add feed response statistics (#468)
* Added consistent and better exception handling, Added reactive repository integration test. Fixed few API bugs * Added request charnge and activity id as part of ResponseDiagnostics using CosmosResponseStatistics * Updated innerException to CosmosClientException * Updated the instance fields to final
This commit is contained in:
Родитель
8c240abc91
Коммит
0449d5acc8
|
@ -46,16 +46,19 @@ public class CosmosdbUtils {
|
||||||
cosmosResponseDiagnostics = cosmosResponse.cosmosResponseDiagnosticsString();
|
cosmosResponseDiagnostics = cosmosResponse.cosmosResponseDiagnosticsString();
|
||||||
}
|
}
|
||||||
FeedResponseDiagnostics feedResponseDiagnostics = null;
|
FeedResponseDiagnostics feedResponseDiagnostics = null;
|
||||||
|
ResponseDiagnostics.CosmosResponseStatistics cosmosResponseStatistics = null;
|
||||||
if (feedResponse != null) {
|
if (feedResponse != null) {
|
||||||
feedResponseDiagnostics = feedResponse.feedResponseDiagnostics();
|
feedResponseDiagnostics = feedResponse.feedResponseDiagnostics();
|
||||||
|
cosmosResponseStatistics = new ResponseDiagnostics.CosmosResponseStatistics(feedResponse);
|
||||||
}
|
}
|
||||||
if (cosmosResponseDiagnostics == null &&
|
if (cosmosResponseDiagnostics == null &&
|
||||||
(feedResponseDiagnostics == null || feedResponseDiagnostics.toString().isEmpty())) {
|
(feedResponseDiagnostics == null || feedResponseDiagnostics.toString().isEmpty()) &&
|
||||||
|
cosmosResponseStatistics == null) {
|
||||||
log.debug("Empty response diagnostics");
|
log.debug("Empty response diagnostics");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final ResponseDiagnostics responseDiagnostics =
|
final ResponseDiagnostics responseDiagnostics =
|
||||||
new ResponseDiagnostics(cosmosResponseDiagnostics, feedResponseDiagnostics);
|
new ResponseDiagnostics(cosmosResponseDiagnostics, feedResponseDiagnostics, cosmosResponseStatistics);
|
||||||
|
|
||||||
// Process response diagnostics
|
// Process response diagnostics
|
||||||
responseDiagnosticsProcessor.processResponseDiagnostics(responseDiagnostics);
|
responseDiagnosticsProcessor.processResponseDiagnostics(responseDiagnostics);
|
||||||
|
|
|
@ -7,18 +7,33 @@
|
||||||
package com.microsoft.azure.spring.data.cosmosdb.core;
|
package com.microsoft.azure.spring.data.cosmosdb.core;
|
||||||
|
|
||||||
import com.azure.data.cosmos.CosmosResponseDiagnostics;
|
import com.azure.data.cosmos.CosmosResponseDiagnostics;
|
||||||
|
import com.azure.data.cosmos.FeedResponse;
|
||||||
import com.azure.data.cosmos.FeedResponseDiagnostics;
|
import com.azure.data.cosmos.FeedResponseDiagnostics;
|
||||||
import lombok.AllArgsConstructor;
|
import com.azure.data.cosmos.Resource;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
@AllArgsConstructor
|
|
||||||
public class ResponseDiagnostics {
|
public class ResponseDiagnostics {
|
||||||
|
|
||||||
private CosmosResponseDiagnostics cosmosResponseDiagnostics;
|
private CosmosResponseDiagnostics cosmosResponseDiagnostics;
|
||||||
private FeedResponseDiagnostics feedResponseDiagnostics;
|
private FeedResponseDiagnostics feedResponseDiagnostics;
|
||||||
|
private CosmosResponseStatistics cosmosResponseStatistics;
|
||||||
|
|
||||||
|
public ResponseDiagnostics(CosmosResponseDiagnostics cosmosResponseDiagnostics,
|
||||||
|
FeedResponseDiagnostics feedResponseDiagnostics) {
|
||||||
|
this.cosmosResponseDiagnostics = cosmosResponseDiagnostics;
|
||||||
|
this.feedResponseDiagnostics = feedResponseDiagnostics;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ResponseDiagnostics(CosmosResponseDiagnostics cosmosResponseDiagnostics,
|
||||||
|
FeedResponseDiagnostics feedResponseDiagnostics,
|
||||||
|
CosmosResponseStatistics cosmosResponseStatistics) {
|
||||||
|
this.cosmosResponseDiagnostics = cosmosResponseDiagnostics;
|
||||||
|
this.feedResponseDiagnostics = feedResponseDiagnostics;
|
||||||
|
this.cosmosResponseStatistics = cosmosResponseStatistics;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
|
@ -29,10 +44,41 @@ public class ResponseDiagnostics {
|
||||||
.append("}");
|
.append("}");
|
||||||
}
|
}
|
||||||
if (feedResponseDiagnostics != null) {
|
if (feedResponseDiagnostics != null) {
|
||||||
|
if (diagnostics.length() != 0) {
|
||||||
|
diagnostics.append(", ");
|
||||||
|
}
|
||||||
diagnostics.append("feedResponseDiagnostics={")
|
diagnostics.append("feedResponseDiagnostics={")
|
||||||
.append(feedResponseDiagnostics)
|
.append(feedResponseDiagnostics)
|
||||||
.append("}");
|
.append("}");
|
||||||
}
|
}
|
||||||
|
if (cosmosResponseStatistics != null) {
|
||||||
|
if (diagnostics.length() != 0) {
|
||||||
|
diagnostics.append(", ");
|
||||||
|
}
|
||||||
|
diagnostics.append("cosmosResponseStatistics={")
|
||||||
|
.append(cosmosResponseStatistics)
|
||||||
|
.append("}");
|
||||||
|
}
|
||||||
return diagnostics.toString();
|
return diagnostics.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
public static class CosmosResponseStatistics {
|
||||||
|
|
||||||
|
private final double requestCharge;
|
||||||
|
private final String activityId;
|
||||||
|
|
||||||
|
public <T extends Resource> CosmosResponseStatistics(FeedResponse<T> feedResponse) {
|
||||||
|
this.requestCharge = feedResponse.requestCharge();
|
||||||
|
this.activityId = feedResponse.activityId();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "CosmosResponseStatistics{" +
|
||||||
|
"requestCharge=" + requestCharge +
|
||||||
|
", activityId='" + activityId + '\'' +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,4 +33,8 @@ public class ResponseDiagnosticsTestUtils {
|
||||||
public FeedResponseDiagnostics getFeedResponseDiagnostics() {
|
public FeedResponseDiagnostics getFeedResponseDiagnostics() {
|
||||||
return diagnostics == null ? null : diagnostics.getFeedResponseDiagnostics();
|
return diagnostics == null ? null : diagnostics.getFeedResponseDiagnostics();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ResponseDiagnostics.CosmosResponseStatistics getCosmosResponseStatistics() {
|
||||||
|
return diagnostics == null ? null : diagnostics.getCosmosResponseStatistics();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -140,6 +140,8 @@ public class CosmosTemplateIT {
|
||||||
assertThat(result.size()).isEqualTo(1);
|
assertThat(result.size()).isEqualTo(1);
|
||||||
assertThat(result.get(0)).isEqualTo(TEST_PERSON);
|
assertThat(result.get(0)).isEqualTo(TEST_PERSON);
|
||||||
assertThat(responseDiagnosticsTestUtils.getFeedResponseDiagnostics()).isNotNull();
|
assertThat(responseDiagnosticsTestUtils.getFeedResponseDiagnostics()).isNotNull();
|
||||||
|
assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNotNull();
|
||||||
|
assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics().getRequestCharge()).isGreaterThan(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -148,6 +150,8 @@ public class CosmosTemplateIT {
|
||||||
TEST_PERSON.getId(), Person.class);
|
TEST_PERSON.getId(), Person.class);
|
||||||
assertEquals(result, TEST_PERSON);
|
assertEquals(result, TEST_PERSON);
|
||||||
assertThat(responseDiagnosticsTestUtils.getFeedResponseDiagnostics()).isNotNull();
|
assertThat(responseDiagnosticsTestUtils.getFeedResponseDiagnostics()).isNotNull();
|
||||||
|
assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNotNull();
|
||||||
|
assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics().getRequestCharge()).isGreaterThan(0);
|
||||||
|
|
||||||
final Person nullResult = cosmosTemplate.findById(Person.class.getSimpleName(),
|
final Person nullResult = cosmosTemplate.findById(Person.class.getSimpleName(),
|
||||||
NOT_EXIST_ID, Person.class);
|
NOT_EXIST_ID, Person.class);
|
||||||
|
@ -165,6 +169,8 @@ public class CosmosTemplateIT {
|
||||||
final List<Person> result = cosmosTemplate.findByIds(ids, Person.class, collectionName);
|
final List<Person> result = cosmosTemplate.findByIds(ids, Person.class, collectionName);
|
||||||
|
|
||||||
assertThat(responseDiagnosticsTestUtils.getFeedResponseDiagnostics()).isNotNull();
|
assertThat(responseDiagnosticsTestUtils.getFeedResponseDiagnostics()).isNotNull();
|
||||||
|
assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNotNull();
|
||||||
|
assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics().getRequestCharge()).isGreaterThan(0);
|
||||||
|
|
||||||
final List<Person> expected = Lists.newArrayList(TEST_PERSON, TEST_PERSON_2, TEST_PERSON_3);
|
final List<Person> expected = Lists.newArrayList(TEST_PERSON, TEST_PERSON_2, TEST_PERSON_3);
|
||||||
assertThat(result.size()).isEqualTo(expected.size());
|
assertThat(result.size()).isEqualTo(expected.size());
|
||||||
|
@ -186,10 +192,13 @@ public class CosmosTemplateIT {
|
||||||
|
|
||||||
assertThat(responseDiagnosticsTestUtils.getCosmosResponseDiagnostics()).isNotNull();
|
assertThat(responseDiagnosticsTestUtils.getCosmosResponseDiagnostics()).isNotNull();
|
||||||
assertThat(responseDiagnosticsTestUtils.getFeedResponseDiagnostics()).isNull();
|
assertThat(responseDiagnosticsTestUtils.getFeedResponseDiagnostics()).isNull();
|
||||||
|
assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNull();
|
||||||
|
|
||||||
final List<Person> result = cosmosTemplate.findAll(Person.class);
|
final List<Person> result = cosmosTemplate.findAll(Person.class);
|
||||||
|
|
||||||
assertThat(responseDiagnosticsTestUtils.getFeedResponseDiagnostics()).isNotNull();
|
assertThat(responseDiagnosticsTestUtils.getFeedResponseDiagnostics()).isNotNull();
|
||||||
|
assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNotNull();
|
||||||
|
assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics().getRequestCharge()).isGreaterThan(0);
|
||||||
|
|
||||||
assertThat(result.size()).isEqualTo(1);
|
assertThat(result.size()).isEqualTo(1);
|
||||||
assertEquals(result.get(0).getFirstName(), firstName);
|
assertEquals(result.get(0).getFirstName(), firstName);
|
||||||
|
@ -205,11 +214,14 @@ public class CosmosTemplateIT {
|
||||||
|
|
||||||
assertThat(responseDiagnosticsTestUtils.getCosmosResponseDiagnostics()).isNotNull();
|
assertThat(responseDiagnosticsTestUtils.getCosmosResponseDiagnostics()).isNotNull();
|
||||||
assertThat(responseDiagnosticsTestUtils.getFeedResponseDiagnostics()).isNull();
|
assertThat(responseDiagnosticsTestUtils.getFeedResponseDiagnostics()).isNull();
|
||||||
|
assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNull();
|
||||||
|
|
||||||
final Person result = cosmosTemplate.findById(Person.class.getSimpleName(),
|
final Person result = cosmosTemplate.findById(Person.class.getSimpleName(),
|
||||||
updated.getId(), Person.class);
|
updated.getId(), Person.class);
|
||||||
|
|
||||||
assertThat(responseDiagnosticsTestUtils.getFeedResponseDiagnostics()).isNotNull();
|
assertThat(responseDiagnosticsTestUtils.getFeedResponseDiagnostics()).isNotNull();
|
||||||
|
assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNotNull();
|
||||||
|
assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics().getRequestCharge()).isGreaterThan(0);
|
||||||
|
|
||||||
assertEquals(result, updated);
|
assertEquals(result, updated);
|
||||||
}
|
}
|
||||||
|
@ -247,10 +259,13 @@ public class CosmosTemplateIT {
|
||||||
|
|
||||||
assertThat(responseDiagnosticsTestUtils.getCosmosResponseDiagnostics()).isNotNull();
|
assertThat(responseDiagnosticsTestUtils.getCosmosResponseDiagnostics()).isNotNull();
|
||||||
assertThat(responseDiagnosticsTestUtils.getFeedResponseDiagnostics()).isNull();
|
assertThat(responseDiagnosticsTestUtils.getFeedResponseDiagnostics()).isNull();
|
||||||
|
assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNull();
|
||||||
|
|
||||||
final List<Person> result = cosmosTemplate.findAll(Person.class);
|
final List<Person> result = cosmosTemplate.findAll(Person.class);
|
||||||
|
|
||||||
assertThat(responseDiagnosticsTestUtils.getFeedResponseDiagnostics()).isNotNull();
|
assertThat(responseDiagnosticsTestUtils.getFeedResponseDiagnostics()).isNotNull();
|
||||||
|
assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNotNull();
|
||||||
|
assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics().getRequestCharge()).isGreaterThan(0);
|
||||||
assertThat(result.size()).isEqualTo(1);
|
assertThat(result.size()).isEqualTo(1);
|
||||||
assertEquals(result.get(0), TEST_PERSON_2);
|
assertEquals(result.get(0), TEST_PERSON_2);
|
||||||
}
|
}
|
||||||
|
@ -261,6 +276,8 @@ public class CosmosTemplateIT {
|
||||||
assertThat(prevCount).isEqualTo(1);
|
assertThat(prevCount).isEqualTo(1);
|
||||||
|
|
||||||
assertThat(responseDiagnosticsTestUtils.getFeedResponseDiagnostics()).isNotNull();
|
assertThat(responseDiagnosticsTestUtils.getFeedResponseDiagnostics()).isNotNull();
|
||||||
|
assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNotNull();
|
||||||
|
assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics().getRequestCharge()).isGreaterThan(0);
|
||||||
|
|
||||||
cosmosTemplate.insert(TEST_PERSON_2,
|
cosmosTemplate.insert(TEST_PERSON_2,
|
||||||
new PartitionKey(personInfo.getPartitionKeyFieldValue(TEST_PERSON_2)));
|
new PartitionKey(personInfo.getPartitionKeyFieldValue(TEST_PERSON_2)));
|
||||||
|
@ -272,6 +289,8 @@ public class CosmosTemplateIT {
|
||||||
|
|
||||||
assertThat(responseDiagnosticsTestUtils.getCosmosResponseDiagnostics()).isNull();
|
assertThat(responseDiagnosticsTestUtils.getCosmosResponseDiagnostics()).isNull();
|
||||||
assertThat(responseDiagnosticsTestUtils.getFeedResponseDiagnostics()).isNotNull();
|
assertThat(responseDiagnosticsTestUtils.getFeedResponseDiagnostics()).isNotNull();
|
||||||
|
assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNotNull();
|
||||||
|
assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics().getRequestCharge()).isGreaterThan(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -281,6 +300,7 @@ public class CosmosTemplateIT {
|
||||||
|
|
||||||
assertThat(responseDiagnosticsTestUtils.getCosmosResponseDiagnostics()).isNotNull();
|
assertThat(responseDiagnosticsTestUtils.getCosmosResponseDiagnostics()).isNotNull();
|
||||||
assertThat(responseDiagnosticsTestUtils.getFeedResponseDiagnostics()).isNull();
|
assertThat(responseDiagnosticsTestUtils.getFeedResponseDiagnostics()).isNull();
|
||||||
|
assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNull();
|
||||||
|
|
||||||
final Criteria criteria = Criteria.getInstance(CriteriaType.IS_EQUAL, "firstName",
|
final Criteria criteria = Criteria.getInstance(CriteriaType.IS_EQUAL, "firstName",
|
||||||
Collections.singletonList(TEST_PERSON_2.getFirstName()));
|
Collections.singletonList(TEST_PERSON_2.getFirstName()));
|
||||||
|
@ -290,6 +310,8 @@ public class CosmosTemplateIT {
|
||||||
assertThat(count).isEqualTo(1);
|
assertThat(count).isEqualTo(1);
|
||||||
|
|
||||||
assertThat(responseDiagnosticsTestUtils.getFeedResponseDiagnostics()).isNotNull();
|
assertThat(responseDiagnosticsTestUtils.getFeedResponseDiagnostics()).isNotNull();
|
||||||
|
assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNotNull();
|
||||||
|
assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics().getRequestCharge()).isGreaterThan(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -299,6 +321,7 @@ public class CosmosTemplateIT {
|
||||||
|
|
||||||
assertThat(responseDiagnosticsTestUtils.getCosmosResponseDiagnostics()).isNotNull();
|
assertThat(responseDiagnosticsTestUtils.getCosmosResponseDiagnostics()).isNotNull();
|
||||||
assertThat(responseDiagnosticsTestUtils.getFeedResponseDiagnostics()).isNull();
|
assertThat(responseDiagnosticsTestUtils.getFeedResponseDiagnostics()).isNull();
|
||||||
|
assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNull();
|
||||||
|
|
||||||
final CosmosPageRequest pageRequest = new CosmosPageRequest(0, PAGE_SIZE_1, null);
|
final CosmosPageRequest pageRequest = new CosmosPageRequest(0, PAGE_SIZE_1, null);
|
||||||
final Page<Person> page1 = cosmosTemplate.findAll(pageRequest, Person.class, collectionName);
|
final Page<Person> page1 = cosmosTemplate.findAll(pageRequest, Person.class, collectionName);
|
||||||
|
@ -308,6 +331,8 @@ public class CosmosTemplateIT {
|
||||||
|
|
||||||
assertThat(responseDiagnosticsTestUtils.getCosmosResponseDiagnostics()).isNull();
|
assertThat(responseDiagnosticsTestUtils.getCosmosResponseDiagnostics()).isNull();
|
||||||
assertThat(responseDiagnosticsTestUtils.getFeedResponseDiagnostics()).isNotNull();
|
assertThat(responseDiagnosticsTestUtils.getFeedResponseDiagnostics()).isNotNull();
|
||||||
|
assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNotNull();
|
||||||
|
assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics().getRequestCharge()).isGreaterThan(0);
|
||||||
|
|
||||||
final Page<Person> page2 = cosmosTemplate.findAll(page1.getPageable(), Person.class,
|
final Page<Person> page2 = cosmosTemplate.findAll(page1.getPageable(), Person.class,
|
||||||
collectionName);
|
collectionName);
|
||||||
|
@ -316,6 +341,8 @@ public class CosmosTemplateIT {
|
||||||
|
|
||||||
assertThat(responseDiagnosticsTestUtils.getCosmosResponseDiagnostics()).isNull();
|
assertThat(responseDiagnosticsTestUtils.getCosmosResponseDiagnostics()).isNull();
|
||||||
assertThat(responseDiagnosticsTestUtils.getFeedResponseDiagnostics()).isNotNull();
|
assertThat(responseDiagnosticsTestUtils.getFeedResponseDiagnostics()).isNotNull();
|
||||||
|
assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNotNull();
|
||||||
|
assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics().getRequestCharge()).isGreaterThan(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -325,6 +352,7 @@ public class CosmosTemplateIT {
|
||||||
|
|
||||||
assertThat(responseDiagnosticsTestUtils.getCosmosResponseDiagnostics()).isNotNull();
|
assertThat(responseDiagnosticsTestUtils.getCosmosResponseDiagnostics()).isNotNull();
|
||||||
assertThat(responseDiagnosticsTestUtils.getFeedResponseDiagnostics()).isNull();
|
assertThat(responseDiagnosticsTestUtils.getFeedResponseDiagnostics()).isNull();
|
||||||
|
assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNull();
|
||||||
|
|
||||||
final Criteria criteria = Criteria.getInstance(CriteriaType.IS_EQUAL, "firstName",
|
final Criteria criteria = Criteria.getInstance(CriteriaType.IS_EQUAL, "firstName",
|
||||||
Collections.singletonList(FIRST_NAME));
|
Collections.singletonList(FIRST_NAME));
|
||||||
|
@ -337,6 +365,8 @@ public class CosmosTemplateIT {
|
||||||
|
|
||||||
assertThat(responseDiagnosticsTestUtils.getCosmosResponseDiagnostics()).isNull();
|
assertThat(responseDiagnosticsTestUtils.getCosmosResponseDiagnostics()).isNull();
|
||||||
assertThat(responseDiagnosticsTestUtils.getFeedResponseDiagnostics()).isNotNull();
|
assertThat(responseDiagnosticsTestUtils.getFeedResponseDiagnostics()).isNotNull();
|
||||||
|
assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNotNull();
|
||||||
|
assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics().getRequestCharge()).isGreaterThan(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -348,6 +378,7 @@ public class CosmosTemplateIT {
|
||||||
|
|
||||||
assertThat(responseDiagnosticsTestUtils.getCosmosResponseDiagnostics()).isNotNull();
|
assertThat(responseDiagnosticsTestUtils.getCosmosResponseDiagnostics()).isNotNull();
|
||||||
assertThat(responseDiagnosticsTestUtils.getFeedResponseDiagnostics()).isNull();
|
assertThat(responseDiagnosticsTestUtils.getFeedResponseDiagnostics()).isNull();
|
||||||
|
assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNull();
|
||||||
|
|
||||||
final Sort sort = Sort.by(Sort.Direction.DESC, "firstName");
|
final Sort sort = Sort.by(Sort.Direction.DESC, "firstName");
|
||||||
final PageRequest pageRequest = new CosmosPageRequest(0, PAGE_SIZE_3, null, sort);
|
final PageRequest pageRequest = new CosmosPageRequest(0, PAGE_SIZE_3, null, sort);
|
||||||
|
@ -363,6 +394,8 @@ public class CosmosTemplateIT {
|
||||||
|
|
||||||
assertThat(responseDiagnosticsTestUtils.getCosmosResponseDiagnostics()).isNull();
|
assertThat(responseDiagnosticsTestUtils.getCosmosResponseDiagnostics()).isNull();
|
||||||
assertThat(responseDiagnosticsTestUtils.getFeedResponseDiagnostics()).isNotNull();
|
assertThat(responseDiagnosticsTestUtils.getFeedResponseDiagnostics()).isNotNull();
|
||||||
|
assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNotNull();
|
||||||
|
assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics().getRequestCharge()).isGreaterThan(0);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -143,6 +143,8 @@ public class ReactiveCosmosTemplateIT {
|
||||||
.consumeNextWith(actual -> Assert.assertEquals(actual, TEST_PERSON))
|
.consumeNextWith(actual -> Assert.assertEquals(actual, TEST_PERSON))
|
||||||
.verifyComplete();
|
.verifyComplete();
|
||||||
assertThat(responseDiagnosticsTestUtils.getFeedResponseDiagnostics()).isNotNull();
|
assertThat(responseDiagnosticsTestUtils.getFeedResponseDiagnostics()).isNotNull();
|
||||||
|
assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNotNull();
|
||||||
|
assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics().getRequestCharge()).isGreaterThan(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -157,6 +159,8 @@ public class ReactiveCosmosTemplateIT {
|
||||||
}).verifyComplete();
|
}).verifyComplete();
|
||||||
|
|
||||||
assertThat(responseDiagnosticsTestUtils.getFeedResponseDiagnostics()).isNotNull();
|
assertThat(responseDiagnosticsTestUtils.getFeedResponseDiagnostics()).isNotNull();
|
||||||
|
assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNotNull();
|
||||||
|
assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics().getRequestCharge()).isGreaterThan(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -166,6 +170,8 @@ public class ReactiveCosmosTemplateIT {
|
||||||
StepVerifier.create(flux).expectNextCount(1).verifyComplete();
|
StepVerifier.create(flux).expectNextCount(1).verifyComplete();
|
||||||
|
|
||||||
assertThat(responseDiagnosticsTestUtils.getFeedResponseDiagnostics()).isNotNull();
|
assertThat(responseDiagnosticsTestUtils.getFeedResponseDiagnostics()).isNotNull();
|
||||||
|
assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNotNull();
|
||||||
|
assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics().getRequestCharge()).isGreaterThan(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -176,6 +182,8 @@ public class ReactiveCosmosTemplateIT {
|
||||||
.verifyComplete();
|
.verifyComplete();
|
||||||
|
|
||||||
assertThat(responseDiagnosticsTestUtils.getFeedResponseDiagnostics()).isNotNull();
|
assertThat(responseDiagnosticsTestUtils.getFeedResponseDiagnostics()).isNotNull();
|
||||||
|
assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNotNull();
|
||||||
|
assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics().getRequestCharge()).isGreaterThan(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -185,6 +193,7 @@ public class ReactiveCosmosTemplateIT {
|
||||||
.expectNext(TEST_PERSON_3).verifyComplete();
|
.expectNext(TEST_PERSON_3).verifyComplete();
|
||||||
|
|
||||||
assertThat(responseDiagnosticsTestUtils.getFeedResponseDiagnostics()).isNull();
|
assertThat(responseDiagnosticsTestUtils.getFeedResponseDiagnostics()).isNull();
|
||||||
|
assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNull();
|
||||||
assertThat(responseDiagnosticsTestUtils.getCosmosResponseDiagnostics()).isNotNull();
|
assertThat(responseDiagnosticsTestUtils.getCosmosResponseDiagnostics()).isNotNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -196,6 +205,7 @@ public class ReactiveCosmosTemplateIT {
|
||||||
.expectNext(TEST_PERSON_3).verifyComplete();
|
.expectNext(TEST_PERSON_3).verifyComplete();
|
||||||
|
|
||||||
assertThat(responseDiagnosticsTestUtils.getFeedResponseDiagnostics()).isNull();
|
assertThat(responseDiagnosticsTestUtils.getFeedResponseDiagnostics()).isNull();
|
||||||
|
assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNull();
|
||||||
assertThat(responseDiagnosticsTestUtils.getCosmosResponseDiagnostics()).isNotNull();
|
assertThat(responseDiagnosticsTestUtils.getCosmosResponseDiagnostics()).isNotNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -206,6 +216,7 @@ public class ReactiveCosmosTemplateIT {
|
||||||
.expectNext(TEST_PERSON_2).verifyComplete();
|
.expectNext(TEST_PERSON_2).verifyComplete();
|
||||||
|
|
||||||
assertThat(responseDiagnosticsTestUtils.getFeedResponseDiagnostics()).isNull();
|
assertThat(responseDiagnosticsTestUtils.getFeedResponseDiagnostics()).isNull();
|
||||||
|
assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNull();
|
||||||
assertThat(responseDiagnosticsTestUtils.getCosmosResponseDiagnostics()).isNotNull();
|
assertThat(responseDiagnosticsTestUtils.getCosmosResponseDiagnostics()).isNotNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -220,6 +231,7 @@ public class ReactiveCosmosTemplateIT {
|
||||||
StepVerifier.create(upsert).expectNextCount(1).verifyComplete();
|
StepVerifier.create(upsert).expectNextCount(1).verifyComplete();
|
||||||
|
|
||||||
assertThat(responseDiagnosticsTestUtils.getFeedResponseDiagnostics()).isNull();
|
assertThat(responseDiagnosticsTestUtils.getFeedResponseDiagnostics()).isNull();
|
||||||
|
assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNull();
|
||||||
assertThat(responseDiagnosticsTestUtils.getCosmosResponseDiagnostics()).isNotNull();
|
assertThat(responseDiagnosticsTestUtils.getCosmosResponseDiagnostics()).isNotNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -235,6 +247,7 @@ public class ReactiveCosmosTemplateIT {
|
||||||
StepVerifier.create(upsert).expectNextCount(1).verifyComplete();
|
StepVerifier.create(upsert).expectNextCount(1).verifyComplete();
|
||||||
|
|
||||||
assertThat(responseDiagnosticsTestUtils.getFeedResponseDiagnostics()).isNull();
|
assertThat(responseDiagnosticsTestUtils.getFeedResponseDiagnostics()).isNull();
|
||||||
|
assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNull();
|
||||||
assertThat(responseDiagnosticsTestUtils.getCosmosResponseDiagnostics()).isNotNull();
|
assertThat(responseDiagnosticsTestUtils.getCosmosResponseDiagnostics()).isNotNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -249,6 +262,7 @@ public class ReactiveCosmosTemplateIT {
|
||||||
StepVerifier.create(upsert).expectNextCount(1).verifyComplete();
|
StepVerifier.create(upsert).expectNextCount(1).verifyComplete();
|
||||||
|
|
||||||
assertThat(responseDiagnosticsTestUtils.getFeedResponseDiagnostics()).isNull();
|
assertThat(responseDiagnosticsTestUtils.getFeedResponseDiagnostics()).isNull();
|
||||||
|
assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNull();
|
||||||
assertThat(responseDiagnosticsTestUtils.getCosmosResponseDiagnostics()).isNotNull();
|
assertThat(responseDiagnosticsTestUtils.getCosmosResponseDiagnostics()).isNotNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -258,12 +272,15 @@ public class ReactiveCosmosTemplateIT {
|
||||||
new PartitionKey(personInfo.getPartitionKeyFieldValue(TEST_PERSON_4))).block();
|
new PartitionKey(personInfo.getPartitionKeyFieldValue(TEST_PERSON_4))).block();
|
||||||
|
|
||||||
assertThat(responseDiagnosticsTestUtils.getFeedResponseDiagnostics()).isNull();
|
assertThat(responseDiagnosticsTestUtils.getFeedResponseDiagnostics()).isNull();
|
||||||
|
assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNull();
|
||||||
assertThat(responseDiagnosticsTestUtils.getCosmosResponseDiagnostics()).isNotNull();
|
assertThat(responseDiagnosticsTestUtils.getCosmosResponseDiagnostics()).isNotNull();
|
||||||
|
|
||||||
Flux<Person> flux = cosmosTemplate.findAll(Person.class.getSimpleName(), Person.class);
|
Flux<Person> flux = cosmosTemplate.findAll(Person.class.getSimpleName(), Person.class);
|
||||||
StepVerifier.create(flux).expectNextCount(2).verifyComplete();
|
StepVerifier.create(flux).expectNextCount(2).verifyComplete();
|
||||||
|
|
||||||
assertThat(responseDiagnosticsTestUtils.getFeedResponseDiagnostics()).isNotNull();
|
assertThat(responseDiagnosticsTestUtils.getFeedResponseDiagnostics()).isNotNull();
|
||||||
|
assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNotNull();
|
||||||
|
assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics().getRequestCharge()).isGreaterThan(0);
|
||||||
assertThat(responseDiagnosticsTestUtils.getCosmosResponseDiagnostics()).isNull();
|
assertThat(responseDiagnosticsTestUtils.getCosmosResponseDiagnostics()).isNull();
|
||||||
|
|
||||||
final Mono<Void> voidMono = cosmosTemplate.deleteById(Person.class.getSimpleName(),
|
final Mono<Void> voidMono = cosmosTemplate.deleteById(Person.class.getSimpleName(),
|
||||||
|
@ -272,12 +289,15 @@ public class ReactiveCosmosTemplateIT {
|
||||||
StepVerifier.create(voidMono).verifyComplete();
|
StepVerifier.create(voidMono).verifyComplete();
|
||||||
|
|
||||||
assertThat(responseDiagnosticsTestUtils.getFeedResponseDiagnostics()).isNull();
|
assertThat(responseDiagnosticsTestUtils.getFeedResponseDiagnostics()).isNull();
|
||||||
|
assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNull();
|
||||||
assertThat(responseDiagnosticsTestUtils.getCosmosResponseDiagnostics()).isNotNull();
|
assertThat(responseDiagnosticsTestUtils.getCosmosResponseDiagnostics()).isNotNull();
|
||||||
|
|
||||||
flux = cosmosTemplate.findAll(Person.class.getSimpleName(), Person.class);
|
flux = cosmosTemplate.findAll(Person.class.getSimpleName(), Person.class);
|
||||||
StepVerifier.create(flux).expectNextCount(1).verifyComplete();
|
StepVerifier.create(flux).expectNextCount(1).verifyComplete();
|
||||||
|
|
||||||
assertThat(responseDiagnosticsTestUtils.getFeedResponseDiagnostics()).isNotNull();
|
assertThat(responseDiagnosticsTestUtils.getFeedResponseDiagnostics()).isNotNull();
|
||||||
|
assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNotNull();
|
||||||
|
assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics().getRequestCharge()).isGreaterThan(0);
|
||||||
assertThat(responseDiagnosticsTestUtils.getCosmosResponseDiagnostics()).isNull();
|
assertThat(responseDiagnosticsTestUtils.getCosmosResponseDiagnostics()).isNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -306,6 +326,8 @@ public class ReactiveCosmosTemplateIT {
|
||||||
StepVerifier.create(personFlux).expectNextCount(1).verifyComplete();
|
StepVerifier.create(personFlux).expectNextCount(1).verifyComplete();
|
||||||
|
|
||||||
assertThat(responseDiagnosticsTestUtils.getFeedResponseDiagnostics()).isNotNull();
|
assertThat(responseDiagnosticsTestUtils.getFeedResponseDiagnostics()).isNotNull();
|
||||||
|
assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNotNull();
|
||||||
|
assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics().getRequestCharge()).isGreaterThan(0);
|
||||||
assertThat(responseDiagnosticsTestUtils.getCosmosResponseDiagnostics()).isNull();
|
assertThat(responseDiagnosticsTestUtils.getCosmosResponseDiagnostics()).isNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -318,6 +340,8 @@ public class ReactiveCosmosTemplateIT {
|
||||||
StepVerifier.create(exists).expectNext(true).verifyComplete();
|
StepVerifier.create(exists).expectNext(true).verifyComplete();
|
||||||
|
|
||||||
assertThat(responseDiagnosticsTestUtils.getFeedResponseDiagnostics()).isNotNull();
|
assertThat(responseDiagnosticsTestUtils.getFeedResponseDiagnostics()).isNotNull();
|
||||||
|
assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNotNull();
|
||||||
|
assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics().getRequestCharge()).isGreaterThan(0);
|
||||||
assertThat(responseDiagnosticsTestUtils.getCosmosResponseDiagnostics()).isNull();
|
assertThat(responseDiagnosticsTestUtils.getCosmosResponseDiagnostics()).isNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -327,6 +351,8 @@ public class ReactiveCosmosTemplateIT {
|
||||||
StepVerifier.create(count).expectNext((long) 1).verifyComplete();
|
StepVerifier.create(count).expectNext((long) 1).verifyComplete();
|
||||||
|
|
||||||
assertThat(responseDiagnosticsTestUtils.getFeedResponseDiagnostics()).isNotNull();
|
assertThat(responseDiagnosticsTestUtils.getFeedResponseDiagnostics()).isNotNull();
|
||||||
|
assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNotNull();
|
||||||
|
assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics().getRequestCharge()).isGreaterThan(0);
|
||||||
assertThat(responseDiagnosticsTestUtils.getCosmosResponseDiagnostics()).isNull();
|
assertThat(responseDiagnosticsTestUtils.getCosmosResponseDiagnostics()).isNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче