Skip to content

Commit 3e8af74

Browse files
authored
docs: Update stackdriver examples for tracing and stats (#613)
* docs: Update stackdriver examples for tracing and stats * update based on review
1 parent bb3ed6d commit 3e8af74

File tree

1 file changed

+32
-2
lines changed

1 file changed

+32
-2
lines changed

README.md

+32-2
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ try {
203203

204204
TIP: If you are experiencing version conflicts with gRPC, see [Version Conflicts](#version-conflicts).
205205

206-
## OpenCensus Tracing
206+
## Client request tracing: OpenCensus Tracing
207207

208208
Cloud Bigtable client supports [OpenCensus Tracing](https://opencensus.io/tracing/),
209209
which gives insight into the client internals and aids in debugging production issues.
@@ -258,6 +258,8 @@ StackdriverTraceExporter.createAndRegister(
258258
.setProjectId("YOUR_PROJECT_ID")
259259
.build());
260260
```
261+
You can view the traces on the Google Cloud Platform Console
262+
[Trace](https://console.cloud.google.com/traces) page.
261263

262264
By default traces are [sampled](https://opencensus.io/tracing/sampling) at a rate of about 1/10,000.
263265
You can configure a higher rate by updating the active tracing params:
@@ -273,7 +275,7 @@ Tracing.getTraceConfig().updateActiveTraceParams(
273275
);
274276
```
275277

276-
## OpenCensus Stats
278+
## Enabling Cloud Bigtable Metrics: OpenCensus Stats
277279

278280
Cloud Bigtable client supports [Opencensus Metrics](https://opencensus.io/stats/),
279281
which gives insight into the client internals and aids in debugging production issues.
@@ -376,6 +378,34 @@ BigtableDataSettings.enableOpenCensusStats();
376378
BigtableDataSettings.enableGfeOpenCensusStats();
377379
```
378380

381+
You can view the metrics on the Google Cloud Platform Console
382+
[Metrics explorer](https://console.cloud.google.com/monitoring/metrics-explorer)
383+
page.
384+
385+
You can configure how frequently metrics are pushed to StackDriver and the
386+
[Monitored resource type](https://cloud.google.com/monitoring/api/resources) by
387+
updating `StackdriverStatsConfiguration`:
388+
389+
``` java
390+
// Example: configuring export interval and monitored resource type
391+
StackdriverStatsExporter.createAndRegister(
392+
StackdriverStatsConfiguration.builder()
393+
.setProjectId("YOUR_PROJECT_ID")
394+
// Exporting metrics every 10 seconds
395+
.setExportInterval(Duration.create(10, 0))
396+
// Configure monitored resource type. A common practice is to use the
397+
// monitored resource objects that represent the physical resources
398+
// where your application code is running. See the full list of
399+
// monitored resource type here:
400+
// https://cloud.google.com/monitoring/api/resources
401+
.setMonitoredResource(MonitoredResource.newBuilder()
402+
.setType("global")
403+
.putLabels("project_id", "YOUR_PROJECT_ID")
404+
.build())
405+
.build()
406+
);
407+
```
408+
379409
## Version Conflicts
380410

381411
google-cloud-bigtable depends on gRPC directly which may conflict with the versions brought

0 commit comments

Comments
 (0)