Skip to content

docs: add observability samples#5448

Open
westarle wants to merge 1 commit intogoogleapis:mainfrom
westarle:feat/observability-samples
Open

docs: add observability samples#5448
westarle wants to merge 1 commit intogoogleapis:mainfrom
westarle:feat/observability-samples

Conversation

@westarle
Copy link
Copy Markdown
Contributor

These are snippets to include in the product-neutral guide for observability.

@westarle westarle requested a review from a team as a code owner April 17, 2026 11:07
@product-auto-label product-auto-label bot added the samples Issues that are directly related to samples. label Apr 17, 2026
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 17, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.76%. Comparing base (da70a13) to head (4ca0d10).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5448      +/-   ##
==========================================
- Coverage   97.76%   97.76%   -0.01%     
==========================================
  Files         217      217              
  Lines       48014    48014              
==========================================
- Hits        46940    46939       -1     
- Misses       1074     1075       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

let subscriber = Registry::default().with(telemetry);
tracing::subscriber::set_global_default(subscriber)?;

// ... initialize the client ...
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is this obvious? Do you need to .enable_tracing() or anything?

@westarle westarle force-pushed the feat/observability-samples branch from 8a6a0da to 4ca0d10 Compare April 17, 2026 14:36
Copy link
Copy Markdown
Contributor

@coryan coryan left a comment

Choose a reason for hiding this comment

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

Some small nits, please fix before merging.

pub async fn sample() -> anyhow::Result<()> {
// Output `WARN` logs for failed logical client requests, and `DEBUG` logs
// for failed low-level RPC attempts from the client library crate.
let filter = tracing_subscriber::EnvFilter::new("warn,google_cloud_secretmanager=debug");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The crate name (and target) is google_cloud_secretmanager**_v1**

// See the License for the specific language governing permissions and
// limitations under the License.

// [START rust_observability_logging] ANCHOR: rust_observability_logging
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We don't have plans to use these in the mdBook, right? We can skip the ANCHOR: and ANCHOR_END if that is the case.

use tracing_subscriber::util::SubscriberInitExt;

pub async fn sample() -> anyhow::Result<()> {
// Output `WARN` logs for failed logical client requests, and `DEBUG` logs
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe:

Suggested change
// Output `WARN` logs for failed logical client requests, and `DEBUG` logs
// Enable all `WARN` logs, including those failed logical client requests in all client libraries.
// In addition, enable `DEBUG` logs for `google_cloud_secretmanager_v1`, which include
// errors in low-level RPC attempts.

I am not sure if a casual reader of this would understand what "logical client request" means. The surrounding text may need to clarify this.

use tracing_subscriber::layer::SubscriberExt;

pub async fn sample() -> anyhow::Result<()> {
use opentelemetry::trace::TracerProvider as _;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: group with the other use declarations.

pub async fn sample() -> anyhow::Result<()> {
// Output `WARN` logs for failed logical client requests, and `DEBUG` logs
// for failed low-level RPC attempts from the client library crate.
let filter = tracing_subscriber::EnvFilter::new("warn,google_cloud_secretmanager=debug");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Since targets are still hardcoded to experimental. (#5150), should we use the working filter in this sample now, or wait until the issue is resolved?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

samples Issues that are directly related to samples.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants