Skip to main content
VeADK Java uses OpenTelemetry to collect agent execution traces and export ADK Java model, tool, Runner session, and related spans to external observability systems. The current source provides OpenTelemetry.initOpenTelemetry(...), plus APMPlus and TLS exporters.

When to Use It

  • Observe model calls, tool calls, knowledge retrieval, memory retrieval, and Runner sessions.
  • Correlate Java agent traces with business request IDs, user IDs, or session IDs.
  • Export data to Volcengine APMPlus or TLS.
  • Flush queued traces or metrics before a short-lived process exits.

Initialize OpenTelemetry

Initialize OpenTelemetry before creating the Agent or running the Runner. OpenTelemetry.initOpenTelemetry(...) receives a list of ExporterFactory instances. If the list is empty, no global provider is registered.
After initialization, VeADK Java gives ADK Java telemetry the global OpenTelemetry tracer. The SDK also registers a shutdown hook to close the tracer provider and meter provider. For short-lived processes, explicitly call forceFlush() on the exporter when needed.

APMPlus

APMPlusExporter exports traces and metrics through OTLP/gRPC. The shortest setup is to provide an APMPlus AppKey explicitly:
When OBSERVABILITY_OPENTELEMETRY_APMPLUS_API_KEY is not set, APMPlusExporter resolves the AppKey through the APMPlus GetAppKey OpenAPI. Volcengine mode requires VOLCENGINE_ACCESS_KEY and VOLCENGINE_SECRET_KEY. With CLOUD_PROVIDER=byteplus, it prefers BYTEPLUS_ACCESS_KEY and BYTEPLUS_SECRET_KEY, then falls back to Volcengine credentials.

TLS

TLSExporter exports traces to Volcengine TLS through OTLP/gRPC. It reads the endpoint, topic, and region from environment variables and uses Volcengine AK/SK to build authentication headers.

Export to Multiple Backends

OpenTelemetry.initOpenTelemetry(...) combines multiple exporters into one composite exporter. Pass multiple exporters when traces should go to both APMPlus and TLS:
The APMPlus exporter also registers a metric reader. The TLS exporter currently exports traces only.

Data and Privacy

OpenTelemetry spans may include attributes from model, tool, knowledge-base, and memory paths. Before enabling production export, verify that:
  • API keys, AK/SK, tokens, cookies, and private user data are not written into prompts, tool arguments, metadata, or logs.
  • Agent names, Runner appName, userId, and sessionId are stable enough for cross-system debugging.
  • The target platform’s retention, access-control, and deletion policies are understood.
  • Short-lived processes call forceFlush() or leave enough time for the shutdown hook to export queued data.

Troubleshooting

Last modified on October 20, 2026