Skip to content

Professional Cloud Developer · Domain 4: Integrating applications with Google Cloud services · 21% of the exam

Task 4.3: Troubleshooting and observability.

Instrumenting code with metrics, logs and traces, finding and fixing issues with Google Cloud Observability, Error Reporting, correlating spans with trace IDs, and AI-assisted observability.

Study it

Sample questions

Try each one before opening the answer. Every option is explained, with the Google Cloud documentation page that proves it.

Question 1 · choose 1

A service writes a user-defined metric with the Cloud Monitoring client library: series = monitoring_v3.TimeSeries() series.metric.type = "checkout/failures" series.resource.type = "global" series.points = [point] client.create_time_series(name=project_name, time_series=[series]) No data ever appears for the metric. What should the developer change?

  1. AAdd a label with the checkout region to the metric
  2. BSet the resource type to the Cloud Run revision that writes the data
  3. CName the type logging.googleapis.com/user/checkout/failures
  4. DName the type custom.googleapis.com/checkout/failures
Show the answer and why
  • AAdd a label with the checkout region to the metric

    Incorrect

    The metric type itself is invalid; adding labels doesn't change that.

  • BSet the resource type to the Cloud Run revision that writes the data

    Incorrect

    The metric type itself is the problem; it lacks a user-defined prefix.

  • CName the type logging.googleapis.com/user/checkout/failures

    Incorrect

    That isn't one of the prefixes Monitoring allows for user-defined metrics.

  • DName the type custom.googleapis.com/checkout/failures

    Correct

    A user-defined metric type must start with a prefix that marks it as user-defined, such as custom.googleapis.com/.

When you create a user-defined metric, its type is a string identifier that must be unique in the project and must use a prefix that marks the metric as user-defined. For Monitoring, the allowed prefixes are custom.googleapis.com/, workload.googleapis.com/, external.googleapis.com/user and external.googleapis.com/prometheus, followed by a name for what is collected.

Question 2 · choose 1

An engineer types this query in Logs Explorer to find failed Cloud Run requests: resource.type="cloud_run_revision" and severity>=ERROR and httpRequest.status>=500. The results include many entries with severity INFO and status 200 that contain the word "and". What should the engineer change?

  1. APut each comparison in parentheses
  2. BWrite the Boolean operators in capitals, as AND
  3. CQuote the value of severity as "ERROR"
  4. DUse the has operator (:) in place of each comparison operator
Show the answer and why
  • APut each comparison in parentheses

    Incorrect

    Parentheses group operators; the lowercase words are still treated as search terms.

  • BWrite the Boolean operators in capitals, as AND

    Correct

    Boolean operators must be capitalized; lowercase and, or and not are parsed as search terms.

  • CQuote the value of severity as "ERROR"

    Incorrect

    Severity comparisons work without quotes; the problem is the operator spelling.

  • DUse the has operator (:) in place of each comparison operator

    Incorrect

    Changing the comparisons leaves the lowercase words parsed as search terms.

The Logging query language is case-insensitive except for regular expressions and logical operators. Boolean operators must be capitalized: lowercase and, or and not are parsed as search terms, which are global restrictions matched against every field. Writing AND restores the intended conjunction.

Question 3 · choose 1

An order service publishes to Pub/Sub, and a fulfillment service on another Cloud Run service pulls the messages. Both use the Python client library and export traces to Cloud Trace through the OpenTelemetry SDK. The publisher client was created with enable_open_telemetry_tracing=True; the subscriber client was created with default options. Engineers see publish spans in Cloud Trace, but nothing of the subscriber's handling of a message. What should they change?

  1. AGrant the subscriber's service account the Pub/Sub Viewer role on the topic
  2. BSet the sampling ratio of the publisher's tracer provider to 1.0
  3. CCopy the trace ID into a message attribute in the publisher code
  4. DCreate the subscriber client with the OpenTelemetry tracing option enabled as well
Show the answer and why
  • AGrant the subscriber's service account the Pub/Sub Viewer role on the topic

    Incorrect

    Exporting traces needs the Cloud Trace Agent role, and the subscriber's problem is that its client doesn't trace.

  • BSet the sampling ratio of the publisher's tracer provider to 1.0

    Incorrect

    Publish spans already appear; the subscriber's client creates none.

  • CCopy the trace ID into a message attribute in the publisher code

    Incorrect

    The client libraries already inject a tracing attribute; the subscriber side must have tracing enabled to use it.

  • DCreate the subscriber client with the OpenTelemetry tracing option enabled as well

    Correct

    Context propagation from the publish side to the subscribe side works only when tracing is turned on in the client libraries.

