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

chore: disable native metrics when there are no credentials #3567

Merged
merged 2 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
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 @@ -83,6 +83,7 @@
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledThreadPoolExecutor;
Expand Down Expand Up @@ -1791,6 +1792,10 @@ public CallCredentialsProvider getCallCredentialsProvider() {
return callCredentialsProvider;
}

private boolean usesNoCredentials() {
return Objects.equals(getCredentials(), NoCredentials.getInstance());
}

public String getCompressorName() {
return compressorName;
}
Expand Down Expand Up @@ -1838,7 +1843,7 @@ private ApiTracerFactory createApiTracerFactory(

// Add Metrics Tracer factory if built in metrics are enabled and if the client is data client
// and if emulator is not enabled.
if (isEnableBuiltInMetrics() && !isAdminClient && !isEmulatorEnabled) {
if (isEnableBuiltInMetrics() && !isAdminClient && !isEmulatorEnabled && !usesNoCredentials()) {
ApiTracerFactory metricsTracerFactory = createMetricsApiTracerFactory();
if (metricsTracerFactory != null) {
apiTracerFactories.add(metricsTracerFactory);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -738,7 +738,7 @@ public void testLeaderAwareRoutingEnablement() {

@Test
public void testEndToEndTracingEnablement() {
// Test that end to end tracing is disabled by default.
// Test that end-to-end tracing is disabled by default.
assertFalse(SpannerOptions.newBuilder().setProjectId("p").build().isEndToEndTracingEnabled());
assertTrue(
SpannerOptions.newBuilder()
Expand All @@ -755,7 +755,7 @@ public void testEndToEndTracingEnablement() {
}

@Test
public void testmonitoringHost() {
public void testMonitoringHost() {
String metricsEndpoint = "test-endpoint:443";
assertNull(SpannerOptions.newBuilder().setProjectId("p").build().getMonitoringHost());
assertThat(
Expand Down
Loading