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

docs: Update stackdriver examples for tracing and stats #613

Merged
merged 2 commits into from
Feb 5, 2021
Merged
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
34 changes: 32 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ try {

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

## OpenCensus Tracing
## Client request tracing: OpenCensus Tracing

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

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

## OpenCensus Stats
## Enabling Cloud Bigtable Metrics: OpenCensus Stats

Cloud Bigtable client supports [Opencensus Metrics](https://opencensus.io/stats/),
which gives insight into the client internals and aids in debugging production issues.
Expand Down Expand Up @@ -376,6 +378,34 @@ BigtableDataSettings.enableOpenCensusStats();
BigtableDataSettings.enableGfeOpenCensusStats();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I"m not sure that this line works still. Or at least it didn't compile when I tried using it I think

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah.. Looks like this change is not released yet

```

You can view the metrics on the Google Cloud Platform Console
[Metrics explorer](https://console.cloud.google.com/monitoring/metrics-explorer)
page.

You can configure how frequently metrics are pushed to StackDriver and the
[Monitored resource type](https://cloud.google.com/monitoring/api/resources) by
updating `StackdriverStatsConfiguration`:

``` java
// Example: configuring export interval and monitored resource type
StackdriverStatsExporter.createAndRegister(
StackdriverStatsConfiguration.builder()
.setProjectId("YOUR_PROJECT_ID")
// Exporting metrics every 10 seconds
.setExportInterval(Duration.create(10, 0))
// Configure monitored resource type. A common practice is to use the
// monitored resource objects that represent the physical resources
// where your application code is running. See the full list of
// monitored resource type here:
// https://cloud.google.com/monitoring/api/resources
.setMonitoredResource(MonitoredResource.newBuilder()
.setType("global")
.putLabels("project_id", "YOUR_PROJECT_ID")
.build())
.build()
);
```

## Version Conflicts

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