forked from Azure/azure-sdk-for-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Wrapped Client Side Request Statistics (Azure#216)
* Wrapped Client Side Request Statistics in Cosmos Response Diagnostic Statistics. Exposed only toString and request latency * Code review comments for Cosmos Response Diagnostics * Wrapped Query Metrics Map in Feed Response Diagnostics. Exposed toString through Feed response diagnostics * Reducing scope of setter to package private
- Loading branch information
1 parent
9c73dd9
commit 42665d2
Showing
27 changed files
with
255 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
sdk/src/main/java/com/azure/data/cosmos/CosmosResponseDiagnostics.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
* The MIT License (MIT) | ||
* Copyright (c) 2018 Microsoft Corporation | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in all | ||
* copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
*/ | ||
package com.azure.data.cosmos; | ||
|
||
import java.time.Duration; | ||
|
||
/** | ||
* This class represents response diagnostic statistics associated with a request to Azure Cosmos DB | ||
*/ | ||
public class CosmosResponseDiagnostics { | ||
|
||
private ClientSideRequestStatistics clientSideRequestStatistics; | ||
|
||
CosmosResponseDiagnostics() { | ||
this.clientSideRequestStatistics = new ClientSideRequestStatistics(); | ||
} | ||
|
||
ClientSideRequestStatistics clientSideRequestStatistics() { | ||
return clientSideRequestStatistics; | ||
} | ||
|
||
CosmosResponseDiagnostics clientSideRequestStatistics(ClientSideRequestStatistics clientSideRequestStatistics) { | ||
this.clientSideRequestStatistics = clientSideRequestStatistics; | ||
return this; | ||
} | ||
|
||
/** | ||
* Retrieves Response Diagnostic String | ||
* @return Response Diagnostic String | ||
*/ | ||
@Override | ||
public String toString() { | ||
return this.clientSideRequestStatistics.toString(); | ||
} | ||
|
||
/** | ||
* Retrieves latency related to the completion of the request | ||
* @return request completion latency | ||
*/ | ||
public Duration requestLatency() { | ||
return this.clientSideRequestStatistics.getRequestLatency(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
sdk/src/main/java/com/azure/data/cosmos/FeedResponseDiagnostics.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package com.azure.data.cosmos; | ||
|
||
import com.azure.data.cosmos.internal.QueryMetrics; | ||
import org.apache.commons.lang3.StringUtils; | ||
|
||
import java.util.Map; | ||
|
||
public class FeedResponseDiagnostics { | ||
|
||
private Map<String, QueryMetrics> queryMetricsMap; | ||
|
||
FeedResponseDiagnostics(Map<String, QueryMetrics> queryMetricsMap) { | ||
this.queryMetricsMap = queryMetricsMap; | ||
} | ||
|
||
Map<String, QueryMetrics> queryMetricsMap() { | ||
return queryMetricsMap; | ||
} | ||
|
||
FeedResponseDiagnostics queryMetricsMap(Map<String, QueryMetrics> queryMetricsMap) { | ||
this.queryMetricsMap = queryMetricsMap; | ||
return this; | ||
} | ||
|
||
/** | ||
* Returns the textual representation of feed response metrics | ||
* @return Textual representation of feed response metrics | ||
*/ | ||
@Override | ||
public String toString() { | ||
if (queryMetricsMap == null || queryMetricsMap.isEmpty()) { | ||
return StringUtils.EMPTY; | ||
} | ||
StringBuilder stringBuilder = new StringBuilder(); | ||
queryMetricsMap.forEach((key, value) -> stringBuilder.append(key).append("=").append(value.toString()).append("\n")); | ||
return stringBuilder.toString(); | ||
} | ||
} |
Oops, something went wrong.