에이전트를 위한 관측 가능성(Observability)¶
ADK에서 지원Python v0.1.0Go v0.1.0Kotlin v0.1.0
에이전트를 위한 관측 가능성은 시스템의 외부 텔레메트리와 구조화된 로그를 분석하여, 추론 트레이스, 도구 호출, 잠재 모델 출력(latent model outputs)을 포함한 시스템 내부 상태를 측정할 수 있게 합니다. 에이전트를 구축할 때, 실행 중 동작(in-process behavior)을 디버깅하고 진단하기 위해 이러한 기능이 필요할 수 있습니다. 일정 수준 이상의 복잡도를 가진 에이전트에서는 기본적인 입력/출력 모니터링만으로는 보통 충분하지 않습니다.
Agent Development Kit(ADK)는 에이전트 모니터링 및 디버깅을 위한 로깅, 메트릭, 트레이스 기능을 기본 제공합니다. 다만 모니터링 및 분석을 위해서는 더 고급의 observability ADK 통합 기능도 고려해야 할 수 있습니다.
빠른 시작: Kotlin에서 관측성 활성화¶
Kotlin에서는 트레이스를 위한 OpenTelemetry를 구성하고 자세한 콘솔 출력을 위한 LoggingPlugin을 사용하여 포괄적인 관측성을 활성화할 수 있습니다.
// 1. Configure OpenTelemetry (Traces)
// ADK Kotlin uses GlobalOpenTelemetry to resolve its tracer on the JVM.
val spanExporter = OtlpGrpcSpanExporter.builder().setEndpoint("http://localhost:4317").build()
val resource =
Resource.getDefault()
.merge(
Resource.create(
Attributes.of(AttributeKey.stringKey("service.name"), "my-kotlin-agent"),
),
)
val tracerProvider =
SdkTracerProvider.builder()
.addSpanProcessor(BatchSpanProcessor.builder(spanExporter).build())
.setResource(resource)
.build()
OpenTelemetrySdk.builder().setTracerProvider(tracerProvider).buildAndRegisterGlobal()
// 2. Optional: Configure ADK Telemetry behavior
// Enable capturing full message content in traces (use with caution in production)
TelemetryConfig.captureMessageContent = true
// 3. Initialize Agent and Runner with LoggingPlugin for console output
val agent = LlmAgent(name = "my_agent", model = Gemini(name = "gemini-flash-latest"))
val runner =
InMemoryRunner(agent = agent, pluginManager = PluginManager(listOf(LoggingPlugin())))
// The runner will now automatically emit traces via GlobalOpenTelemetry
// and log activity to the console via the LoggingPlugin.
runner.run(
userId = "user123",
sessionId = "session456",
newMessage = Content.fromText(Role.USER, "Hello!"),
)
관측 가능성을 위한 ADK 통합
ADK용 사전 구축된 관측 가능성 라이브러리 목록은 도구 및 통합을 참조하세요.