|
65 | 65 | import java.util.Set;
|
66 | 66 | import java.util.logging.Logger;
|
67 | 67 | import javax.annotation.Nonnull;
|
| 68 | +import javax.annotation.Nullable; |
68 | 69 | import org.threeten.bp.Duration;
|
69 | 70 |
|
70 | 71 | /**
|
@@ -250,6 +251,7 @@ public class EnhancedBigtableStubSettings extends StubSettings<EnhancedBigtableS
|
250 | 251 | private final FeatureFlags featureFlags;
|
251 | 252 |
|
252 | 253 | private final MetricsProvider metricsProvider;
|
| 254 | + @Nullable private final String metricsEndpoint; |
253 | 255 |
|
254 | 256 | private EnhancedBigtableStubSettings(Builder builder) {
|
255 | 257 | super(builder);
|
@@ -278,6 +280,7 @@ private EnhancedBigtableStubSettings(Builder builder) {
|
278 | 280 | enableRoutingCookie = builder.enableRoutingCookie;
|
279 | 281 | enableRetryInfo = builder.enableRetryInfo;
|
280 | 282 | metricsProvider = builder.metricsProvider;
|
| 283 | + metricsEndpoint = builder.metricsEndpoint; |
281 | 284 |
|
282 | 285 | // Per method settings.
|
283 | 286 | readRowsSettings = builder.readRowsSettings.build();
|
@@ -362,6 +365,15 @@ public boolean getEnableRetryInfo() {
|
362 | 365 | return enableRetryInfo;
|
363 | 366 | }
|
364 | 367 |
|
| 368 | + /** |
| 369 | + * Gets the Google Cloud Monitoring endpoint for publishing client side metrics. If it's null, |
| 370 | + * client will publish metrics to the default monitoring endpoint. |
| 371 | + */ |
| 372 | + @Nullable |
| 373 | + public String getMetricsEndpoint() { |
| 374 | + return metricsEndpoint; |
| 375 | + } |
| 376 | + |
365 | 377 | /** Returns a builder for the default ChannelProvider for this service. */
|
366 | 378 | public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() {
|
367 | 379 | Boolean isDirectpathEnabled = Boolean.parseBoolean(System.getenv(CBT_ENABLE_DIRECTPATH));
|
@@ -684,6 +696,7 @@ public static class Builder extends StubSettings.Builder<EnhancedBigtableStubSet
|
684 | 696 | private FeatureFlags.Builder featureFlags;
|
685 | 697 |
|
686 | 698 | private MetricsProvider metricsProvider;
|
| 699 | + @Nullable private String metricsEndpoint; |
687 | 700 |
|
688 | 701 | /**
|
689 | 702 | * Initializes a new Builder with sane defaults for all settings.
|
@@ -831,6 +844,7 @@ private Builder(EnhancedBigtableStubSettings settings) {
|
831 | 844 | enableRoutingCookie = settings.enableRoutingCookie;
|
832 | 845 | enableRetryInfo = settings.enableRetryInfo;
|
833 | 846 | metricsProvider = settings.metricsProvider;
|
| 847 | + metricsEndpoint = settings.getMetricsEndpoint(); |
834 | 848 |
|
835 | 849 | // Per method settings.
|
836 | 850 | readRowsSettings = settings.readRowsSettings.toBuilder();
|
@@ -999,6 +1013,24 @@ public MetricsProvider getMetricsProvider() {
|
999 | 1013 | return this.metricsProvider;
|
1000 | 1014 | }
|
1001 | 1015 |
|
| 1016 | + /** |
| 1017 | + * Built-in client side metrics are published through Google Cloud Monitoring endpoint. This |
| 1018 | + * setting overrides the default endpoint for publishing the metrics. |
| 1019 | + */ |
| 1020 | + public Builder setMetricsEndpoint(String endpoint) { |
| 1021 | + this.metricsEndpoint = endpoint; |
| 1022 | + return this; |
| 1023 | + } |
| 1024 | + |
| 1025 | + /** |
| 1026 | + * Get the Google Cloud Monitoring endpoint for publishing client side metrics. If it's null, |
| 1027 | + * client will publish metrics to the default monitoring endpoint. |
| 1028 | + */ |
| 1029 | + @Nullable |
| 1030 | + public String getMetricsEndpoint() { |
| 1031 | + return metricsEndpoint; |
| 1032 | + } |
| 1033 | + |
1002 | 1034 | @InternalApi("Used for internal testing")
|
1003 | 1035 | public Map<String, String> getJwtAudienceMapping() {
|
1004 | 1036 | return jwtAudienceMapping;
|
@@ -1184,6 +1216,7 @@ public String toString() {
|
1184 | 1216 | .add("pingAndWarmSettings", pingAndWarmSettings)
|
1185 | 1217 | .add("executeQuerySettings", executeQuerySettings)
|
1186 | 1218 | .add("metricsProvider", metricsProvider)
|
| 1219 | + .add("metricsEndpoint", metricsEndpoint) |
1187 | 1220 | .add("parent", super.toString())
|
1188 | 1221 | .toString();
|
1189 | 1222 | }
|
|
0 commit comments