Skip to content

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:
Trace (trace_id: abc123)
├── Span A (root span)
│   ├── Span B (child of A)
│   └── Span C (child of A)
│       └── Span D (child of C)

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:
traceparent: 00-<trace-id>-<span-id>-<flags>
tracestate: vendor1=value1,vendor2=value2

OpenTelemetry API (24%)

Question 4

How do you create a span manually?

Show Solution
from opentelemetry import trace

tracer = trace.get_tracer(__name__)

with tracer.start_as_current_span("my-operation") as span:
    span.set_attribute("key", "value")
    span.add_event("processing started")
    # Do work
    span.set_status(trace.Status(trace.StatusCode.OK))
Tracer tracer = GlobalOpenTelemetry.getTracer("my-app");
Span span = tracer.spanBuilder("my-operation").startSpan();
try (Scope scope = span.makeCurrent()) {
    span.setAttribute("key", "value");
    // Do work
} finally {
    span.end();
}

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"
span.set_attribute("http.method", "GET")
span.add_event("cache_miss", {"key": "user:123"})

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 sample

Question 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 decision
from opentelemetry.sdk.trace.sampling import TraceIdRatioBased

sampler = TraceIdRatioBased(0.1)  # Sample 10%
provider = TracerProvider(sampler=sampler)

OpenTelemetry 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 → Exporters

Question 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 efficiency

Instrumentation (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
Or with environment variables:
export OTEL_SERVICE_NAME=my-service
export OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4317
opentelemetry-instrument 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

  1. Know the three signals - Traces, Metrics, Logs
  2. Understand Collector architecture - Receivers, Processors, Exporters
  3. Know SDK components - Providers, Processors, Exporters
  4. Practice configuration - Collector YAML, SDK setup
  5. Understand context propagation - W3C Trace Context

← Back to OTCA Overview