Implement initial OTel setup for ADK agents#89
Merged
peterj merged 1 commit intoagentregistry-dev:mainfrom Jan 15, 2026
Merged
Conversation
peterj
approved these changes
Jan 15, 2026
christian-posta
pushed a commit
to christian-posta/agentregistry
that referenced
this pull request
Mar 9, 2026
This PR lets you enable ADK's built-in instrumentation and specify an `otlp` endpoint where you can push tracing data. Example output from an instrumented agent: ``` Span agentregistry-dev#2 Trace ID : e5091e6a8908770a95bf5ed73b852e29 Parent ID : 3e7bbdb443a54eff ID : 8ea357d47f0058c1 Name : call_llm Kind : Internal Start time : 2026-01-14 16:53:18.36083154 +0000 UTC End time : 2026-01-14 16:53:19.579240184 +0000 UTC Status code : Unset Status message : DroppedAttributesCount: 0 DroppedEventsCount: 0 DroppedLinksCount: 0 Attributes: -> gen_ai.system: Str(gcp.vertex.agent) -> gen_ai.request.model: Str(openai/gpt-4) -> gcp.vertex.agent.invocation_id: Str(e-f3aeaf51-6172-4ee4-9c69-5977fca52be4) -> gcp.vertex.agent.session_id: Str(ctx-4fa656b9-5bc8-4a55-b530-1c5ff1218369) -> gcp.vertex.agent.event_id: Str(f8bc6371-66c1-45ac-ba7d-9bb45115c1b1) -> gcp.vertex.agent.llm_request: Str({"model": "openai/gpt-4", "config": {"system_instruction": "\nYou roll dice and answer questions about the outcome of the dice rolls.\nYou can roll dice of different sizes.\nYou can use multiple tools in parallel by calling functions in parallel (in one request and in one round).\nIt is ok to discuss previous dice roles, and comment on the dice rolls.\nWhen you are asked to roll a die, you must call the roll_die tool with the number of sides. Be sure to pass in an integer. Do not pass in a string.\nYou should never roll a die on your own.\nWhen checking prime numbers, call the check_prime tool with a list of integers. Be sure to pass in a list of integers. You should never pass in a string.\nYou should not check prime numbers before calling the tool.\nWhen you are asked to roll a die and check prime numbers, you should always make the following two function calls:\n1. You should first call the roll_die tool to get a roll. Wait for the function response before calling the check_prime tool.\n2. After you get the function response from roll_die tool, you should call the check_prime tool with the roll_die result.\n2.1 If user asks you to check primes based on previous rolls, make sure you include the previous rolls in the list.\n3. When you respond, you must include the roll_die result from step 1.\nYou should always perform the previous 3 steps when asking for a roll and checking prime numbers.\nYou should not rely on the previous history on prime results.\n\n\n \n\nYou are an agent. Your internal name is \"testagent_agent\".\n\n The description about you is \"testagent agent.\"", "tools": [{"function_declarations": [{"name": "roll_die", "parameters": {"properties": {"sides": {"type": "INTEGER"}}, "required": ["sides"], "type": "OBJECT"}}, {"name": "check_prime", "parameters": {"properties": {"nums": {"items": {"type": "INTEGER"}, "type": "ARRAY"}}, "required": ["nums"], "type": "OBJECT"}}]}], "labels": {"adk_agent_name": "testagent_agent"}}, "contents": [{"parts": [{"text": "roll a dice"}], "role": "user"}, {"parts": [{"function_call": {"id": "call_74woxaXXP1F568UBe38QBVMe", "args": {"sides": 6}, "name": "roll_die"}}], "role": "model"}, {"parts": [{"function_response": {"id": "call_74woxaXXP1F568UBe38QBVMe", "name": "roll_die", "response": {"result": 3}}}], "role": "user"}]}) -> gcp.vertex.agent.llm_response: Str({"content":{"parts":[{"text":"I rolled a 6-sided die, and the result is 3."}],"role":"model"},"partial":false,"usage_metadata":{"candidates_token_count":16,"prompt_token_count":412,"total_token_count":428}}) -> gen_ai.usage.input_tokens: Int(412) -> gen_ai.usage.output_tokens: Int(16) Span agentregistry-dev#3 Trace ID : e5091e6a8908770a95bf5ed73b852e29 Parent ID : 4afadb631b31a6fb ID : 3e7bbdb443a54eff Name : invoke_agent testagent_agent Kind : Internal Start time : 2026-01-14 16:53:16.961428433 +0000 UTC End time : 2026-01-14 16:53:19.579316392 +0000 UTC Status code : Unset Status message : DroppedAttributesCount: 0 DroppedEventsCount: 0 DroppedLinksCount: 0 Attributes: -> gen_ai.operation.name: Str(invoke_agent) -> gen_ai.agent.description: Str(testagent agent.) -> gen_ai.agent.name: Str(testagent_agent) -> gen_ai.conversation.id: Str(ctx-4fa656b9-5bc8-4a55-b530-1c5ff1218369) Span agentregistry-dev#4 Trace ID : e5091e6a8908770a95bf5ed73b852e29 Parent ID : fc71e0b4a7043e64 ID : 4afadb631b31a6fb Name : invocation Kind : Internal Start time : 2026-01-14 16:53:16.961243435 +0000 UTC End time : 2026-01-14 16:53:19.57933835 +0000 UTC Status code : Unset Status message : DroppedAttributesCount: 0 DroppedEventsCount: 0 DroppedLinksCount: 0 {"resource": {"service.instance.id": "76f643d2-7d3f-4029-83da-bf0f9e7d1c37", "service.name": "otelcol", "service.version": "0.143.1"}, "otelcol.component.id": "debug", "otelcol.component.kind": "exporter", "otelcol.signal": "traces"} ```
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR lets you enable ADK's built-in instrumentation and specify an
otlpendpoint where you can push tracing data.Example output from an instrumented agent: