Skip to content

Commit fe6e4a5

Browse files
committed
documentation
1 parent a9a1b1c commit fe6e4a5

File tree

6 files changed

+27
-12
lines changed

6 files changed

+27
-12
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,9 @@ the Cloud Spanner Java client.
158158

159159
## OpenCensus Metrics
160160

161+
> Note: OpenCensus project is deprecated. See [Sunsetting OpenCensus](https://opentelemetry.io/blog/2023/sunsetting-opencensus/).
162+
We recommend migrating to OpenTelemetry, the successor project.
163+
161164
Cloud Spanner client supports [Opencensus Metrics](https://opencensus.io/stats/),
162165
which gives insight into the client internals and aids in debugging/troubleshooting
163166
production issues. OpenCensus metrics will provide you with enough data to enable you to

google-cloud-spanner/pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -263,14 +263,14 @@
263263
</dependency>
264264
<dependency>
265265
<groupId>io.opentelemetry</groupId>
266-
<artifactId>opentelemetry-sdk-testing</artifactId>
266+
<artifactId>opentelemetry-sdk-trace</artifactId>
267267
<version>${opentelemetry.version}</version>
268268
<scope>test</scope>
269269
</dependency>
270270
<dependency>
271271
<groupId>io.opentelemetry</groupId>
272-
<artifactId>opentelemetry-sdk-metrics-testing</artifactId>
273-
<version>1.13.0-alpha</version>
272+
<artifactId>opentelemetry-sdk-testing</artifactId>
273+
<version>${opentelemetry.version}</version>
274274
<scope>test</scope>
275275
</dependency>
276276
<dependency>

google-cloud-spanner/src/main/java/com/google/cloud/spanner/spi/v1/SpannerRpcViews.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,12 @@ public class SpannerRpcViews {
9191
* measures the latency between Google's network receives an RPC and reads back the first byte of
9292
* the response. gfe_header_missing_count is a counter of the number of RPC responses without a
9393
* server-timing header.
94+
*
95+
* @deprecated The OpenCensus project is deprecated. Use OpeTelemetry to get gfe_latency and
96+
* gfe_header_missing_count metrics.
9497
*/
9598
@VisibleForTesting
99+
@Deprecated
96100
public static void registerGfeLatencyAndHeaderMissingCountViews() {
97101
viewManager.registerView(SPANNER_GFE_LATENCY_VIEW);
98102
viewManager.registerView(SPANNER_GFE_HEADER_MISSING_COUNT_VIEW);
@@ -101,6 +105,9 @@ public static void registerGfeLatencyAndHeaderMissingCountViews() {
101105
/**
102106
* Register GFE Latency view. gfe_latency measures the latency between Google's network receives
103107
* an RPC and reads back the first byte of the response.
108+
*
109+
* @deprecated The OpenCensus project is deprecated. Use OpeTelemetry to get gfe_latency and
110+
* gfe_header_missing_count metrics.
104111
*/
105112
@VisibleForTesting
106113
public static void registerGfeLatencyView() {
@@ -110,6 +117,9 @@ public static void registerGfeLatencyView() {
110117
/**
111118
* Register GFE Header Missing Count view. gfe_header_missing_count is a counter of the number of
112119
* RPC responses without a server-timing header.
120+
*
121+
* @deprecated The OpenCensus project is deprecated. Use OpeTelemetry to get gfe_latency and
122+
* gfe_header_missing_count metrics.
113123
*/
114124
@VisibleForTesting
115125
public static void registerGfeHeaderMissingCountView() {

google-cloud-spanner/src/test/java/com/google/cloud/spanner/OpenTelemetrySpanTest.java

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2020 Google LLC
2+
* Copyright 2023 Google LLC
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -16,7 +16,6 @@
1616

1717
package com.google.cloud.spanner;
1818

19-
import static com.google.common.truth.Truth.assertThat;
2019
import static org.junit.Assert.assertEquals;
2120
import static org.junit.Assert.assertThrows;
2221
import static org.junit.Assert.assertTrue;
@@ -106,8 +105,6 @@ public static void startStaticServer() throws IOException {
106105
String uniqueName = InProcessServerBuilder.generateName();
107106
server =
108107
InProcessServerBuilder.forName(uniqueName)
109-
// We need to use a real executor for timeouts to occur.
110-
.scheduledExecutorService(new ScheduledThreadPoolExecutor(1))
111108
.addService(mockSpanner)
112109
.build()
113110
.start();
@@ -181,7 +178,7 @@ public void singleUse() {
181178
|| name.equals("CloudSpanner.ReadOnlyTransaction")
182179
|| name.equals("SessionPool.WaitForSession"));
183180
assertTrue(hasSpanData);
184-
assertThat(spans.size()).isEqualTo(5);
181+
assertEquals(5, spans.size());
185182
}
186183
}
187184

@@ -209,7 +206,7 @@ public void multiUse() {
209206
|| name.equals("CloudSpanner.ReadOnlyTransaction")
210207
|| name.equals("SessionPool.WaitForSession"));
211208
assertTrue(hasSpanData);
212-
assertThat(spans.size()).isEqualTo(5);
209+
assertEquals(5, spans.size());
213210
}
214211

215212
@Test
@@ -231,7 +228,7 @@ public void transactionRunner() {
231228
|| name.equals("CloudSpanner.ReadWriteTransaction")
232229
|| name.equals("SessionPool.WaitForSession"));
233230
assertTrue(hasSpanData);
234-
assertThat(spans.size()).isEqualTo(5);
231+
assertEquals(5, spans.size());
235232
}
236233

237234
@Test
@@ -257,6 +254,6 @@ public void transactionRunnerWithError() {
257254
|| name.equals("CloudSpanner.ReadWriteTransaction")
258255
|| name.equals("SessionPool.WaitForSession"));
259256
assertTrue(hasSpanData);
260-
assertThat(spans.size()).isEqualTo(4);
257+
assertEquals(4, spans.size());
261258
}
262259
}

google-cloud-spanner/src/test/java/com/google/cloud/spanner/SessionPoolTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ private SessionPool createPool(
177177
new TestExecutorFactory(),
178178
client.getSessionClient(db),
179179
clock,
180+
Position.RANDOM,
180181
metricRegistry,
181182
labelValues,
182183
openTelemetry,

samples/snippets/src/main/java/com/example/spanner/TracingSample.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,11 @@
3232
import io.opencensus.trace.samplers.Samplers;
3333
import java.util.Arrays;
3434

35-
/** This sample demonstrates how to enable opencensus tracing and stats in cloud spanner client. */
35+
/** This sample demonstrates how to enable opencensus tracing and stats in cloud spanner client.
36+
*
37+
* @deprecated The OpenCensus project is deprecated. Use OpenTelemetry to enable metrics
38+
* and stats with cloud spanner client.
39+
*/
3640
public class TracingSample {
3741

3842
private static final String SAMPLE_SPAN = "CloudSpannerSample";

0 commit comments

Comments
 (0)