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

test: remove unnecessary custom app profile for metrics test #2436

Merged
merged 2 commits into from
Dec 3, 2024
Merged
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 @@ -24,10 +24,7 @@
import static com.google.common.truth.TruthJUnit.assume;

import com.google.api.client.util.Lists;
import com.google.cloud.bigtable.admin.v2.BigtableInstanceAdminClient;
import com.google.cloud.bigtable.admin.v2.BigtableTableAdminClient;
import com.google.cloud.bigtable.admin.v2.models.AppProfile;
import com.google.cloud.bigtable.admin.v2.models.CreateAppProfileRequest;
import com.google.cloud.bigtable.admin.v2.models.CreateTableRequest;
import com.google.cloud.bigtable.admin.v2.models.Table;
import com.google.cloud.bigtable.data.v2.BigtableDataClient;
Expand Down Expand Up @@ -94,12 +91,9 @@ public class BuiltinMetricsIT {
private BigtableDataClient clientCustomOtel;
private BigtableDataClient clientDefault;
private BigtableTableAdminClient tableAdminClient;
private BigtableInstanceAdminClient instanceAdminClient;
private MetricServiceClient metricClient;

private InMemoryMetricReader metricReader;
private String appProfileCustomOtel;
private String appProfileDefault;

public static String[] VIEWS = {
"operation_latencies",
Expand Down Expand Up @@ -131,19 +125,6 @@ public void setup() throws IOException {
metricClient = MetricServiceClient.create();

tableAdminClient = testEnvRule.env().getTableAdminClient();
instanceAdminClient = testEnvRule.env().getInstanceAdminClient();
appProfileCustomOtel = PrefixGenerator.newPrefix("test1");
appProfileDefault = PrefixGenerator.newPrefix("test2");
instanceAdminClient.createAppProfile(
CreateAppProfileRequest.of(testEnvRule.env().getInstanceId(), appProfileCustomOtel)
.setRoutingPolicy(
AppProfile.SingleClusterRoutingPolicy.of(testEnvRule.env().getPrimaryClusterId()))
.setIsolationPolicy(AppProfile.StandardIsolationPolicy.of(AppProfile.Priority.LOW)));
instanceAdminClient.createAppProfile(
CreateAppProfileRequest.of(testEnvRule.env().getInstanceId(), appProfileDefault)
.setRoutingPolicy(
AppProfile.SingleClusterRoutingPolicy.of(testEnvRule.env().getPrimaryClusterId()))
.setIsolationPolicy(AppProfile.StandardIsolationPolicy.of(AppProfile.Priority.LOW)));

// When using the custom OTEL instance, we can also register a InMemoryMetricReader on the
// SdkMeterProvider to verify the data exported on Cloud Monitoring with the in memory metric
Expand All @@ -162,9 +143,8 @@ public void setup() throws IOException {
BigtableDataClient.create(
settings
.setMetricsProvider(CustomOpenTelemetryMetricsProvider.create(openTelemetry))
.setAppProfileId(appProfileCustomOtel)
.build());
clientDefault = BigtableDataClient.create(settings.setAppProfileId(appProfileDefault).build());
clientDefault = BigtableDataClient.create(settings.build());
}

@After
Expand All @@ -178,12 +158,7 @@ public void tearDown() {
if (tableDefault != null) {
tableAdminClient.deleteTable(tableDefault.getId());
}
if (instanceAdminClient != null) {
instanceAdminClient.deleteAppProfile(
testEnvRule.env().getInstanceId(), appProfileCustomOtel, true);
instanceAdminClient.deleteAppProfile(
testEnvRule.env().getInstanceId(), appProfileDefault, true);
}

if (clientCustomOtel != null) {
clientCustomOtel.close();
}
Expand Down Expand Up @@ -231,8 +206,8 @@ public void testBuiltinMetricsWithDefaultOTEL() throws Exception {
String.format(
"metric.type=\"bigtable.googleapis.com/client/%s\" "
+ "AND resource.labels.instance=\"%s\" AND metric.labels.method=\"Bigtable.MutateRow\""
+ " AND resource.labels.table=\"%s\" AND metric.labels.app_profile=\"%s\"",
view, testEnvRule.env().getInstanceId(), tableDefault.getId(), appProfileDefault);
+ " AND resource.labels.table=\"%s\"",
view, testEnvRule.env().getInstanceId(), tableDefault.getId());
ListTimeSeriesRequest.Builder requestBuilder =
ListTimeSeriesRequest.newBuilder()
.setName(name.toString())
Expand All @@ -246,8 +221,8 @@ public void testBuiltinMetricsWithDefaultOTEL() throws Exception {
String.format(
"metric.type=\"bigtable.googleapis.com/client/%s\" "
+ "AND resource.labels.instance=\"%s\" AND metric.labels.method=\"Bigtable.ReadRows\""
+ " AND resource.labels.table=\"%s\" AND metric.labels.app_profile=\"%s\"",
view, testEnvRule.env().getInstanceId(), tableDefault.getId(), appProfileDefault);
+ " AND resource.labels.table=\"%s\"",
view, testEnvRule.env().getInstanceId(), tableDefault.getId());
requestBuilder.setFilter(metricFilter);

verifyMetricsArePublished(requestBuilder.build(), metricsPollingStopwatch, view);
Expand Down Expand Up @@ -299,11 +274,8 @@ public void testBuiltinMetricsWithCustomOTEL() throws Exception {
String.format(
"metric.type=\"bigtable.googleapis.com/client/%s\" "
+ "AND resource.labels.instance=\"%s\" AND metric.labels.method=\"Bigtable.MutateRow\""
+ " AND resource.labels.table=\"%s\" AND metric.labels.app_profile=\"%s\"",
view,
testEnvRule.env().getInstanceId(),
tableCustomOtel.getId(),
appProfileCustomOtel);
+ " AND resource.labels.table=\"%s\"",
view, testEnvRule.env().getInstanceId(), tableCustomOtel.getId());
ListTimeSeriesRequest.Builder requestBuilder =
ListTimeSeriesRequest.newBuilder()
.setName(name.toString())
Expand All @@ -320,11 +292,8 @@ public void testBuiltinMetricsWithCustomOTEL() throws Exception {
String.format(
"metric.type=\"bigtable.googleapis.com/client/%s\" "
+ "AND resource.labels.instance=\"%s\" AND metric.labels.method=\"Bigtable.ReadRows\""
+ " AND resource.labels.table=\"%s\" AND metric.labels.app_profile=\"%s\"",
view,
testEnvRule.env().getInstanceId(),
tableCustomOtel.getId(),
appProfileCustomOtel);
+ " AND resource.labels.table=\"%s\"",
view, testEnvRule.env().getInstanceId(), tableCustomOtel.getId());
requestBuilder.setFilter(metricFilter);

response = verifyMetricsArePublished(requestBuilder.build(), metricsPollingStopwatch, view);
Expand Down
Loading