Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
mutianf committed Oct 28, 2024
1 parent f135428 commit 384c01c
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,9 @@ static String getProjectId(PointData pointData) {
return pointData.getAttributes().get(BIGTABLE_PROJECT_ID_KEY);
}

// Returns a list of timeseries by project id
static Map<String, List<TimeSeries>> convertToBigtableTimeSeries(
List<MetricData> collection, String taskId) {
// List of timeseries by project id
Map<String, List<TimeSeries>> allTimeSeries = new HashMap<>();

for (MetricData metricData : collection) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,15 @@
*/
package com.google.cloud.bigtable.data.v2.stub.metrics;

import com.google.auth.oauth2.GoogleCredentials;
import com.google.auth.Credentials;
import com.google.cloud.NoCredentials;
import com.google.common.collect.ImmutableMap;
import io.opentelemetry.api.OpenTelemetry;
import java.io.IOException;
import java.net.URI;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
Expand All @@ -38,8 +43,7 @@ public void test() throws IOException {
// different endpoint and credential should return a different instance
OpenTelemetry otel3 = provider.getOpenTelemetry(null, null);
// same endpoint, different credential, should return a different instance
OpenTelemetry otel4 =
provider.getOpenTelemetry("fake-endpoint:123", GoogleCredentials.getApplicationDefault());
OpenTelemetry otel4 = provider.getOpenTelemetry("fake-endpoint:123", new FakeCredentials());
// everything is the same, should return the same instance
OpenTelemetry otel5 =
provider.getOpenTelemetry("fake-endpoint:123", NoCredentials.getInstance());
Expand All @@ -51,4 +55,29 @@ public void test() throws IOException {

provider.toString();
}

private static class FakeCredentials extends Credentials {
@Override
public String getAuthenticationType() {
return "fake";
}

@Override
public Map<String, List<String>> getRequestMetadata(URI uri) throws IOException {
return ImmutableMap.of("my-header", Arrays.asList("fake-credential"));
}

@Override
public boolean hasRequestMetadata() {
return true;
}

@Override
public boolean hasRequestMetadataOnly() {
return true;
}

@Override
public void refresh() throws IOException {}
}
}

0 comments on commit 384c01c

Please sign in to comment.