The Pub/Sub client libraries create a trace for each published message that covers its lifecycle until acknowledgment, with publishing spans and subscription spans. To propagate context from publish to subscribe, the client libraries inject a tracing attribute with the googclient_ prefix on the publish side; this mechanism is enabled only when tracing is turned on. Each client is configured with the enable OpenTelemetry tracing option, and exporting to Cloud Trace needs the Cloud Trace Agent role on the service account.

Question 4 · choose 1

A service calls two partner programs, A and B. The team wants one user-defined metric that counts calls, and it wants to alert on the call rate of each program and to chart the share of calls that go to A. How should it model the metric?

  1. AOne metric with a label that records the program, A or B
  2. BOne metric without labels that counts all calls
  3. COne metric that counts only the calls to program A
  4. DOne logs-based metric for each program on the same log entries
Show the answer and why
  • AOne metric with a label that records the program, A or B

    Correct

    Monitoring keeps a time series per label value, so each program can be filtered and ratios are simple.

  • BOne metric without labels that counts all calls

    Incorrect

    The data for the two programs can't be separated, so the alerts can't be built.

  • COne metric that counts only the calls to program A

    Incorrect

    Calls to B would go uncounted, so its rate couldn't be alerted on.

  • DOne logs-based metric for each program on the same log entries

    Incorrect

    That is two metrics, and ratios are simplest with one labeled metric.

Monitoring creates a time series for each unique combination of label values. A single metric with a label for the program gives one time series per program, so alerting conditions can filter on the label and ratios are easy to compute. A metric without such a label combines both programs, and their data can't be separated.

Question 5 · choose 1

While investigating an incident, a developer runs SEARCH("checkout") in Logs Explorer. Which of these log entries does the query NOT return?

  1. AAn entry whose textPayload is "checkout started for shopping cart 42"
  2. BAn entry whose jsonPayload.step field is "checkout"
  3. CAn entry whose jsonPayload.message is "checkouts queued: 12"
  4. DAn entry whose labels.component is "Checkout"
Show the answer and why
  • AAn entry whose textPayload is "checkout started for shopping cart 42"

    Incorrect

    The field contains the token checkout, so the entry matches.

  • BAn entry whose jsonPayload.step field is "checkout"

    Incorrect

    Without a field argument, SEARCH looks through the whole entry, so this field matches.

  • CAn entry whose jsonPayload.message is "checkouts queued: 12"

    Correct

    SEARCH matches exact tokens, not substrings, so the token checkouts doesn't match checkout.

  • DAn entry whose labels.component is "Checkout"

    Incorrect

    SEARCH compares tokens without regard to case, so Checkout matches.

The SEARCH function splits its query into tokens and matches a log entry when a field contains those tokens, with case-insensitive comparisons. It performs exact matches, not substring matches, so SEARCH("checkout") doesn't match a value whose token is checkouts, in the same way that the page's SEARCH("world") doesn't match "worldwide". With no field argument, the whole entry is searched.

Question 6 · choose 1

To meet a compliance rule, a team turned on customer-managed encryption keys for the log bucket that stores its application logs. Since then, new exceptions no longer appear in Error Reporting, although the stack traces are in the logs. Why?

  1. AError Reporting now samples at most 100 errors per hour
  2. BError Reporting can't analyze entries in a log bucket with CMEK enabled
  3. CStack traces must be sent to the Error Reporting API once CMEK is on
  4. DError Reporting ignores entries whose severity is lower than CRITICAL
Show the answer and why
  • AError Reporting now samples at most 100 errors per hour

    Incorrect

    Sampling limits how many errors are analyzed; it doesn't stop new ones from appearing.

  • BError Reporting can't analyze entries in a log bucket with CMEK enabled

    Correct

    Error Reporting analyzes log entries only when CMEK is disabled on all the buckets that store them.

  • CStack traces must be sent to the Error Reporting API once CMEK is on

    Incorrect

    The constraint is on the log bucket; Error Reporting still reads logs from buckets without CMEK.

  • DError Reporting ignores entries whose severity is lower than CRITICAL

    Incorrect

    No such rule applies to these entries; the change was the bucket's encryption.

Error Reporting is built on Cloud Logging and analyzes log entries only when several conditions hold, including that customer-managed encryption keys are disabled on all log buckets that store the entry. After CMEK was turned on for the bucket, Error Reporting can no longer infer errors from those entries.

Practice domain 4 →Practice all domains →