AgentOps 빠른 시작 — 두 줄로 자동 계측 시작하기
AgentOps 빠른 시작 — 두 줄로 자동 계측 시작하기
AgentOps는 AI 에이전트 프로젝트에 쉽게 통합되도록 설계됐어요. 최소 설정으로 강력한 옵저버빌리티를 얻을 수 있고, 지원되는 LLM·에이전트 프레임워크 호출을 두 줄의 Python 코드로 모니터링할 수 있습니다.
설치
SDK를 설치하세요. API 키 관리를 편하게 하려면 python-dotenv를 함께 설치하는 것을 권장합니다.
pip install agentops python-dotenv
초기 설정 — 두 줄
- Import: 스크립트에서
import agentops - Initialize: API 키로
agentops.init()호출
import agentops
import os
from dotenv import load_dotenv
# Load environment variables (recommended for API keys)
load_dotenv()
# The API key can be passed directly or set as an environment variable AGENTOPS_API_KEY
AGENTOPS_API_KEY = os.getenv("AGENTOPS_API_KEY")
agentops.init(AGENTOPS_API_KEY)
# That's it for basic auto-instrumentation!
# If you're using a supported library (like OpenAI, LangChain, CrewAI, etc.),
# AgentOps will now automatically track LLM calls and agent actions.
API 키는 AgentOps Dashboard에서 받을 수 있어요. .env 파일에 둔다면 agentops.init() 앞에 load_dotenv()가 실행되어야 합니다.
실행과 트레이스 보기
두 줄을 추가하고 API 키를 준비했다면, 평소처럼 앱을 실행하세요. AgentOps가 지원 라이브러리를 자동으로 계측해 트레이스 데이터를 보내고, Dashboard에서 에이전트 동작을 관찰할 수 있습니다.
데코레이터로 더 세밀하게
자동 계측도 강력하지만, 커스텀 코드 부분을 추적하고 싶다면 @operation, @agent, @tool, @trace 데코레이터를 쓸 수 있어요. 특정 함수를 @operation으로 감싸면 실행·파라미터·반환값을 추적하고, @agent로 클래스를 묶으면 모든 하위 작업을 그 에이전트 컨텍스트로 그룹화합니다.
from agentops.sdk.decorators import operation
@operation
def process_data(data):
# Your function logic here
processed_result = data.upper()
return processed_result
@tool은 특정 도구 사용을 비용과 함께 추적하고, @trace는 일련의 작업을 하나의 논리적 워크플로로 묶습니다. 자세한 데코레이터는 Decorators를 참고하세요.
더 알아보기
- 대시보드 개요는 Introduction 참고
- 데코레이터 종류는 Decorators 참고