diff --git a/eng/code-quality-reports/src/main/resources/spotbugs/spotbugs-exclude.xml b/eng/code-quality-reports/src/main/resources/spotbugs/spotbugs-exclude.xml index fa40be14bb80a..969b301ee7bd4 100755 --- a/eng/code-quality-reports/src/main/resources/spotbugs/spotbugs-exclude.xml +++ b/eng/code-quality-reports/src/main/resources/spotbugs/spotbugs-exclude.xml @@ -1049,7 +1049,7 @@ - + diff --git a/sdk/cosmos/azure-cosmos/CHANGELOG.md b/sdk/cosmos/azure-cosmos/CHANGELOG.md index 2992a049ce59b..93c1580690fd8 100644 --- a/sdk/cosmos/azure-cosmos/CHANGELOG.md +++ b/sdk/cosmos/azure-cosmos/CHANGELOG.md @@ -9,7 +9,8 @@ #### Bugs Fixed #### Other Changes -* Remove `requires io.netty.transport.epoll` from `module-info`. +* Remove requires `io.netty.transport.epoll` from `module-info`. +* Converted from `durationInMicroSec` to `durationInMilliSecs` in `CosmosDiagnostics` - See [PR 29643](https://github.com/Azure/azure-sdk-for-java/pull/29643) ### 4.31.0 (2022-06-08) diff --git a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/RequestTimeline.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/RequestTimeline.java index 2b07c27c2753f..0563169e073e4 100644 --- a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/RequestTimeline.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/RequestTimeline.java @@ -151,14 +151,14 @@ public String toString() { return RntbdObjectMapper.toString(this); } - @JsonPropertyOrder({ "name", "startTimeUTC", "durationInMicroSec" }) + @JsonPropertyOrder({ "name", "startTimeUTC", "durationInMilliSecs" }) public static final class Event { @JsonIgnore private final Duration duration; @JsonProperty - private final long durationInMicroSec; + private final double durationInMilliSecs; @JsonProperty("eventName") private final String name; @@ -183,9 +183,9 @@ public Event(final String name, final Instant from, final Instant to) { } if (duration != null) { - this.durationInMicroSec = duration.toNanos()/1000L; + this.durationInMilliSecs = (double)(duration.toNanos()) / (1000d * 1000d); } else { - this.durationInMicroSec = 0; + this.durationInMilliSecs = 0.0D; } } diff --git a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/SerializationDiagnosticsContext.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/SerializationDiagnosticsContext.java index 9622345e9e01a..0ac9aaaee7aa8 100644 --- a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/SerializationDiagnosticsContext.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/SerializationDiagnosticsContext.java @@ -59,15 +59,15 @@ public SerializationDiagnosticsSerializer() { @Override public void serialize(SerializationDiagnosticsContext.SerializationDiagnostics serializationDiagnostics, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException { - Duration durationinMS = serializationDiagnostics.startTimeUTC == null ? + Duration duration = serializationDiagnostics.startTimeUTC == null ? null : serializationDiagnostics.endTimeUTC == null ? Duration.ZERO : Duration.between(serializationDiagnostics.startTimeUTC, serializationDiagnostics.endTimeUTC); jsonGenerator.writeStartObject(); jsonGenerator.writeObjectField("serializationType", serializationDiagnostics.serializationType); jsonGenerator.writeStringField("startTimeUTC", DiagnosticsInstantSerializer.fromInstant(serializationDiagnostics.startTimeUTC)); jsonGenerator.writeStringField("endTimeUTC", DiagnosticsInstantSerializer.fromInstant(serializationDiagnostics.endTimeUTC)); - if (durationinMS != null) { - jsonGenerator.writeNumberField("durationInMicroSec", durationinMS.toNanos() / 1000); + if (duration != null) { + jsonGenerator.writeNumberField("durationInMilliSecs", (double)duration.toNanos() / (1000d * 1000d)); } jsonGenerator.writeEndObject(); diff --git a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/directconnectivity/rntbd/RntbdChannelAcquisitionEvent.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/directconnectivity/rntbd/RntbdChannelAcquisitionEvent.java index 4be91e871404c..ce9dcf6867964 100644 --- a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/directconnectivity/rntbd/RntbdChannelAcquisitionEvent.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/directconnectivity/rntbd/RntbdChannelAcquisitionEvent.java @@ -59,7 +59,7 @@ public void serialize(RntbdChannelAcquisitionEvent event, writer.writeStringField(event.eventType.toString(), event.createdTime.toString()); if (event.completeTime != null) { - writer.writeNumberField("durationInMicroSec",Duration.between(event.createdTime, event.completeTime).toNanos()/1000L); + writer.writeNumberField("durationInMilliSecs", (double) Duration.between(event.createdTime, event.completeTime).toNanos() / (1000d * 1000d)); } writer.writeEndObject(); diff --git a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/directconnectivity/rntbd/RntbdPollChannelEvent.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/directconnectivity/rntbd/RntbdPollChannelEvent.java index c2dc5b945c340..b9499b0dfdbd1 100644 --- a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/directconnectivity/rntbd/RntbdPollChannelEvent.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/directconnectivity/rntbd/RntbdPollChannelEvent.java @@ -50,8 +50,8 @@ public void serialize(RntbdPollChannelEvent event, if (event.getCompleteTime() != null) { writer.writeNumberField( - "durationInMicroSec", - Duration.between(event.getCompleteTime(), event.getCompleteTime()).toNanos()/1000L); + "durationInMilliSecs", + (double) Duration.between(event.getCompleteTime(), event.getCompleteTime()).toNanos() / (1000d * 1000d)); } if (event.details != null && event.details.size() > 0) { diff --git a/sdk/cosmos/azure-cosmos/src/test/java/com/azure/cosmos/CosmosDiagnosticsTest.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/cosmos/CosmosDiagnosticsTest.java index 4ef042eb1efda..fed50f848bf7a 100644 --- a/sdk/cosmos/azure-cosmos/src/test/java/com/azure/cosmos/CosmosDiagnosticsTest.java +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/cosmos/CosmosDiagnosticsTest.java @@ -1124,7 +1124,7 @@ private void validateTransportRequestTimelineDirect(String diagnostics) { assertThat(diagnostics).contains("\"eventName\":\"received\""); assertThat(diagnostics).contains("\"eventName\":\"completed\""); assertThat(diagnostics).contains("\"startTimeUTC\""); - assertThat(diagnostics).contains("\"durationInMicroSec\""); + assertThat(diagnostics).contains("\"durationInMilliSecs\""); } public void isValidJSON(final String json) { diff --git a/sdk/cosmos/azure-spring-data-cosmos/README.md b/sdk/cosmos/azure-spring-data-cosmos/README.md index cf7c4160a27e8..486d2adca3837 100644 --- a/sdk/cosmos/azure-spring-data-cosmos/README.md +++ b/sdk/cosmos/azure-spring-data-cosmos/README.md @@ -126,7 +126,7 @@ public class AppConfiguration extends AbstractCosmosConfiguration { @Value("${azure.cosmos.queryMetricsEnabled}") private boolean queryMetricsEnabled; - + @Value("${azure.cosmos.maxDegreeOfParallelism}") private int maxDegreeOfParallelism;