Elixir & Phoenix: Scalable Backend Development · 강의

OpenTelemetry를 사용한 분산 추적

OpenTelemetry를 사용해 프로세스와 서비스 사이를 이동하는 요청을 추적하고, 흩어진 로그를 하나로 연결된 시간선으로 바꾸는 방법을 배웁니다.

레슨 4/413개 단계

OpenTelemetry를 사용한 분산 추적은(는) CoddyKit의 무료 Elixir & Phoenix: Scalable Backend Development 강의입니다. 이것은 4개 중 4번째 강의입니다. 아래에서 전체 강의를 무료로 읽을 수 있으며, 내장 코드 에디터와 24/7 AI 튜터와 함께 브라우저에서 직접 실습할 수 있습니다. 이 강의는 Elixir & Phoenix: Scalable Backend Development 학습 경로의 일부이며, 진행 상황이 웹과 CoddyKit 앱에 동기화됩니다. Elixir & Phoenix: Scalable Backend Development 강의에는 총 4개의 강의가 포함되어 있습니다.

이 강의의 일부는 아직 번역되지 않았으며 영어로 표시됩니다.

The Distributed Debugging Problem

In a system spread across services and processes, one user request touches many components. Plain logs cannot show how they connect. Distributed tracing stitches the whole journey into one timeline.

Traces and Spans

A trace represents one end-to-end request. It is made of spans — timed units of work like a DB query or an HTTP call. Spans nest to form a tree.

What is OpenTelemetry?

OpenTelemetry (OTel) is a vendor-neutral standard for traces, metrics, and logs. Elixir has first-class support via the opentelemetry packages, exporting to Jaeger, Honeycomb, Datadog, and more.

Adding the Dependencies

Add the API, SDK, and an exporter to your deps.

defp deps do
  [
    {:opentelemetry, "~> 1.3"},
    {:opentelemetry_exporter, "~> 1.6"},
    {:opentelemetry_phoenix, "~> 1.1"}
  ]
end

Auto-Instrumenting Phoenix

The opentelemetry_phoenix package hooks into Telemetry events so each request becomes a trace automatically. Set it up in your application start.

def start(_type, _args) do
  OpentelemetryPhoenix.setup()
  OpentelemetryEcto.setup([:my_app, :repo])
  Supervisor.start_link(children, opts)
end

Creating a Manual Span

For custom work, wrap it in a span with Tracer.with_span/2. It records start and end times automatically.

require OpenTelemetry.Tracer, as: Tracer
Tracer.with_span "charge_payment" do
  PaymentGateway.charge(order)
end

Adding Span Attributes

Attributes attach searchable context to a span, like the user id or order total.

Tracer.set_attributes([{"order.id", order.id}, {"order.total", order.total}])

Recording Errors

When something fails, mark the span so it stands out in your tracing UI.

Tracer.set_status(:error, "payment declined")
Tracer.record_exception(exception)

Context Propagation

The magic of tracing is context propagation: the trace id travels with the request across service boundaries via HTTP headers, so spans from different services join the same trace.

Exporting to a Backend

Configure an exporter to ship spans to your observability backend over OTLP.

config :opentelemetry,
  span_processor: :batch,
  traces_exporter: :otlp
config :opentelemetry_exporter,
  otlp_endpoint: "http://collector:4318"

Reading a Trace

In a tracing UI you see a waterfall of spans. Long bars reveal slow steps; gaps reveal waiting. This pinpoints latency far faster than scanning logs.

Quick Check

Test your tracing knowledge.

Recap

You learned distributed tracing with OpenTelemetry:

  • Traces are built from nested spans
  • Auto-instrument Phoenix and Ecto via Telemetry
  • Create manual spans with with_span and add attributes
  • Record errors on spans for visibility
  • Context propagation connects spans across services

Tracing turns multi-service requests into one readable timeline.

무료로 시작

AI 튜터와 함께 Elixir을(를) 배우세요 — 무료

브라우저에서 실제 코드를 작성하고 실행하며, 24/7 AI 튜터로부터 즉각적인 도움을 받고, 웹이나 앱에서 중단한 부분부터 계속 학습하세요.

코스
12
레슨
48

자주 묻는 질문

“OpenTelemetry를 사용한 분산 추적” 강의는 무료인가요?

네 — “OpenTelemetry를 사용한 분산 추적” 전체 내용을 이 웹사이트에서 무료로 읽을 수 있습니다. 인터랙티브하게 실습하려면(내장 코드 에디터와 24/7 AI 튜터), CoddyKit PRO로 업그레이드하면 Elixir & Phoenix: Scalable Backend Development 강의 전체를 잠금 해제할 수 있습니다. Elixir & Phoenix: Scalable Backend Development 강의에는 총 4개의 강의가 포함되어 있습니다.

“OpenTelemetry를 사용한 분산 추적”에서 뭘 배우나요?

OpenTelemetry를 사용해 프로세스와 서비스 사이를 이동하는 요청을 추적하고, 흩어진 로그를 하나로 연결된 시간선으로 바꾸는 방법을 배웁니다. 브라우저에서 직접 실행하는 실습 코드로 Elixir & Phoenix: Scalable Backend Development을(를) 배우며, 24/7 AI 튜터가 강의를 진행하면서 질문에 답변해줍니다.

Elixir & Phoenix: Scalable Backend Development을(를) 시작하는 데 경험이 필요한가요?

사전 경험은 필요하지 않습니다. CoddyKit의 Elixir & Phoenix: Scalable Backend Development은(는) 초급자부터 고급 학습자까지를 위해 구성되어 있으므로, 여기서 시작하거나 처음부터 시작할 수 있으며 자신의 속도대로 진행할 수 있습니다. 이것은 4개 중 4번째 강의입니다.

“OpenTelemetry를 사용한 분산 추적” 강의는 얼마나 걸리나요?

대부분의 CoddyKit 강의는 약 5~10분이 소요됩니다. 각 강의는 간결하고 인터랙티브하여 꾸준한 진행이 가능하며, 웹과 앱에서 중단한 부분부터 바로 시작할 수 있습니다.

이 Elixir & Phoenix: Scalable Backend Development 강의에서 코드를 작성하고 실행할 수 있나요?

네. 모든 Elixir & Phoenix: Scalable Backend Development 강의에는 내장 코드 에디터가 포함되어 있으므로, 브라우저에서 바로 실제 코드를 작성하고 실행한 후 즉시 AI 피드백을 받을 수 있습니다 — 로컬 설정이 필요 없습니다.

이 강의의 모든 강의

  1. Elixir 벤치마킹과 프로파일링
  2. Telemetry와 메트릭을 활용한 모니터링
  3. 오류 처리와 구조화된 로깅
  4. OpenTelemetry를 사용한 분산 추적
← Elixir & Phoenix: Scalable Backend Development(으)로 돌아가기