Complete the code to enable Cloud Trace API in your GCP project.
gcloud services enable [1]The Cloud Trace API is enabled using cloudtrace.googleapis.com. This allows latency data collection.
Complete the code to create a trace span using the OpenTelemetry Python library.
with tracer.start_as_current_span("[1]") as span: # your code here pass
Using a descriptive name like custom_operation helps identify the span in latency analysis.
Fix the error in the code to export trace data to Cloud Trace using OpenTelemetry.
trace.set_tracer_provider(TracerProvider())
trace.get_tracer_provider().add_span_processor(BatchSpanProcessor([1]))To send traces to Cloud Trace, use CloudTraceSpanExporter() as the exporter.
Fill both blanks to configure the OpenTelemetry tracer with resource attributes and exporter.
resource = Resource(attributes={"service.name": [1])
tracer_provider = TracerProvider(resource=resource)
tracer_provider.add_span_processor(BatchSpanProcessor([2]))Set the service name to a meaningful string like "my-service" and use CloudTraceSpanExporter() to send traces to Cloud Trace.
Fill all three blanks to create a trace span, add attributes, and end it properly.
tracer = trace.get_tracer("[1]") with tracer.start_as_current_span("[2]") as span: span.set_attribute("http.status_code", [3]) # your code here
Use my-service as tracer name, request-handler as span name, and set HTTP status code attribute to 200 to indicate success.