0
0
HLDsystem_design~10 mins

Distributed tracing in HLD - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to define the unique identifier used to track a request across services.

HLD
trace_id = generate_[1]()  # Unique ID for distributed tracing
Drag options to blanks, or click blank then click option'
Atraceparent
Bspan_id
Ctrace_context
Dtrace_id
Attempts:
3 left
💡 Hint
Common Mistakes
Confusing span_id with trace_id
Using trace_context instead of trace_id
2fill in blank
medium

Complete the code to create a new span representing a unit of work in distributed tracing.

HLD
span = tracer.start_[1](name="database_query")
Drag options to blanks, or click blank then click option'
Atrace
Bspan
Ccontext
Dtrace_id
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'trace' instead of 'span' to start a unit of work
Confusing 'context' with span creation
3fill in blank
hard

Fix the error in the code to correctly propagate trace context between services.

HLD
headers["[1]"] = serialize_trace_context(trace_context)
Drag options to blanks, or click blank then click option'
Atraceparent
Bspan_id
Ctrace_id
Dtracing_header
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'trace_id' as header name instead of 'traceparent'
Using non-standard header names
4fill in blank
hard

Fill both blanks to correctly extract and start a child span from incoming trace context.

HLD
incoming_context = extract_trace_context([1])
child_span = tracer.start_span(name="process_request", context=[2])
Drag options to blanks, or click blank then click option'
Arequest.headers
Bincoming_context
Ctrace_context
Drequest.body
Attempts:
3 left
💡 Hint
Common Mistakes
Extracting context from request body
Passing wrong variable as context to start_span
5fill in blank
hard

Fill all three blanks to build a dictionary representing a trace span with its ID, parent ID, and operation name.

HLD
span_info = {
  "span_id": [1],
  "parent_id": [2],
  "operation": "[3]"
}
Drag options to blanks, or click blank then click option'
Acurrent_span.id
Bparent_span.id
Cprocess_payment
Dtrace_id
Attempts:
3 left
💡 Hint
Common Mistakes
Using trace_id instead of span_id
Mixing up current_span and parent_span IDs