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

Cosmos Metrics: allow enabling only metrics of certain categories #33436

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
caec82a
Cosmos Metrics: allow enabling only metrics of certain categories
FabianMeiswinkel Feb 10, 2023
f2faf85
Updating changelogs
FabianMeiswinkel Feb 10, 2023
94ec79f
Small refactoring removing unnecessary metricTagNames/metricCategorie…
FabianMeiswinkel Feb 10, 2023
1edf43d
Linting fixes
FabianMeiswinkel Feb 10, 2023
37fbe70
Fixing test regressions
FabianMeiswinkel Feb 11, 2023
cbdf1e2
Adding tests
FabianMeiswinkel Feb 13, 2023
7ec76c3
Fixing test failure
FabianMeiswinkel Feb 13, 2023
5c39a29
Aligning MetricNames with the new categories
FabianMeiswinkel Feb 13, 2023
d5ca35b
Update CosmosClientTelemetryConfig.java
FabianMeiswinkel Feb 13, 2023
4e77588
Update RntbdServiceEndpoint.java
FabianMeiswinkel Feb 13, 2023
60666ed
Test changes
FabianMeiswinkel Feb 13, 2023
718f831
Fixing test issues
FabianMeiswinkel Feb 13, 2023
d638fa1
Merge branch 'main' of https://github.com/Azure/azure-sdk-for-java in…
FabianMeiswinkel Feb 14, 2023
fbb12a2
Public API refactoring
FabianMeiswinkel Feb 14, 2023
ca6be6f
Merge branch 'main' of https://github.com/Azure/azure-sdk-for-java in…
FabianMeiswinkel Feb 14, 2023
504ce9b
Update ci.yml
FabianMeiswinkel Feb 14, 2023
b3bead8
Trying to fix build issue
FabianMeiswinkel Feb 14, 2023
8ca19f2
Trying to fix build issue
FabianMeiswinkel Feb 14, 2023
8f043b2
Adding missing javadoc comments
FabianMeiswinkel Feb 14, 2023
cd088c9
Refactoring to allow more granular option definition for metrics
FabianMeiswinkel Feb 15, 2023
6d4fdb2
Merge branch 'main' of https://github.com/Azure/azure-sdk-for-java in…
FabianMeiswinkel Feb 15, 2023
7a0a229
Fixing linting violations
FabianMeiswinkel Feb 15, 2023
4e4fa9f
Fixing tests
FabianMeiswinkel Feb 15, 2023
c0aea62
Making system meters configurable
FabianMeiswinkel Feb 15, 2023
80c7680
NITs
FabianMeiswinkel Feb 15, 2023
5c731bc
Update CosmosMeterOptions.java
FabianMeiswinkel Feb 15, 2023
b30a4de
Test fix
FabianMeiswinkel Feb 15, 2023
17c04ba
Adding few more tests and fixing javadoc violations
FabianMeiswinkel Feb 15, 2023
e915d07
Merge branch 'main' of https://github.com/Azure/azure-sdk-for-java in…
FabianMeiswinkel Feb 15, 2023
2ae7bb6
Reacting to Code review feedback
FabianMeiswinkel Feb 15, 2023
8c94f08
Merge branch 'main' of https://github.com/Azure/azure-sdk-for-java in…
FabianMeiswinkel Feb 15, 2023
f95d166
Reacting to API review feedback
FabianMeiswinkel Feb 15, 2023
b5bbc9c
Merge branch 'main' of https://github.com/Azure/azure-sdk-for-java in…
FabianMeiswinkel Feb 15, 2023
69be954
Refactoring based on API review
FabianMeiswinkel Feb 15, 2023
eb71343
Update pom.xml
FabianMeiswinkel Feb 15, 2023
85ccd3b
Update CosmosMeterOptions.java
FabianMeiswinkel Feb 15, 2023
ad1c43d
Update CosmosMeterOptions.java
FabianMeiswinkel Feb 16, 2023
aa09a88
Update CosmosMeterOptions.java
FabianMeiswinkel Feb 16, 2023
ba04d1b
Update CosmosMeterOptions.java
FabianMeiswinkel Feb 16, 2023
7cce4fd
Merge branch 'main' of https://github.com/Azure/azure-sdk-for-java in…
FabianMeiswinkel Feb 16, 2023
d9af6e8
Update pom.xml
FabianMeiswinkel Feb 16, 2023
48aacab
Update pom.xml
FabianMeiswinkel Feb 16, 2023
2d03dc2
Merge branch 'main' of https://github.com/Azure/azure-sdk-for-java in…
FabianMeiswinkel Feb 16, 2023
2eebb6a
Update ClientMetricsTest.java
FabianMeiswinkel Feb 16, 2023
4ff8e9a
Merge branch 'main' of https://github.com/Azure/azure-sdk-for-java in…
FabianMeiswinkel Feb 16, 2023
92f3efd
Merge branch 'main' of https://github.com/Azure/azure-sdk-for-java in…
FabianMeiswinkel Feb 16, 2023
ecc3fc7
Refactoring to avoid dependency on ExtendableStringEnum
FabianMeiswinkel Feb 17, 2023
50c5d80
Fixing regression from removing ExpandableStringENum
FabianMeiswinkel Feb 17, 2023
1f84f59
Update CosmosMetricName.java
FabianMeiswinkel Feb 17, 2023
f4cd11f
Update ClientMetricsTest.java
FabianMeiswinkel Feb 17, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -19,6 +19,7 @@
import com.azure.cosmos.implementation.TracerProvider;
import com.azure.cosmos.implementation.clienttelemetry.ClientTelemetry;
import com.azure.cosmos.implementation.clienttelemetry.ClientTelemetryMetrics;
import com.azure.cosmos.implementation.clienttelemetry.MetricCategory;
import com.azure.cosmos.implementation.clienttelemetry.TagName;
import com.azure.cosmos.implementation.directconnectivity.rntbd.RntbdMetrics;
import com.azure.cosmos.implementation.throughputControl.config.ThroughputControlGroupInternal;
Expand Down Expand Up @@ -84,6 +85,7 @@ public final class CosmosAsyncClient implements Closeable {
private final Tag clientCorrelationTag;
private final String accountTagValue;
private final EnumSet<TagName> metricTagNames;
private final EnumSet<MetricCategory> metricCategories;
private final boolean clientMetricsEnabled;
private final boolean isSendClientTelemetryToServiceEnabled;
private final MeterRegistry clientMetricRegistrySnapshot;
Expand Down Expand Up @@ -139,6 +141,8 @@ public final class CosmosAsyncClient implements Closeable {
.getClientCorrelationId(effectiveTelemetryConfig);
this.metricTagNames = telemetryConfigAccessor
.getMetricTagNames(effectiveTelemetryConfig);
this.metricCategories = telemetryConfigAccessor
.getMetricCategories(effectiveTelemetryConfig);

List<Permission> permissionList = new ArrayList<>();
if (this.permissions != null) {
Expand Down Expand Up @@ -168,6 +172,7 @@ public final class CosmosAsyncClient implements Closeable {
.withClientTelemetryConfig(this.clientTelemetryConfig)
.withClientCorrelationId(this.clientCorrelationId)
.withMetricTagNames(this.metricTagNames)
.withMetricCategories(this.metricCategories)
.build();

String effectiveClientCorrelationId = this.asyncDocumentClient.getClientCorrelationId();
Expand Down Expand Up @@ -728,6 +733,11 @@ public EnumSet<TagName> getMetricTagNames(CosmosAsyncClient client) {
return client.metricTagNames;
}

@Override
public EnumSet<MetricCategory> getMetricCategories(CosmosAsyncClient client) {
return client.metricCategories;
}

@Override
public boolean isClientTelemetryMetricsEnabled(CosmosAsyncClient client) {
return client.clientMetricsEnabled;
Expand Down
Expand Up @@ -11,6 +11,7 @@
import com.azure.cosmos.implementation.caches.RxClientCollectionCache;
import com.azure.cosmos.implementation.caches.RxPartitionKeyRangeCache;
import com.azure.cosmos.implementation.clienttelemetry.ClientTelemetry;
import com.azure.cosmos.implementation.clienttelemetry.MetricCategory;
import com.azure.cosmos.implementation.clienttelemetry.TagName;
import com.azure.cosmos.implementation.query.PartitionedQueryExecutionInfo;
import com.azure.cosmos.implementation.throughputControl.config.ThroughputControlGroupInternal;
Expand Down Expand Up @@ -99,6 +100,7 @@ class Builder {
CosmosClientTelemetryConfig clientTelemetryConfig;
private String clientCorrelationId = null;
private EnumSet<TagName> metricTagNames = EnumSet.allOf(TagName.class);
private EnumSet<MetricCategory> metricCategories = MetricCategory.DEFAULT_CATEGORIES;

public Builder withServiceEndpoint(String serviceEndpoint) {
try {
Expand Down Expand Up @@ -131,6 +133,12 @@ public Builder withMetricTagNames(EnumSet<TagName> tagNames) {
return this;
}

public Builder withMetricCategories(EnumSet<MetricCategory> categories) {
this.metricCategories = categories;

return this;
}

/**
* New method withMasterKeyOrResourceToken will take either master key or resource token
* and perform authentication for accessing resource.
Expand Down
Expand Up @@ -19,6 +19,7 @@
import com.azure.cosmos.ThroughputControlGroupConfig;
import com.azure.cosmos.implementation.batch.ItemBatchOperation;
import com.azure.cosmos.implementation.batch.PartitionScopeThresholds;
import com.azure.cosmos.implementation.clienttelemetry.MetricCategory;
import com.azure.cosmos.implementation.clienttelemetry.TagName;
import com.azure.cosmos.implementation.patch.PatchOperation;
import com.azure.cosmos.implementation.routing.PartitionKeyInternal;
Expand Down Expand Up @@ -1040,6 +1041,7 @@ public interface CosmosAsyncClientAccessor {
Tag getClientCorrelationTag(CosmosAsyncClient client);
String getAccountTagValue(CosmosAsyncClient client);
EnumSet<TagName> getMetricTagNames(CosmosAsyncClient client);
EnumSet<MetricCategory> getMetricCategories(CosmosAsyncClient client);
boolean isClientTelemetryMetricsEnabled(CosmosAsyncClient client);
boolean isSendClientTelemetryToServiceEnabled(CosmosAsyncClient client);
List<String> getPreferredRegions(CosmosAsyncClient client);
Expand Down Expand Up @@ -1124,6 +1126,7 @@ public interface CosmosClientTelemetryConfigAccessor {
int getMaxConnectionPoolSize(CosmosClientTelemetryConfig config);
Duration getIdleHttpConnectionTimeout(CosmosClientTelemetryConfig config);
ProxyOptions getProxy(CosmosClientTelemetryConfig config);
EnumSet<MetricCategory> getMetricCategories(CosmosClientTelemetryConfig config);
EnumSet<TagName> getMetricTagNames(CosmosClientTelemetryConfig config);
String getClientCorrelationId(CosmosClientTelemetryConfig config);
MeterRegistry getClientMetricRegistry(CosmosClientTelemetryConfig config);
Expand Down
Expand Up @@ -163,6 +163,10 @@ public ClientTelemetryInfo getClientTelemetryInfo() {
return clientTelemetryInfo;
}

public CosmosClientTelemetryConfig getClientTelemetryConfig() {
return clientTelemetryConfig;
}

public static String getMachineId(DiagnosticsClientContext.DiagnosticsClientConfig diagnosticsClientConfig) {
AzureVMMetadata metadataSnapshot = azureVmMetaDataSingleton.get();

Expand Down