From 117c279a59890163c6895a8ef6b4900cd64e2a26 Mon Sep 17 00:00:00 2001 From: Naresh Chaudhary Date: Thu, 26 Sep 2024 12:58:23 +0000 Subject: [PATCH] Rename spanner tracing to end to end tracing --- .../clirr-ignored-differences.xml | 4 +- .../google/cloud/spanner/SpannerOptions.java | 38 +++++++++--------- .../cloud/spanner/spi/v1/GapicSpannerRpc.java | 10 ++--- .../spi/v1/SpannerInterceptorProvider.java | 4 +- .../spi/v1/SpannerMetadataProvider.java | 10 ++--- .../cloud/spanner/SpannerOptionsTest.java | 12 +++--- .../spanner/spi/v1/GapicSpannerRpcTest.java | 40 +++++++++---------- .../spi/v1/SpannerMetadataProviderTest.java | 2 +- 8 files changed, 60 insertions(+), 60 deletions(-) diff --git a/google-cloud-spanner/clirr-ignored-differences.xml b/google-cloud-spanner/clirr-ignored-differences.xml index 549eefaca6e..8e7a392302a 100644 --- a/google-cloud-spanner/clirr-ignored-differences.xml +++ b/google-cloud-spanner/clirr-ignored-differences.xml @@ -695,11 +695,11 @@ boolean isEnableApiTracing() - + 7012 com/google/cloud/spanner/SpannerOptions$SpannerEnvironment - boolean isEnableSpannerTracing() + boolean isEnableEndToEndTracing() diff --git a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/SpannerOptions.java b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/SpannerOptions.java index 767b617435a..b4631243e4d 100644 --- a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/SpannerOptions.java +++ b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/SpannerOptions.java @@ -163,7 +163,7 @@ public class SpannerOptions extends ServiceOptions { private final boolean enableApiTracing; private final boolean enableBuiltInMetrics; private final boolean enableExtendedTracing; - private final boolean enableSpannerTracing; + private final boolean enableEndToEndTracing; enum TracingFramework { OPEN_CENSUS, @@ -671,7 +671,7 @@ protected SpannerOptions(Builder builder) { enableApiTracing = builder.enableApiTracing; enableExtendedTracing = builder.enableExtendedTracing; enableBuiltInMetrics = builder.enableBuiltInMetrics; - enableSpannerTracing = builder.enableSpannerTracing; + enableEndToEndTracing = builder.enableEndToEndTracing; } /** @@ -709,7 +709,7 @@ default boolean isEnableBuiltInMetrics() { return false; } - default boolean isEnableSpannerTracing() { + default boolean isEnableEndToEndTracing() { return false; } } @@ -726,8 +726,8 @@ private static class SpannerEnvironmentImpl implements SpannerEnvironment { private static final String SPANNER_ENABLE_EXTENDED_TRACING = "SPANNER_ENABLE_EXTENDED_TRACING"; private static final String SPANNER_ENABLE_API_TRACING = "SPANNER_ENABLE_API_TRACING"; private static final String SPANNER_ENABLE_BUILTIN_METRICS = "SPANNER_ENABLE_BUILTIN_METRICS"; - private static final String SPANNER_ENABLE_SPANNER_TRACING = - "SPANNER_ENABLE_SPANNER_TRACING"; + private static final String SPANNER_ENABLE_END_TO_END_TRACING = + "SPANNER_ENABLE_END_TO_END_TRACING"; private SpannerEnvironmentImpl() {} @@ -762,8 +762,8 @@ public boolean isEnableBuiltInMetrics() { } @Override - public boolean isEnableSpannerTracing() { - return Boolean.parseBoolean(System.getenv(SPANNER_ENABLE_SPANNER_TRACING)); + public boolean isEnableEndToEndTracing() { + return Boolean.parseBoolean(System.getenv(SPANNER_ENABLE_END_TO_END_TRACING)); } } @@ -829,8 +829,8 @@ public static class Builder private boolean enableApiTracing = SpannerOptions.environment.isEnableApiTracing(); private boolean enableExtendedTracing = SpannerOptions.environment.isEnableExtendedTracing(); private boolean enableBuiltInMetrics = SpannerOptions.environment.isEnableBuiltInMetrics(); - private boolean enableSpannerTracing = - SpannerOptions.environment.isEnableSpannerTracing(); + private boolean enableEndToEndTracing = + SpannerOptions.environment.isEnableEndToEndTracing(); private static String createCustomClientLibToken(String token) { return token + " " + ServiceOptions.getGoogApiClientLibName(); @@ -897,7 +897,7 @@ protected Builder() { this.enableApiTracing = options.enableApiTracing; this.enableExtendedTracing = options.enableExtendedTracing; this.enableBuiltInMetrics = options.enableBuiltInMetrics; - this.enableSpannerTracing = options.enableSpannerTracing; + this.enableEndToEndTracing = options.enableEndToEndTracing; } @Override @@ -1432,13 +1432,13 @@ public Builder setEnableExtendedTracing(boolean enableExtendedTracing) { } /** - * Sets whether to enable Spanner tracing. Enabling this option will create the trace - * spans at the Spanner layer. By default, spanner tracing is disabled. Enabling spanner - * tracing requires OpenTelemetry to be set up properly. Simply enabling this option - * won't generate spanner traces. + * Sets whether to enable end to end tracing. Enabling this option will create the + * trace spans at the Spanner layer. By default, end to end tracing is disabled. + * Enabling end to end tracing requires OpenTelemetry to be set up properly. Simply + * enabling this option won't generate traces at Spanner layer. */ - public Builder setEnableSpannerTracing(boolean enableSpannerTracing) { - this.enableSpannerTracing = enableSpannerTracing; + public Builder setEnableEndToEndTracing(boolean enableEndToEndTracing) { + this.enableEndToEndTracing = enableEndToEndTracing; return this; } @@ -1774,11 +1774,11 @@ public boolean isEnableExtendedTracing() { } /** - * Returns whether Spanner tracing is enabled. If this option is enabled then trace spans + * Returns whether end to end tracing is enabled. If this option is enabled then trace spans * will be created at the Spanner layer. */ - public boolean isSpannerTracingEnabled() { - return enableSpannerTracing; + public boolean isEndToEndTracingEnabled() { + return enableEndToEndTracing; } /** Returns the default query options to use for the specific database. */ diff --git a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/spi/v1/GapicSpannerRpc.java b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/spi/v1/GapicSpannerRpc.java index 1db93fadf9d..2360b5d5173 100644 --- a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/spi/v1/GapicSpannerRpc.java +++ b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/spi/v1/GapicSpannerRpc.java @@ -272,7 +272,7 @@ public class GapicSpannerRpc implements SpannerRpc { private static final ConcurrentMap ADMINISTRATIVE_REQUESTS_RATE_LIMITERS = new ConcurrentHashMap<>(); private final boolean leaderAwareRoutingEnabled; - private final boolean spannerTracingEnabled; + private final boolean endToEndTracingEnabled; private final int numChannels; private final boolean isGrpcGcpExtensionEnabled; @@ -326,7 +326,7 @@ public GapicSpannerRpc(final SpannerOptions options) { this.callCredentialsProvider = options.getCallCredentialsProvider(); this.compressorName = options.getCompressorName(); this.leaderAwareRoutingEnabled = options.isLeaderAwareRoutingEnabled(); - this.spannerTracingEnabled = options.isSpannerTracingEnabled(); + this.endToEndTracingEnabled = options.isEndToEndTracingEnabled(); this.numChannels = options.getNumChannels(); this.isGrpcGcpExtensionEnabled = options.isGrpcGcpExtensionEnabled(); @@ -353,7 +353,7 @@ public GapicSpannerRpc(final SpannerOptions options) { options.getInterceptorProvider(), SpannerInterceptorProvider.createDefault(options.getOpenTelemetry()))) // This sets the trace context headers. - .withTraceContext(spannerTracingEnabled, options.getOpenTelemetry()) + .withTraceContext(endToEndTracingEnabled, options.getOpenTelemetry()) // This sets the response compressor (Server -> Client). .withEncoding(compressorName)) .setHeaderProvider(headerProviderWithUserAgent) @@ -2011,8 +2011,8 @@ GrpcCallContext newCallContext( if (routeToLeader && leaderAwareRoutingEnabled) { context = context.withExtraHeaders(metadataProvider.newRouteToLeaderHeader()); } - if (spannerTracingEnabled) { - context = context.withExtraHeaders(metadataProvider.newSpannerTracingHeader()); + if (endToEndTracingEnabled) { + context = context.withExtraHeaders(metadataProvider.newEndToEndTracingHeader()); } if (callCredentialsProvider != null) { CallCredentials callCredentials = callCredentialsProvider.getCallCredentials(); diff --git a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/spi/v1/SpannerInterceptorProvider.java b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/spi/v1/SpannerInterceptorProvider.java index ee8ac7237b9..b4d28ef0789 100644 --- a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/spi/v1/SpannerInterceptorProvider.java +++ b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/spi/v1/SpannerInterceptorProvider.java @@ -75,8 +75,8 @@ SpannerInterceptorProvider withEncoding(String encoding) { } SpannerInterceptorProvider withTraceContext( - boolean spannerTracingEnabled, OpenTelemetry openTelemetry) { - if (spannerTracingEnabled) { + boolean endToEndTracingEnabled, OpenTelemetry openTelemetry) { + if (endToEndTracingEnabled) { return with(new TraceContextInterceptor(openTelemetry)); } return this; diff --git a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/spi/v1/SpannerMetadataProvider.java b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/spi/v1/SpannerMetadataProvider.java index 7dc2e5ab154..2ebc4925788 100644 --- a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/spi/v1/SpannerMetadataProvider.java +++ b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/spi/v1/SpannerMetadataProvider.java @@ -37,7 +37,7 @@ class SpannerMetadataProvider { private final Map, String> headers; private final String resourceHeaderKey; private static final String ROUTE_TO_LEADER_HEADER_KEY = "x-goog-spanner-route-to-leader"; - private static final String SPANNER_TRACING_HEADER_KEY = "x-goog-spanner-end-to-end-tracing"; + private static final String END_TO_END_TRACING_HEADER_KEY = "x-goog-spanner-end-to-end-tracing"; private static final Pattern[] RESOURCE_TOKEN_PATTERNS = { Pattern.compile("^(?projects/[^/]*/instances/[^/]*/databases/[^/]*)(.*)?"), Pattern.compile("^(?projects/[^/]*/instances/[^/]*)(.*)?") @@ -45,8 +45,8 @@ class SpannerMetadataProvider { private static final Map> ROUTE_TO_LEADER_HEADER_MAP = ImmutableMap.of(ROUTE_TO_LEADER_HEADER_KEY, Collections.singletonList("true")); - private static final Map> SPANNER_TRACING_HEADER_MAP = - ImmutableMap.of(SPANNER_TRACING_HEADER_KEY, Collections.singletonList("true")); + private static final Map> END_TO_END_TRACING_HEADER_MAP = + ImmutableMap.of(END_TO_END_TRACING_HEADER_KEY, Collections.singletonList("true")); private SpannerMetadataProvider(Map headers, String resourceHeaderKey) { this.resourceHeaderKey = resourceHeaderKey; @@ -92,8 +92,8 @@ Map> newRouteToLeaderHeader() { return ROUTE_TO_LEADER_HEADER_MAP; } - Map> newSpannerTracingHeader() { - return SPANNER_TRACING_HEADER_MAP; + Map> newEndToEndTracingHeader() { + return END_TO_END_TRACING_HEADER_MAP; } private Map, String> constructHeadersAsMetadata( diff --git a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/SpannerOptionsTest.java b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/SpannerOptionsTest.java index 4d9776fe6ec..e8421cd235c 100644 --- a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/SpannerOptionsTest.java +++ b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/SpannerOptionsTest.java @@ -737,21 +737,21 @@ public void testLeaderAwareRoutingEnablement() { } @Test - public void testSpannerTracingEnablement() { + public void testEndToEndTracingEnablement() { // Test that end to end tracing is disabled by default. - assertFalse(SpannerOptions.newBuilder().setProjectId("p").build().isSpannerTracingEnabled()); + assertFalse(SpannerOptions.newBuilder().setProjectId("p").build().isEndToEndTracingEnabled()); assertTrue( SpannerOptions.newBuilder() .setProjectId("p") - .setEnableSpannerTracing(true) + .setEnableEndToEndTracing(true) .build() - .isSpannerTracingEnabled()); + .isEndToEndTracingEnabled()); assertFalse( SpannerOptions.newBuilder() .setProjectId("p") - .setEnableSpannerTracing(false) + .setEnableEndToEndTracing(false) .build() - .isSpannerTracingEnabled()); + .isEndToEndTracingEnabled()); } @Test diff --git a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/spi/v1/GapicSpannerRpcTest.java b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/spi/v1/GapicSpannerRpcTest.java index d2760e012be..af459a44e21 100644 --- a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/spi/v1/GapicSpannerRpcTest.java +++ b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/spi/v1/GapicSpannerRpcTest.java @@ -155,7 +155,7 @@ public class GapicSpannerRpcTest { private static String defaultUserAgent; private static Spanner spanner; private static boolean isRouteToLeader; - private static boolean isSpannerTracing; + private static boolean isEndToEndTracing; private static boolean isTraceContextPresent; @Parameter public Dialect dialect; @@ -215,16 +215,16 @@ public ServerCall.Listener interceptCall( Key.of( "x-goog-spanner-route-to-leader", Metadata.ASCII_STRING_MARSHALLER)); - String spannerTracingHeader = + String endToEndTracingHeader = headers.get( Key.of( "x-goog-spanner-end-to-end-tracing", Metadata.ASCII_STRING_MARSHALLER)); isRouteToLeader = (routeToLeaderHeader != null && routeToLeaderHeader.equals("true")); - isSpannerTracing = - (spannerTracingHeader != null - && spannerTracingHeader.equals("true")); + isEndToEndTracing = + (endToEndTracingHeader != null + && endToEndTracingHeader.equals("true")); } return Contexts.interceptCall(Context.current(), call, headers, next); } @@ -248,7 +248,7 @@ public void reset() throws InterruptedException { server.awaitTermination(); } isRouteToLeader = false; - isSpannerTracing = false; + isEndToEndTracing = false; isTraceContextPresent = false; } @@ -491,11 +491,11 @@ public void testNewCallContextWithRouteToLeaderHeaderAndLarDisabled() { } @Test - public void testNewCallContextWithSpannerTracingHeader() { + public void testNewCallContextWithEndToEndTracingHeader() { SpannerOptions options = SpannerOptions.newBuilder() .setProjectId("some-project") - .setEnableSpannerTracing(true) + .setEnableEndToEndTracing(true) .build(); GapicSpannerRpc rpc = new GapicSpannerRpc(options, false); GrpcCallContext callContext = @@ -515,11 +515,11 @@ public void testNewCallContextWithSpannerTracingHeader() { } @Test - public void testNewCallContextWithoutSpannerTracingHeader() { + public void testNewCallContextWithoutEndToEndTracingHeader() { SpannerOptions options = SpannerOptions.newBuilder() .setProjectId("some-project") - .setEnableSpannerTracing(false) + .setEnableEndToEndTracing(false) .build(); GapicSpannerRpc rpc = new GapicSpannerRpc(options, false); GrpcCallContext callContext = @@ -534,9 +534,9 @@ public void testNewCallContextWithoutSpannerTracingHeader() { } @Test - public void testSpannerTracingHeaderWithEnabledTracing() { + public void testEndToEndTracingHeaderWithEnabledTracing() { final SpannerOptions options = - createSpannerOptions().toBuilder().setEnableSpannerTracing(true).build(); + createSpannerOptions().toBuilder().setEnableEndToEndTracing(true).build(); try (Spanner spanner = options.getService()) { final DatabaseClient databaseClient = spanner.getDatabaseClient(DatabaseId.of("[PROJECT]", "[INSTANCE]", "[DATABASE]")); @@ -547,13 +547,13 @@ public void testSpannerTracingHeaderWithEnabledTracing() { return null; }); } - assertTrue(isSpannerTracing); + assertTrue(isEndToEndTracing); } @Test - public void testSpannerTracingHeaderWithDisabledTracing() { + public void testEndToEndTracingHeaderWithDisabledTracing() { final SpannerOptions options = - createSpannerOptions().toBuilder().setEnableSpannerTracing(false).build(); + createSpannerOptions().toBuilder().setEnableEndToEndTracing(false).build(); try (Spanner spanner = options.getService()) { final DatabaseClient databaseClient = spanner.getDatabaseClient(DatabaseId.of("[PROJECT]", "[INSTANCE]", "[DATABASE]")); @@ -564,7 +564,7 @@ public void testSpannerTracingHeaderWithDisabledTracing() { return null; }); } - assertFalse(isSpannerTracing); + assertFalse(isEndToEndTracing); } @Test @@ -639,7 +639,7 @@ public void testCustomUserAgent() { } @Test - public void testTraceContextHeaderWithOpenTelemetryAndSpannerTracingEnabled() { + public void testTraceContextHeaderWithOpenTelemetryAndEndToEndTracingEnabled() { OpenTelemetry openTelemetry = OpenTelemetrySdk.builder() .setPropagators(ContextPropagators.create(W3CTraceContextPropagator.getInstance())) @@ -650,7 +650,7 @@ public void testTraceContextHeaderWithOpenTelemetryAndSpannerTracingEnabled() { createSpannerOptions() .toBuilder() .setOpenTelemetry(openTelemetry) - .setEnableSpannerTracing(true) + .setEnableEndToEndTracing(true) .build(); try (Spanner spanner = options.getService()) { final DatabaseClient databaseClient = @@ -665,7 +665,7 @@ public void testTraceContextHeaderWithOpenTelemetryAndSpannerTracingEnabled() { } @Test - public void testTraceContextHeaderWithOpenTelemetryAndSpannerTracingDisabled() { + public void testTraceContextHeaderWithOpenTelemetryAndEndToEndTracingDisabled() { OpenTelemetry openTelemetry = OpenTelemetrySdk.builder() .setPropagators(ContextPropagators.create(W3CTraceContextPropagator.getInstance())) @@ -676,7 +676,7 @@ public void testTraceContextHeaderWithOpenTelemetryAndSpannerTracingDisabled() { createSpannerOptions() .toBuilder() .setOpenTelemetry(openTelemetry) - .setEnableSpannerTracing(false) + .setEnableEndToEndTracing(false) .build(); try (Spanner spanner = options.getService()) { final DatabaseClient databaseClient = diff --git a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/spi/v1/SpannerMetadataProviderTest.java b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/spi/v1/SpannerMetadataProviderTest.java index 36cbbe2d1c4..c4fdd6200af 100644 --- a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/spi/v1/SpannerMetadataProviderTest.java +++ b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/spi/v1/SpannerMetadataProviderTest.java @@ -98,7 +98,7 @@ public void testNewRouteToLeaderHeader() { public void testNewEndToEndTracingHeader() { SpannerMetadataProvider metadataProvider = SpannerMetadataProvider.create(ImmutableMap.of(), "header1"); - Map> extraHeaders = metadataProvider.newSpannerTracingHeader(); + Map> extraHeaders = metadataProvider.newEndToEndTracingHeader(); Map> expectedHeaders = ImmutableMap.>of( "x-goog-spanner-end-to-end-tracing", ImmutableList.of("true"));