Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added optional tags/dimensions for PartitionId/ReplicaId as addition/… #35164

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,21 @@ public void beforeTest(CosmosMetricCategory... metricCategories) {
beforeTest(null, metricCategories);
}

public void beforeTest(CosmosDiagnosticsThresholds thresholds, CosmosMetricCategory... metricCategories) {
public void beforeTest(
CosmosDiagnosticsThresholds thresholds,
CosmosMetricCategory... metricCategories) {
assertThat(this.client).isNull();
assertThat(this.meterRegistry).isNull();

this.meterRegistry = ConsoleLoggingRegistryFactory.create(1);

this.inputMetricsOptions = new CosmosMicrometerMetricsOptions()
.meterRegistry(this.meterRegistry)
.setMetricCategories(metricCategories);
.setMetricCategories(metricCategories)
.configureDefaultTagNames(
CosmosMetricTagName.DEFAULT,
CosmosMetricTagName.PARTITION_ID,
CosmosMetricTagName.REPLICA_ID);

this.inputClientTelemetryConfig = new CosmosClientTelemetryConfig()
.metricsOptions(this.inputMetricsOptions);
Expand Down Expand Up @@ -234,13 +240,31 @@ public void createItem() throws Exception {
this.assertMetrics("cosmos.client.op.calls", true, expectedOperationTag);

if (!disableLatencyMeter) {
Tag expectedRequestTag = Tag.of(TagName.RequestStatusCode.toString(), "201/0");
this.validateMetrics(
expectedOperationTag,
Tag.of(TagName.RequestStatusCode.toString(), "201/0"),
expectedRequestTag,
1,
300
);

// also ensure the replicaId dimension is populated for DIRECT mode
if (this.client.asyncClient().getConnectionPolicy().getConnectionMode() == ConnectionMode.DIRECT) {
Meter foundMeter = this.assertMetrics(
"cosmos.client.req.rntbd.latency",
true,
expectedRequestTag);
assertThat(foundMeter).isNotNull();
boolean replicaIdDimensionExists = foundMeter
.getId()
.getTags()
.stream()
.anyMatch(tag -> tag.getKey().equals(TagName.ReplicaId.toString()) &&
!tag.getValue().equals("NONE"));
assertThat(replicaIdDimensionExists)
.isEqualTo(true);
}

this.validateMetrics(
Tag.of(
TagName.Operation.toString(), "Document/Create"),
Expand Down Expand Up @@ -1095,6 +1119,11 @@ public void meterTagNameFromStringConversion() {
.isSameAs(CosmosMetricTagName.SERVICE_ADDRESS);
assertThat(CosmosMetricTagName.fromString("serviceEndpoint"))
.isSameAs(CosmosMetricTagName.SERVICE_ENDPOINT);
assertThat(CosmosMetricTagName.fromString("partitionID"))
.isSameAs(CosmosMetricTagName.PARTITION_ID);
assertThat(CosmosMetricTagName.fromString("REPLICAid"))
.isSameAs(CosmosMetricTagName.REPLICA_ID);

}

@Test(groups = {"simple"}, timeOut = TIMEOUT)
Expand Down
2 changes: 1 addition & 1 deletion sdk/cosmos/azure-cosmos/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#### Features Added
* Added the capability to filter request-level metrics based on diagnostic thresholds. Request-level metrics usually are used to capture metrics per backend endpoint/replica - a high cardinality dimension. Filtering by diagnostic thresholds reduces the overhead - but also means request-level metrics can only be used for debugging purposes - not for monitoring purposes. So, it is important to use the unfiltered operation-level metrics for health monitoring in this case. - See [PR 35114](https://github.com/Azure/azure-sdk-for-java/pull/35114)

* Added optional tags/dimensions for PartitionId/ReplicaId as alternative to ServiceAddress for direct-mode (rntbd) request-level metrics. - See [PR 35164](https://github.com/Azure/azure-sdk-for-java/pull/35164)
FabianMeiswinkel marked this conversation as resolved.
Show resolved Hide resolved
#### Breaking Changes

#### Bugs Fixed
Expand Down
Loading