Prepare and test your skills

Prepare and test your skills

Free sample question with answers and detailed explanation below. The Professional Cloud Developer practice bank has an additional 608 practice questions.Try 10 free realistic questions: instant score, no credit card, and no account required.
You are developing a Java microservice on Google Kubernetes Engine (GKE) that queries Cloud Spanner and handles customer checkout requests. You need to instrument the application to meet the following requirements:
Which implementation approach should you choose?
Sqlcommenter is an open-source OpenTelemetry library designed for databases and object-relational mappings (ORMs). It automatically augments outgoing SQL statements with key-value comments containing application context (such as controller names or business logic tags) and propagates OpenTelemetry trace context from the application to the database.
SpannerOptions to emit OpenTelemetry client-side metrics such as round-trip or query execution latency.The goal were to correlate slow SQL queries generated by an ORM in Cloud SQL back to specific application routes or business workflows using Query Insights and Cloud Trace.
Although traces and metrics complement each other in observability, MQL requires time-series metrics exported via an OpenTelemetry MeterProvider or Cloud Monitoring API rather than trace span metadata.
While this option correctly instruments the Java application with the OpenTelemetry SDK, SpannerOptions, and the OpenTelemetry Collector, it attempts to query the resulting metrics in Monitoring Query Language (MQL) without specifying a monitored-resource type.
googlemanagedprometheus exporter are written against the prometheus_target resource type. Unlike PromQL, MQL and Monitoring filters do not automatically infer prometheus_target from the metric name.prometheus_target in your MQL fetch expressions, the queries will fail to validate or return empty time series, preventing dashboards and alerting policies from functioning.prometheus_target resource carries essential resource labels such as project_id, location, cluster, namespace, job, and instance.fetch operation that specifies both the monitored-resource type and the metric type (for example, fetch prometheus_target :: prometheus.googleapis.com/...).prometheus.googleapis.com identify the metric domain, not the monitored-resource schema.You were writing queries exclusively in PromQL instead of MQL, because PromQL natively maps metric names and label selectors without requiring an explicit prometheus_target resource declaration.
A common misconception when transitioning from PromQL to MQL is assuming metric names are globally standalone. Understanding the separation between metric descriptors and monitored-resource types in Cloud Monitoring is essential for writing valid MQL queries.
User-defined log-based metrics (prefixed with logging.googleapis.com/user) extract numerical values or counts from log entries ingested into Cloud Logging. Developers sometimes use them to derive metrics from structured application logs without integrating a metrics SDK.
SpannerOptions and loses standardized OTLP Collector GKE enrichment.logging.googleapis.com/user prefix rather than prometheus.googleapis.com.DoubleHistogram.You needed to track rare error occurrences or audit events from an existing legacy application where modifying code to add an OpenTelemetry SDK is not feasible.
For high-volume performance indicators like latency histograms, in-process aggregation with the OpenTelemetry SDK and OTLP Collector is far more cost-effective and gives you full visibility on the Metrics Management page.
This approach combines vendor-neutral OpenTelemetry SDK instrumentation in Java with the OpenTelemetry Collector and Google Cloud Monitoring. By enabling OpenTelemetry metrics on SpannerOptions and registering an SdkMeterProvider with an OTLP exporter, the application emits both built-in Spanner client telemetry and custom DoubleHistogram measurements to the Collector, which translates them into Cloud Monitoring time series.
SpannerOptions.enableOpenTelemetryMetrics() activates Spanner client-side metrics, while obtaining a Meter from the shared SdkMeterProvider lets you define a custom DoubleHistogram for checkout latency.googlemanagedprometheus exporter along with Kubernetes metadata processors (such as k8sattributes) attaches GKE cluster, namespace, and workload labels and ingests metrics under the prometheus.googleapis.com prefix.prometheus_target monitored-resource type. Explicitly referencing prometheus_target in your Monitoring Query Language (MQL) queries ensures accurate filtering, alignment, and alerting.cluster, namespace, location) and custom metric attributes.This architecture adheres to OpenTelemetry standards, supports both Spanner client observability and domain-specific KPIs from a single SDK configuration, and satisfies Cloud Monitoring's strict resource-typing rules for MQL queries.
Answer them yourself and get your score the moment you finish. No account needed.
Full access includes
Keep the momentum going with these hand-picked practice scenarios
Last updated Validated