ElGraph.LLM.Telemetry (ElGraph v0.3.0)

Copy Markdown View Source

LLM 호출 계측 헬퍼 (관측/Langfuse 연동의 토대).

[:el_graph, :llm, :chat] span을 낸다 — start/stop/exception 자동(:telemetry.span). stop 메타에 provider·model·토큰 사용량(성공) 또는 error(실패)를 싣는다. 이 메타가 OTel GenAI semconv(gen_ai.usage.*)로 매핑되어 어느 관측 백엔드로든 흐른다.

Summary

Functions

LLM 호출(fun)을 telemetry span으로 감싼다.

Functions

instrument(provider, model, fun)

@spec instrument(atom(), String.t(), (-> term())) :: term()

LLM 호출(fun)을 telemetry span으로 감싼다.

fun{:ok, %{usage: ...}} 또는 {:error, reason}을 반환해야 한다.