Google Professional Cloud Developer Question 61
Select 3Google Cloud PlatformYou are developing a microservices-based application hosted on Google Kubernetes Engine (GKE). To monitor the performance and troubleshoot issues, you need to implement observability using Google Cloud’s tools. Which of the following actions should you take to instrument your code to produce metrics, logs, and traces effectively?
- A
Use the Cloud Logging client library to write structured logs directly from your application.
- B
Add OpenTelemetry SDK to your application to capture distributed traces and export them to Cloud Trace.
- C
Use the Compute Engine API to export application performance metrics.
- D
Instrument your application with the Cloud Monitoring client library to record custom metrics.
- E
Configure IAM roles for your application to directly write to Stackdriver logs without using client libraries.
Show answer and explanation
Correct answers: A, B, D
Explanation
To achieve effective observability in a Google Cloud environment, developers must use appropriate tools and libraries. Structured logs can be sent to Cloud Logging using the Cloud Logging client library, while distributed traces can be captured with OpenTelemetry and sent to Cloud Trace. For custom metrics, the Cloud Monitoring client library is the correct approach. Compute Engine APIs and IAM roles, while useful for other purposes, are not directly relevant to instrumenting application code for metrics, logs, and traces.
- A. Correct.
Correct. Cloud Logging client libraries allow applications to write structured logs directly to Cloud Logging, which is essential for observability.
- B. Correct.
Correct. OpenTelemetry SDK is a widely used library for capturing distributed traces and exporting them to Cloud Trace in Google Cloud.
- C. Incorrect.
Incorrect. While Compute Engine APIs can be used for VM management, they are unrelated to instrumenting application code for metrics or logs.
- D. Correct.
Correct. The Cloud Monitoring client library enables applications to record custom metrics, which can then be visualized and monitored in Google Cloud Monitoring.
- E. Incorrect.
Incorrect. While configuring IAM roles is important for permissions, Stackdriver (now Cloud Logging) requires client libraries or APIs to send logs, and IAM roles alone cannot handle this.