OTCA Sample Practice Questions¶
Practice Resources¶
Observability Concepts (16%)¶
Question 1¶
What are the three pillars of observability in OpenTelemetry?
Show Solution
1. **Traces** - Distributed tracing showing request flow 2. **Metrics** - Numerical measurements over time 3. **Logs** - Timestamped text records of events OpenTelemetry also supports **Baggage** for context propagation.Question 2¶
What is the difference between a Trace and a Span?
Show Solution
- **Trace** - Complete journey of a request through a distributed system, identified by a unique trace ID - **Span** - Single operation within a trace, with start time, duration, and attributes A trace contains multiple spans in a parent-child hierarchy:Question 3¶
What is context propagation?
Show Solution
Context propagation passes trace context between services to correlate spans across service boundaries. Components: - **Context** - Carries trace ID, span ID, trace flags - **Propagators** - Inject/extract context from carriers (HTTP headers) - **W3C Trace Context** - Standard format for propagation Example headers:OpenTelemetry API (24%)¶
Question 4¶
How do you create a span manually?
Show Solution
Question 5¶
How do you record metrics with OpenTelemetry?
Show Solution
from opentelemetry import metrics
meter = metrics.get_meter(__name__)
# Counter - only increases
counter = meter.create_counter("requests_total")
counter.add(1, {"method": "GET"})
# UpDownCounter - can increase or decrease
gauge = meter.create_up_down_counter("active_connections")
gauge.add(1)
gauge.add(-1)
# Histogram - distribution of values
histogram = meter.create_histogram("request_duration")
histogram.record(0.5, {"endpoint": "/api"})
Question 6¶
What are span attributes vs span events?
Show Solution
**Attributes** - Key-value pairs describing the span - Set once, describe the operation - Examples: http.method, http.url, db.system **Events** - Timestamped logs within a span - Can have multiple events per span - Examples: "cache miss", "retry attempt"OpenTelemetry SDK (16%)¶
Question 7¶
What are the main SDK components?
Show Solution
**Trace SDK:** - TracerProvider - Creates tracers - SpanProcessor - Processes spans (batch, simple) - SpanExporter - Exports spans to backends **Metrics SDK:** - MeterProvider - Creates meters - MetricReader - Reads metrics periodically - MetricExporter - Exports metrics **Common:** - Resource - Describes the entity producing telemetry - Sampler - Decides which traces to sampleQuestion 8¶
Configure the OpenTelemetry SDK with OTLP exporter.
Show Solution
from opentelemetry import trace
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import BatchSpanProcessor
from opentelemetry.exporter.otlp.proto.grpc.trace_exporter import OTLPSpanExporter
from opentelemetry.sdk.resources import Resource
resource = Resource.create({"service.name": "my-service"})
provider = TracerProvider(resource=resource)
processor = BatchSpanProcessor(OTLPSpanExporter(endpoint="localhost:4317"))
provider.add_span_processor(processor)
trace.set_tracer_provider(provider)
Question 9¶
What is sampling and what are the sampling strategies?
Show Solution
**Sampling** decides which traces to record to reduce overhead. Strategies: - **AlwaysOn** - Record all traces - **AlwaysOff** - Record no traces - **TraceIdRatioBased** - Sample based on trace ID ratio - **ParentBased** - Follow parent's sampling decisionOpenTelemetry Collector (24%)¶
Question 10¶
What are the main components of the OTel Collector?
Show Solution
1. **Receivers** - Accept data (OTLP, Jaeger, Prometheus) 2. **Processors** - Transform data (batch, filter, attributes) 3. **Exporters** - Send data to backends (OTLP, Jaeger, Prometheus) 4. **Extensions** - Additional capabilities (health check, pprof) 5. **Connectors** - Connect pipelines (count spans to metrics) Pipeline: Receivers → Processors → ExportersQuestion 11¶
Write a basic Collector configuration.
Show Solution
receivers:
otlp:
protocols:
grpc:
endpoint: 0.0.0.0:4317
http:
endpoint: 0.0.0.0:4318
processors:
batch:
timeout: 10s
send_batch_size: 1000
memory_limiter:
limit_mib: 512
exporters:
otlp:
endpoint: jaeger:4317
tls:
insecure: true
prometheus:
endpoint: 0.0.0.0:8889
service:
pipelines:
traces:
receivers: [otlp]
processors: [memory_limiter, batch]
exporters: [otlp]
metrics:
receivers: [otlp]
processors: [batch]
exporters: [prometheus]
Question 12¶
What are common Collector deployment patterns?
Show Solution
1. **No Collector (Direct)** - Apps export directly to backend 2. **Agent** - Collector as sidecar/daemonset per node 3. **Gateway** - Centralized Collector cluster 4. **Agent + Gateway** - Two-tier architecture Best practices: - Use Agent for collection, Gateway for processing - Enable memory_limiter processor - Use batch processor for efficiencyInstrumentation (20%)¶
Question 13¶
What is the difference between auto and manual instrumentation?
Show Solution
**Auto-instrumentation:** - Automatic, no code changes - Uses agents or libraries - Covers common frameworks - Less control **Manual instrumentation:** - Requires code changes - Full control over spans/metrics - Custom business logic - More effort Best practice: Use auto-instrumentation as base, add manual for business logic.Question 14¶
How do you enable auto-instrumentation in Python?
Show Solution
# Install
pip install opentelemetry-distro opentelemetry-exporter-otlp
opentelemetry-bootstrap -a install
# Run with auto-instrumentation
opentelemetry-instrument \
--service_name my-service \
--traces_exporter otlp \
--metrics_exporter otlp \
--exporter_otlp_endpoint http://localhost:4317 \
python app.py
Question 15¶
What semantic conventions should you follow?
Show Solution
Semantic conventions standardize attribute names: **HTTP:** - `http.method` - GET, POST - `http.url` - Full URL - `http.status_code` - 200, 404 **Database:** - `db.system` - mysql, postgresql - `db.statement` - SQL query - `db.name` - Database name **Service:** - `service.name` - Service identifier - `service.version` - Version string Following conventions enables better correlation across tools.Exam Tips¶
- Know the three signals - Traces, Metrics, Logs
- Understand Collector architecture - Receivers, Processors, Exporters
- Know SDK components - Providers, Processors, Exporters
- Practice configuration - Collector YAML, SDK setup
- Understand context propagation - W3C Trace Context