로그 레벨
로그 레벨 (Log Levels)
trace는 observation이 매우 많을 수 있어요(데이터 모델). level 속성으로 observation의 중요도를 구분해 trace의 장황함을 제어하고 에러와 경고를 강조할 수 있어요. 사용 가능한 레벨: DEBUG, DEFAULT, WARNING, ERROR.
출처: 문서
본문
trace는 observation이 매우 많을 수 있어요. level 속성으로 observation의 중요도를 구분해 trace의 장황함(verbosity)을 제어하고 에러와 경고를 강조할 수 있어요. 사용 가능한 레벨: DEBUG, DEFAULT, WARNING, ERROR.
레벨 외에도 statusMessage를 포함해 추가 컨텍스트를 제공할 수 있어요.

Python SDK
@observe() 데코레이터 사용 시:
from langfuse import observe, get_client
@observe()
def my_function():
langfuse = get_client()
# ... processing logic ...
# Update the current observation with a warning level
langfuse.update_current_span(
level="WARNING",
status_message="This is a warning"
)
observation을 직접 생성할 때:
from langfuse import get_client
langfuse = get_client()
# Using context managers (recommended)
with langfuse.start_as_current_observation(as_type="span", name="my-operation") as span:
# Set level and status message on creation
with span.start_as_current_observation(
name="potentially-risky-operation",
level="WARNING",
status_message="Operation may fail"
) as risky_span:
# ... do work ...
# Or update level and status message later
risky_span.update(
level="ERROR",
status_message="Operation failed with unexpected input"
)
# You can also update the currently active observation without a direct reference
with langfuse.start_as_current_observation(as_type="span", name="another-operation"):
# ... some processing ...
langfuse.update_current_span(
level="DEBUG",
status_message="Processing intermediate results"
)
generation을 만들 때 레벨을 설정할 수도 있어요:
langfuse = get_client()
with langfuse.start_as_current_observation(
as_type="generation",
name="llm-call",
model="gpt-4o",
level="DEFAULT" # Default level
) as generation:
# ... make LLM call ...
if error_detected:
generation.update(
level="ERROR",
status_message="Model returned malformed output"
)
JS/TS SDK
컨텍스트 매니저 사용 시:
import { startActiveObservation, startObservation } from "@langfuse/tracing";
await startActiveObservation("context-manager", async (span) => {
span.update({
input: { query: "What is the capital of France?" },
});
updateActiveObservation({
level: "WARNING",
statusMessage: "This is a warning",
});
});
observe 래퍼 사용 시:
import { observe, updateActiveObservation } from "@langfuse/tracing";
// An existing function
async function fetchData(source: string) {
updateActiveObservation({
level: "WARNING",
statusMessage: "This is a warning",
});
// ... logic to fetch data
return { data: `some data from ${source}` };
}
// Wrap the function to trace it
const tracedFetchData = observe(fetchData, {
name: "observe-wrapper",
});
const result = await tracedFetchData("API");
observation을 수동 생성할 때:
import { startObservation } from "@langfuse/tracing";
const span = startObservation("manual-observation", {
input: { query: "What is the capital of France?" },
});
span.update({
level: "WARNING",
statusMessage: "This is a warning",
});
span.update({ output: "Paris" }).end();
자세한 내용은 JS/TS SDK docs를 참고하세요.
OpenAI SDK: OpenAI SDK Integration을 사용하면 level과 statusMessage가 OpenAI API 응답에 기반해 자동으로 설정돼요. 예시를 참고하세요.
Langchain: LangChain Integration을 사용하면 LangChain 파이프라인의 각 단계에 대해 level과 statusMessage가 자동으로 설정돼요.
로그 레벨로 trace 필터링 (Filter Trace by Log Level)
단일 trace를 볼 때 observation을 로그 레벨로 필터링할 수 있어요.
GitHub Discussions
더 알아보기 (Learn more)
- 출처 문서: 로그 레벨 (Log Levels)