[ Web Proxy ]
URL:
Viewing: https://docs.cloud.google.com/java/docs/observability [Back]  [Original]

Enable telemetry signals in Cloud Client Libraries for Java  |  Google Cloud Documentation Skip to main content
Google Cloud Documentation [Google Cloud Documentation]
Send feedback

Enable telemetry signals in Cloud Client Libraries for Java Stay organized with collections Save and categorize content based on your preferences.

Google Cloud provides powerful monitoring, logging, and diagnostics for Java applications.

The Java client libraries are instrumented to emit tracing, metrics, and logging data. The instrumentation is opt-in; you need to explicitly enable it. This document describes the available signals and how to enable them.

Available signals

Golden Signals include the following telemetry data, adhering to OpenTelemetry Semantic Conventions:

The signals include standard OpenTelemetry attributes (for example, http.response.status_code and rpc.system.name) and Google Cloud-specific custom attributes, which may include these and similar attributes:

For a full list of standard attributes, see the OpenTelemetry HTTP and gRPC semantic conventions.

Enabling telemetry

To protect sensitive data, telemetry signals are disabled by default. You must explicitly opt in to enable them.

Traces, logs, or metrics may contain sensitive data such as resource names, full URLs, and error messages.

Before configuring subscribers or exporters for traces, logs, or metrics, review the contents of the spans and consult the OpenTelemetry documentation to set up filters and formatters to prevent leaking sensitive information, depending on your intended use case.

Tracing and metrics

In the generated Java client libraries, you must enable tracing and metrics programmatically by providing the appropriate tracer factory to your client's settings during initialization:

For the Java BigQuery SDK, enable tracing by setting BigQueryOptions.newBuilder().setEnableOpenTelemetryTracing(true) and providing the OpenTelemetry tracer.

Logging

Actionable error logs are integrated directly into the core ApiTracer framework. To turn on actionable error logs globally across your Google Cloud client libraries, use the following environment variable:

export GOOGLE_SDK_JAVA_LOGGING=true

Trace context propagation

Trace context propagation in the Java client libraries requires tracing to be explicitly enabled.

When trace generation is enabled (for example, by configuring an OpenTelemetryTracingFactory) and your application has an active OpenTelemetry span in the current context when a client library method is called, the library uses it to provide a tracing context for the outgoing requests. This ensures that your application-level traces can be correlated with backend service logs and behaviors.

Exporting telemetry

Once telemetry is enabled in the client libraries, your application must be configured to collect and export this data to your observability backend.

Tracing and metrics

To export the traces and metrics generated by the Java client libraries, initialize the OpenTelemetry SDK with your preferred exporter (for example, OTLP) and set up the global text map propagator in your application.

For more details on collecting and exporting OpenTelemetry data to Cloud Monitoring or Cloud Trace, see Choose an instrumentation approach.

Logging

The Java client libraries use standard logging frameworks like SLF4J and java.util.logging. When GOOGLE_SDK_JAVA_LOGGING=true is set, actionable error logs are emitted at the DEBUG level.

To route these structured logs to Cloud Logging, configure your logging framework (for example, Logback) to write JSON to standard output (stdout). If you are deploying to an environment like Google Kubernetes Engine or Cloud Run, the built-in agents automatically scrape these logs.

For detailed instructions on configuring Logback or java.util.logging to output Cloud Logging compatible JSON, including trace correlation, see Configure structured logging for Java.

Send feedback

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2026-08-11 UTC.

Need to tell us more? [[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2026-08-11 UTC."],[],[]]

Web Proxy Viewer  |  New URL  |  Original Page