0
0
GCPcloud~30 mins

Cloud Trace for latency analysis in GCP - Mini Project: Build & Apply

Choose your learning style9 modes available
Cloud Trace for latency analysis
📖 Scenario: You work for a company that wants to understand how long their web application takes to respond to user requests. They want to use Google Cloud Trace to collect and analyze latency data.
🎯 Goal: Set up a basic Cloud Trace configuration to collect latency data for a sample web service and analyze the trace spans.
📋 What You'll Learn
Create a dictionary called trace_data with sample trace spans and their durations
Add a configuration variable called latency_threshold_ms to set a latency limit
Use a list comprehension to filter trace spans that exceed the latency threshold
Add a final configuration to enable trace export to Google Cloud Trace
💡 Why This Matters
🌍 Real World
Cloud Trace helps developers and operators understand where delays happen in their applications by collecting latency data from different parts of the system.
💼 Career
Knowing how to configure and analyze trace data is important for cloud engineers and developers to improve application performance and user experience.
Progress0 / 4 steps
1
Create sample trace data
Create a dictionary called trace_data with these exact entries: 'span1': 120, 'span2': 85, 'span3': 200, 'span4': 50. The numbers represent latency in milliseconds.
GCP
Need a hint?

Use curly braces to create a dictionary with keys as span names and values as latency in ms.

2
Set latency threshold
Add a variable called latency_threshold_ms and set it to 100 to represent the maximum acceptable latency in milliseconds.
GCP
Need a hint?

Just assign the number 100 to the variable latency_threshold_ms.

3
Filter slow trace spans
Use a list comprehension to create a list called slow_spans that contains the names of spans from trace_data whose latency is greater than latency_threshold_ms.
GCP
Need a hint?

Use a list comprehension with for span, latency in trace_data.items() and an if condition.

4
Enable trace export configuration
Add a dictionary called trace_config with a key 'export_enabled' set to true to enable exporting trace data to Google Cloud Trace.
GCP
Need a hint?

Create a dictionary with the key 'export_enabled' and value true.