-
Notifications
You must be signed in to change notification settings - Fork 94
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
feat: add response protos #1246
Merged
Merged
Changes from 16 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
519dac9
feat: add built in metrics measure and views
mutianf 8dc5cce
remove status from application latency
mutianf 872c4c2
feat: update tracers to use built in metrics
mutianf 35418b2
feat: add response protos
mutianf c81f323
fix broken tests
mutianf 023cebd
remove unused code
mutianf 1fa3008
clean up
mutianf 2a86c37
add integration test
mutianf 509ffdc
add integration tests and fix unit tests
mutianf 544b35d
revert proto changes
mutianf 8c78b21
fix license
mutianf 7ec4c8c
add debug log
mutianf 8363b0a
test
mutianf 919dbc5
update
mutianf e6b0d8d
fix integration tests
mutianf 35c5a16
fix dependency plugin
mutianf 267c91c
fix pom and update annotation
mutianf edbb528
🦉 Updates from OwlBot post-processor
gcf-owl-bot[bot] 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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,8 +19,12 @@ | |
|
||
import com.google.api.core.InternalApi; | ||
import com.google.api.gax.tracing.SpanName; | ||
import com.google.common.annotations.VisibleForTesting; | ||
import io.opencensus.stats.Stats; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.stream.Collectors; | ||
|
||
/** | ||
* Wrapper class for accessing opencensus. We use a shaded version of opencensus to avoid polluting | ||
|
@@ -34,4 +38,16 @@ public static StatsRecorderWrapper createRecorder( | |
return new StatsRecorderWrapper( | ||
operationType, spanName, statsAttributes, Stats.getStatsRecorder()); | ||
} | ||
|
||
// This is used in integration tests to get the tag value strings from view manager because Stats | ||
// is relocated to com.google.bigtable.veneer.repackaged.io.opencensus. | ||
@VisibleForTesting | ||
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. Please use InternalApi("Visible for testing"). We arent supposed to expose guava on our public surface |
||
public static List<String> getOperationLatencyViewTagValueStrings() { | ||
return Stats.getViewManager().getView(BuiltinViewConstants.OPERATION_LATENCIES_VIEW.getName()) | ||
.getAggregationMap().entrySet().stream() | ||
.map(Map.Entry::getKey) | ||
.flatMap(x -> x.stream()) | ||
.map(x -> x.asString()) | ||
.collect(Collectors.toCollection(ArrayList::new)); | ||
} | ||
} |
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
90 changes: 90 additions & 0 deletions
90
...gtable/src/test/java/com/google/cloud/bigtable/data/v2/it/StreamingMetricsMetadataIT.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,90 @@ | ||
/* | ||
* Copyright 2022 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.google.cloud.bigtable.data.v2.it; | ||
|
||
import static com.google.common.truth.Truth.assertThat; | ||
import static com.google.common.truth.TruthJUnit.assume; | ||
|
||
import com.google.api.core.ApiFuture; | ||
import com.google.api.gax.rpc.NotFoundException; | ||
import com.google.cloud.bigtable.admin.v2.models.Cluster; | ||
import com.google.cloud.bigtable.data.v2.models.Query; | ||
import com.google.cloud.bigtable.data.v2.models.Row; | ||
import com.google.cloud.bigtable.stats.BuiltinViews; | ||
import com.google.cloud.bigtable.stats.StatsWrapper; | ||
import com.google.cloud.bigtable.test_helpers.env.EmulatorEnv; | ||
import com.google.cloud.bigtable.test_helpers.env.TestEnvRule; | ||
import com.google.common.collect.Lists; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.UUID; | ||
import java.util.concurrent.TimeUnit; | ||
import org.junit.BeforeClass; | ||
import org.junit.ClassRule; | ||
import org.junit.Test; | ||
|
||
public class StreamingMetricsMetadataIT { | ||
@ClassRule public static TestEnvRule testEnvRule = new TestEnvRule(); | ||
|
||
@BeforeClass | ||
public static void setUpClass() { | ||
assume() | ||
.withMessage("StreamingMetricsMetadataIT is not supported on Emulator") | ||
.that(testEnvRule.env()) | ||
.isNotInstanceOf(EmulatorEnv.class); | ||
BuiltinViews.registerBigtableBuiltinViews(); | ||
} | ||
|
||
@Test | ||
public void testSuccess() throws Exception { | ||
String prefix = UUID.randomUUID().toString(); | ||
String uniqueKey = prefix + "-read"; | ||
|
||
Query query = Query.create(testEnvRule.env().getTableId()).rowKey(uniqueKey); | ||
ArrayList<Row> rows = Lists.newArrayList(testEnvRule.env().getDataClient().readRows(query)); | ||
|
||
ApiFuture<List<Cluster>> clustersFuture = | ||
testEnvRule | ||
.env() | ||
.getInstanceAdminClient() | ||
.listClustersAsync(testEnvRule.env().getInstanceId()); | ||
|
||
List<Cluster> clusters = clustersFuture.get(1, TimeUnit.MINUTES); | ||
|
||
// give opencensus some time to populate view data | ||
Thread.sleep(100); | ||
|
||
List<String> tagValueStrings = StatsWrapper.getOperationLatencyViewTagValueStrings(); | ||
assertThat(tagValueStrings).contains(clusters.get(0).getZone()); | ||
assertThat(tagValueStrings).contains(clusters.get(0).getId()); | ||
} | ||
|
||
@Test | ||
public void testFailure() throws InterruptedException { | ||
Query query = Query.create("non-exist-table"); | ||
try { | ||
Lists.newArrayList(testEnvRule.env().getDataClient().readRows(query)); | ||
} catch (NotFoundException e) { | ||
} | ||
|
||
// give opencensus some time to populate view data | ||
Thread.sleep(100); | ||
|
||
List<String> tagValueStrings = StatsWrapper.getOperationLatencyViewTagValueStrings(); | ||
assertThat(tagValueStrings).contains("undefined"); | ||
assertThat(tagValueStrings).contains("undefined"); | ||
} | ||
} |
100 changes: 100 additions & 0 deletions
100
...d-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/it/UnaryMetricsMetadataIT.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,100 @@ | ||
/* | ||
* Copyright 2022 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.google.cloud.bigtable.data.v2.it; | ||
|
||
import static com.google.common.truth.Truth.assertThat; | ||
import static com.google.common.truth.TruthJUnit.assume; | ||
|
||
import com.google.api.core.ApiFuture; | ||
import com.google.api.gax.rpc.NotFoundException; | ||
import com.google.cloud.bigtable.admin.v2.models.Cluster; | ||
import com.google.cloud.bigtable.data.v2.models.RowMutation; | ||
import com.google.cloud.bigtable.stats.BuiltinViews; | ||
import com.google.cloud.bigtable.stats.StatsWrapper; | ||
import com.google.cloud.bigtable.test_helpers.env.EmulatorEnv; | ||
import com.google.cloud.bigtable.test_helpers.env.TestEnvRule; | ||
import java.util.List; | ||
import java.util.UUID; | ||
import java.util.concurrent.TimeUnit; | ||
import org.junit.BeforeClass; | ||
import org.junit.ClassRule; | ||
import org.junit.Test; | ||
|
||
public class UnaryMetricsMetadataIT { | ||
@ClassRule public static TestEnvRule testEnvRule = new TestEnvRule(); | ||
|
||
@BeforeClass | ||
public static void setUpClass() { | ||
assume() | ||
.withMessage("UnaryMetricsMetadataIT is not supported on Emulator") | ||
.that(testEnvRule.env()) | ||
.isNotInstanceOf(EmulatorEnv.class); | ||
BuiltinViews.registerBigtableBuiltinViews(); | ||
} | ||
|
||
@Test | ||
public void testSuccess() throws Exception { | ||
String rowKey = UUID.randomUUID().toString(); | ||
String familyId = testEnvRule.env().getFamilyId(); | ||
|
||
ApiFuture<Void> future = | ||
testEnvRule | ||
.env() | ||
.getDataClient() | ||
.mutateRowCallable() | ||
.futureCall( | ||
RowMutation.create(testEnvRule.env().getTableId(), rowKey) | ||
.setCell(familyId, "q", "myVal")); | ||
|
||
future.get(1, TimeUnit.MINUTES); | ||
|
||
ApiFuture<List<Cluster>> clustersFuture = | ||
testEnvRule | ||
.env() | ||
.getInstanceAdminClient() | ||
.listClustersAsync(testEnvRule.env().getInstanceId()); | ||
List<Cluster> clusters = clustersFuture.get(1, TimeUnit.MINUTES); | ||
|
||
// give opencensus some time to populate view data | ||
Thread.sleep(100); | ||
|
||
List<String> tagValueStrings = StatsWrapper.getOperationLatencyViewTagValueStrings(); | ||
assertThat(tagValueStrings).contains(clusters.get(0).getZone()); | ||
assertThat(tagValueStrings).contains(clusters.get(0).getId()); | ||
} | ||
|
||
@Test | ||
public void testFailure() throws InterruptedException { | ||
String rowKey = UUID.randomUUID().toString(); | ||
String familyId = testEnvRule.env().getFamilyId(); | ||
|
||
try { | ||
testEnvRule | ||
.env() | ||
.getDataClient() | ||
.mutateRowCallable() | ||
.call(RowMutation.create("non-exist-table", rowKey).setCell(familyId, "q", "myVal")); | ||
} catch (NotFoundException e) { | ||
} | ||
|
||
// give opencensus some time to populate view data | ||
Thread.sleep(100); | ||
|
||
List<String> tagValueStrings = StatsWrapper.getOperationLatencyViewTagValueStrings(); | ||
assertThat(tagValueStrings).contains("undefined"); | ||
assertThat(tagValueStrings).contains("undefined"); | ||
} | ||
} |
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.
Lets pull this up to the root pom