-
Notifications
You must be signed in to change notification settings - Fork 102
Add CSM for batch write flow control #2685
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
Open
kongweihan
wants to merge
1
commit into
googleapis:main
Choose a base branch
from
kongweihan:csm-batch-write-flow-control
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -20,13 +20,11 @@ | |
| import com.google.common.collect.ImmutableMap; | ||
| import com.google.common.collect.ImmutableSet; | ||
| import io.opentelemetry.api.common.AttributeKey; | ||
| import io.opentelemetry.sdk.metrics.Aggregation; | ||
| import io.opentelemetry.sdk.metrics.InstrumentSelector; | ||
| import io.opentelemetry.sdk.metrics.InstrumentType; | ||
| import io.opentelemetry.sdk.metrics.View; | ||
| import io.opentelemetry.sdk.metrics.*; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. here also, no import * |
||
| import java.util.Map; | ||
| import java.util.Set; | ||
| import java.util.stream.Collectors; | ||
| import javax.annotation.Nullable; | ||
|
|
||
| /** Defining Bigtable builit-in metrics scope, attributes, metric names and views. */ | ||
| @InternalApi | ||
|
|
@@ -49,6 +47,7 @@ public class BuiltinMetricsConstants { | |
| static final AttributeKey<String> METHOD_KEY = AttributeKey.stringKey("method"); | ||
| static final AttributeKey<String> STATUS_KEY = AttributeKey.stringKey("status"); | ||
| static final AttributeKey<String> CLIENT_UID_KEY = AttributeKey.stringKey("client_uid"); | ||
| static final AttributeKey<Boolean> APPLIED_KEY = AttributeKey.booleanKey("applied"); | ||
kongweihan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| static final AttributeKey<String> TRANSPORT_TYPE = AttributeKey.stringKey("transport_type"); | ||
| static final AttributeKey<String> TRANSPORT_REGION = AttributeKey.stringKey("transport_region"); | ||
|
|
@@ -95,6 +94,9 @@ public class BuiltinMetricsConstants { | |
| static final String CLIENT_BLOCKING_LATENCIES_NAME = "throttling_latencies"; | ||
| static final String PER_CONNECTION_ERROR_COUNT_NAME = "per_connection_error_count"; | ||
| static final String OUTSTANDING_RPCS_PER_CHANNEL_NAME = "connection_pool/outstanding_rpcs"; | ||
| static final String BATCH_WRITE_FLOW_CONTROL_TARGET_QPS_NAME = | ||
| "batch_write_flow_control_target_qps"; | ||
| static final String BATCH_WRITE_FLOW_CONTROL_FACTOR_NAME = "batch_write_flow_control_factor"; | ||
|
|
||
| // Start allow list of metrics that will be exported as internal | ||
| public static final Map<String, Set<String>> GRPC_METRICS = | ||
|
|
@@ -210,6 +212,8 @@ public class BuiltinMetricsConstants { | |
| 70.0, 75.0, 80.0, 85.0, 90.0, 95.0, 100.0, 105.0, 110.0, 115.0, 120.0, 125.0, 130.0, | ||
| 135.0, 140.0, 145.0, 150.0, 155.0, 160.0, 165.0, 170.0, 175.0, 180.0, 185.0, 190.0, | ||
| 195.0, 200.0)); | ||
| private static final Aggregation AGGREGATION_BATCH_WRITE_FLOW_CONTROL_FACTOR_HISTOGRAM = | ||
| Aggregation.explicitBucketHistogram(ImmutableList.of(0.7, 0.8, 0.9, 1.0, 1.1, 1.2, 1.3)); | ||
|
|
||
| static final Set<AttributeKey> COMMON_ATTRIBUTES = | ||
| ImmutableSet.of( | ||
|
|
@@ -225,7 +229,7 @@ public class BuiltinMetricsConstants { | |
| static void defineView( | ||
| ImmutableMap.Builder<InstrumentSelector, View> viewMap, | ||
| String id, | ||
| Aggregation aggregation, | ||
| @Nullable Aggregation aggregation, | ||
| InstrumentType type, | ||
| String unit, | ||
| Set<AttributeKey> attributes) { | ||
|
|
@@ -242,14 +246,12 @@ static void defineView( | |
| COMMON_ATTRIBUTES.stream().map(AttributeKey::getKey).collect(Collectors.toSet())) | ||
| .addAll(attributes.stream().map(AttributeKey::getKey).collect(Collectors.toSet())) | ||
| .build(); | ||
| View view = | ||
| View.builder() | ||
| .setName(METER_NAME + id) | ||
| .setAggregation(aggregation) | ||
| .setAttributeFilter(attributesFilter) | ||
| .build(); | ||
|
|
||
| viewMap.put(selector, view); | ||
| ViewBuilder viewBuilder = | ||
| View.builder().setName(METER_NAME + id).setAttributeFilter(attributesFilter); | ||
| if (aggregation != null) { | ||
| viewBuilder.setAggregation(aggregation); | ||
| } | ||
| viewMap.put(selector, viewBuilder.build()); | ||
| } | ||
|
|
||
| // uses cloud.BigtableClient schema | ||
|
|
@@ -367,7 +369,23 @@ public static Map<InstrumentSelector, View> getAllViews() { | |
| .addAll(COMMON_ATTRIBUTES) | ||
| .add(STREAMING_KEY, STATUS_KEY) | ||
| .build()); | ||
|
|
||
| defineView( | ||
| views, | ||
| BATCH_WRITE_FLOW_CONTROL_TARGET_QPS_NAME, | ||
| null, | ||
| InstrumentType.GAUGE, | ||
| "1", | ||
| ImmutableSet.<AttributeKey>builder().addAll(COMMON_ATTRIBUTES).build()); | ||
| defineView( | ||
| views, | ||
| BATCH_WRITE_FLOW_CONTROL_FACTOR_NAME, | ||
| AGGREGATION_BATCH_WRITE_FLOW_CONTROL_FACTOR_HISTOGRAM, | ||
| InstrumentType.HISTOGRAM, | ||
| "1", | ||
| ImmutableSet.<AttributeKey>builder() | ||
| .addAll(COMMON_ATTRIBUTES) | ||
| .add(STATUS_KEY, APPLIED_KEY) | ||
| .build()); | ||
| return views.build(); | ||
| } | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think you need this import anymore? You can run
mvn com.spotify.fmt:fmt-maven-plugin:formatand that should clean up the unused imports.