Files
2026-09-13 21:55:56 +00:00

375 lines
36 KiB
HTML

<!DOCTYPE HTML>
<html lang="en">
<head>
<!-- Google Analytics tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-DKHZS27PHP"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag("js", new Date());
gtag("config", "G-DKHZS27PHP");
</script>
<!-- Generated by javadoc (26) -->
<title>TraceManager (Google Agent Development Kit Maven Parent POM 1.7.0 API)</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="description" content="declaration: package: com.google.adk.plugins.agentanalytics, class: TraceManager">
<meta name="generator" content="javadoc/ClassWriter">
<link rel="stylesheet" type="text/css" href="../../../../../resource-files/jquery-ui.min.css">
<link rel="stylesheet" type="text/css" href="../../../../../resource-files/stylesheet.css">
<script type="text/javascript" src="../../../../../script-files/script.js"></script>
<script type="text/javascript" src="../../../../../script-files/jquery-3.7.1.min.js"></script>
<script type="text/javascript" src="../../../../../script-files/jquery-ui.min.js"></script>
</head>
<body class="class-declaration-page">
<script type="text/javascript">const pathtoroot = "../../../../../";
loadScripts();
initTheme();
</script>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
<header role="banner">
<nav role="navigation">
<!-- ========= START OF TOP NAVBAR ======= -->
<div class="top-nav" id="navbar-top">
<div class="nav-content">
<div class="nav-menu-button"><button id="navbar-toggle-button" aria-controls="navbar-top" aria-expanded="false" aria-label="Toggle navigation links"><span class="nav-bar-toggle-icon">&nbsp;</span><span class="nav-bar-toggle-icon">&nbsp;</span><span class="nav-bar-toggle-icon">&nbsp;</span></button></div>
<div class="skip-nav"><a href="#skip-navbar-top" title="Skip navigation links">Skip navigation links</a></div>
<ul id="navbar-top-firstrow" class="nav-list" title="Navigation">
<li><a href="../../../../../index.html">Overview</a></li>
<li class="nav-bar-cell1-rev">Class</li>
<li><a href="class-use/TraceManager.html">Use</a></li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../../../index-all.html">Index</a></li>
<li><a href="../../../../../search.html">Search</a></li>
<li><button id="theme-button" aria-label="Select Theme" title="Select Theme"></button></li>
</ul>
<div id="theme-panel">
<div>Select Theme</div>
<div><label for="theme-light"><input type="radio" id="theme-light" disabled name="theme" value="theme-light"><span>Light</span></label><label for="theme-dark"><input type="radio" id="theme-dark" disabled name="theme" value="theme-dark"><span>Dark</span></label><label for="theme-os"><input type="radio" id="theme-os" disabled name="theme" value="theme-os"><span>System Setting</span></label></div>
</div>
</div>
</div>
<div class="sub-nav">
<div class="nav-content">
<ol class="sub-nav-list">
<li><a href="package-summary.html">com.google.adk.plugins.agentanalytics</a></li>
<li><a href="TraceManager.html" class="current-selection">TraceManager</a></li>
</ol>
<div class="nav-list-search"><input type="text" id="search-input" disabled placeholder="Search documentation (type /)" aria-label="Search in documentation" autocomplete="off" spellcheck="false"><input type="reset" id="reset-search" disabled value="Reset"></div>
</div>
</div>
<!-- ========= END OF TOP NAVBAR ========= -->
<span class="skip-nav" id="skip-navbar-top"></span></nav>
</header>
<div class="main-grid">
<nav role="navigation" class="toc" aria-label="Table of contents">
<div class="toc-header">Contents&nbsp;<input type="text" class="filter-input" disabled placeholder="Filter contents (type .)" aria-label="Filter table of contents" autocomplete="off" spellcheck="false"><input type="reset" class="reset-filter" disabled tabindex="-1" value="Reset">&nbsp;<button class="toc-sort-toggle" id="toc-lexical-order-toggle"><img src="../../../../../resource-files/sort-a-z.svg" alt="Sort member details in lexicographical order"></button></div>
<ol class="toc-list" tabindex="-1">
<li><a href="#" tabindex="0">Description</a></li>
<li><a href="#method-summary" tabindex="0">Method Summary</a></li>
<li><a href="#method-detail" tabindex="0">Method Details</a>
<ol class="toc-list">
<li><a href="#getRootAgentName()" tabindex="0">getRootAgentName()</a></li>
<li><a href="#initTrace(com.google.adk.agents.InvocationContext)" tabindex="0">initTrace(InvocationContext)</a></li>
<li><a href="#initTraceIfNeeded(com.google.adk.agents.InvocationContext)" tabindex="0">initTraceIfNeeded(InvocationContext)</a></li>
<li><a href="#getTraceId(com.google.adk.agents.InvocationContext)" tabindex="0">getTraceId(InvocationContext)</a></li>
<li><a href="#pushSpan(com.google.adk.agents.InvocationContext,java.lang.String)" tabindex="0">pushSpan(InvocationContext, String)</a></li>
<li><a href="#attachCurrentSpan(com.google.adk.agents.InvocationContext)" tabindex="0">attachCurrentSpan(InvocationContext)</a></li>
<li><a href="#ensureInvocationSpan(com.google.adk.agents.InvocationContext)" tabindex="0">ensureInvocationSpan(InvocationContext)</a></li>
<li><a href="#popSpan(com.google.adk.agents.InvocationContext,java.lang.String)" tabindex="0">popSpan(InvocationContext, String)</a></li>
<li><a href="#popSpan(com.google.adk.agents.InvocationContext,java.lang.String,java.lang.String)" tabindex="0">popSpan(InvocationContext, String, String)</a></li>
<li><a href="#clearStack()" tabindex="0">clearStack()</a></li>
<li><a href="#getCurrentSpanAndParent(com.google.adk.agents.InvocationContext)" tabindex="0">getCurrentSpanAndParent(InvocationContext)</a></li>
<li><a href="#getCurrentSpanId(com.google.adk.agents.InvocationContext)" tabindex="0">getCurrentSpanId(InvocationContext)</a></li>
<li><a href="#recordFirstToken(java.lang.String)" tabindex="0">recordFirstToken(String)</a></li>
<li><a href="#getStartTime(java.lang.String)" tabindex="0">getStartTime(String)</a></li>
<li><a href="#getFirstTokenTime(java.lang.String)" tabindex="0">getFirstTokenTime(String)</a></li>
</ol>
</li>
</ol>
<button class="hide-sidebar"><span>Hide sidebar&nbsp;</span><img src="../../../../../resource-files/left.svg" alt="Hide sidebar"></button><button class="show-sidebar"><img src="../../../../../resource-files/right.svg" alt="Show sidebar"><span>&nbsp;Show sidebar</span></button></nav>
<main role="main">
<!-- ======== START OF CLASS DATA ======== -->
<div class="header">
<h1 title="Class TraceManager" class="title">Class TraceManager</h1>
</div>
<div class="inheritance" title="Inheritance Tree"><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Object.html" title="class in java.lang" class="external-link">java.lang.Object</a>
<div class="inheritance">com.google.adk.plugins.agentanalytics.TraceManager</div>
</div>
<section class="class-description" id="class-description">
<hr>
<div class="horizontal-scroll">
<div class="type-signature"><span class="modifiers">public final class </span><span class="element-name type-name-label">TraceManager</span>
<span class="extends-implements">extends <a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Object.html" title="class in java.lang" class="external-link">Object</a></span></div>
<div class="block">Manages the BQAA-internal execution tree of span IDs for one invocation.
<p>No OpenTelemetry spans are created: records are ID-only, so a host with an SDK exporter
configured never receives a duplicate plugin-owned span tree next to ADK's framework spans.
Ambient OpenTelemetry context is still consulted for the <code>trace_id</code> (and the invocation
root's <code>span_id</code>) so BigQuery rows stay joinable to Cloud Trace.
<p>Span records are kept in per-branch stacks keyed by <a href="../../agents/InvocationContext.html#branch()"><code>InvocationContext.branch()</code></a>.
Concurrently scheduled <code>ParallelAgent</code> branches (which share an invocation ID but carry
distinct branch strings) never touch each other's stacks, so a branch completing first can no
longer pop another branch's span. Within one branch, agent and model spans execute sequentially
and use top-of-stack semantics, but ADK executes an event's function calls CONCURRENTLY by
default: tool spans therefore carry an operation identity (the function-call ID) plus a parent
captured at push time, and are popped by identity rather than stack position. Pops additionally
verify the record's <code>kind</code>, so an error callback firing without its matching push cannot
pop an unrelated record.</div>
</div>
</section>
<section class="summary">
<ul class="summary-list">
<!-- ========== METHOD SUMMARY =========== -->
<li>
<section class="method-summary" id="method-summary">
<h2>Method Summary</h2>
<div id="method-summary-table">
<div class="table-tabs" role="tablist" aria-orientation="horizontal"><button id="method-summary-table-tab0" role="tab" aria-selected="true" aria-controls="method-summary-table.tabpanel" tabindex="0" onkeydown="switchTab(event)" onclick="show('method-summary-table', 'method-summary-table', 3)" class="active-table-tab">All Methods</button><button id="method-summary-table-tab2" role="tab" aria-selected="false" aria-controls="method-summary-table.tabpanel" tabindex="-1" onkeydown="switchTab(event)" onclick="show('method-summary-table', 'method-summary-table-tab2', 3)" class="table-tab">Instance Methods</button><button id="method-summary-table-tab4" role="tab" aria-selected="false" aria-controls="method-summary-table.tabpanel" tabindex="-1" onkeydown="switchTab(event)" onclick="show('method-summary-table', 'method-summary-table-tab4', 3)" class="table-tab">Concrete Methods</button></div>
<div id="method-summary-table.tabpanel" role="tabpanel" aria-labelledby="method-summary-table-tab0">
<div class="summary-table three-column-summary">
<div class="table-header col-first">Modifier and Type</div>
<div class="table-header col-second">Method</div>
<div class="table-header col-last">Description</div>
<div class="col-first even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/String.html" title="class in java.lang" class="external-link">String</a></code></div>
<div class="col-second even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#attachCurrentSpan(com.google.adk.agents.InvocationContext)" class="member-name-link">attachCurrentSpan</a><wbr>(<a href="../../agents/InvocationContext.html" title="class in com.google.adk.agents">InvocationContext</a>&nbsp;context)</code></div>
<div class="col-last even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4">
<div class="block">Records the ambient OpenTelemetry span's IDs as the invocation root without creating or owning
any span, so plugin-emitted rows correlate with the host's existing tracing.</div>
</div>
<div class="col-first odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code>void</code></div>
<div class="col-second odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#clearStack()" class="member-name-link">clearStack</a>()</code></div>
<div class="col-last odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4">&nbsp;</div>
<div class="col-first even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code>void</code></div>
<div class="col-second even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#ensureInvocationSpan(com.google.adk.agents.InvocationContext)" class="member-name-link">ensureInvocationSpan</a><wbr>(<a href="../../agents/InvocationContext.html" title="class in com.google.adk.agents">InvocationContext</a>&nbsp;context)</code></div>
<div class="col-last even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4">&nbsp;</div>
<div class="col-first odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code>com.google.adk.plugins.agentanalytics.TraceManager.SpanIds</code></div>
<div class="col-second odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#getCurrentSpanAndParent(com.google.adk.agents.InvocationContext)" class="member-name-link">getCurrentSpanAndParent</a><wbr>(<a href="../../agents/InvocationContext.html" title="class in com.google.adk.agents">InvocationContext</a>&nbsp;context)</code></div>
<div class="col-last odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4">&nbsp;</div>
<div class="col-first even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/Optional.html" title="class in java.util" class="external-link">Optional</a><wbr>&lt;<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/String.html" title="class in java.lang" class="external-link">String</a>&gt;</code></div>
<div class="col-second even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#getCurrentSpanId(com.google.adk.agents.InvocationContext)" class="member-name-link">getCurrentSpanId</a><wbr>(<a href="../../agents/InvocationContext.html" title="class in com.google.adk.agents">InvocationContext</a>&nbsp;context)</code></div>
<div class="col-last even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4">&nbsp;</div>
<div class="col-first odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/Optional.html" title="class in java.util" class="external-link">Optional</a><wbr>&lt;<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/time/Instant.html" title="class in java.time" class="external-link">Instant</a>&gt;</code></div>
<div class="col-second odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#getFirstTokenTime(java.lang.String)" class="member-name-link">getFirstTokenTime</a><wbr>(<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/String.html" title="class in java.lang" class="external-link">String</a>&nbsp;spanId)</code></div>
<div class="col-last odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4">&nbsp;</div>
<div class="col-first even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/String.html" title="class in java.lang" class="external-link">String</a></code></div>
<div class="col-second even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#getRootAgentName()" class="member-name-link">getRootAgentName</a>()</code></div>
<div class="col-last even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4">&nbsp;</div>
<div class="col-first odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/Optional.html" title="class in java.util" class="external-link">Optional</a><wbr>&lt;<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/time/Instant.html" title="class in java.time" class="external-link">Instant</a>&gt;</code></div>
<div class="col-second odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#getStartTime(java.lang.String)" class="member-name-link">getStartTime</a><wbr>(<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/String.html" title="class in java.lang" class="external-link">String</a>&nbsp;spanId)</code></div>
<div class="col-last odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4">&nbsp;</div>
<div class="col-first even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/String.html" title="class in java.lang" class="external-link">String</a></code></div>
<div class="col-second even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#getTraceId(com.google.adk.agents.InvocationContext)" class="member-name-link">getTraceId</a><wbr>(<a href="../../agents/InvocationContext.html" title="class in com.google.adk.agents">InvocationContext</a>&nbsp;context)</code></div>
<div class="col-last even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4">&nbsp;</div>
<div class="col-first odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code>void</code></div>
<div class="col-second odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#initTrace(com.google.adk.agents.InvocationContext)" class="member-name-link">initTrace</a><wbr>(<a href="../../agents/InvocationContext.html" title="class in com.google.adk.agents">InvocationContext</a>&nbsp;context)</code></div>
<div class="col-last odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4">&nbsp;</div>
<div class="col-first even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code>void</code></div>
<div class="col-second even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#initTraceIfNeeded(com.google.adk.agents.InvocationContext)" class="member-name-link">initTraceIfNeeded</a><wbr>(<a href="../../agents/InvocationContext.html" title="class in com.google.adk.agents">InvocationContext</a>&nbsp;context)</code></div>
<div class="col-last even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4">
<div class="block">Sets the root agent name from the invocation context if it is still the sentinel default.</div>
</div>
<div class="col-first odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/Optional.html" title="class in java.util" class="external-link">Optional</a><wbr>&lt;com.google.adk.plugins.agentanalytics.TraceManager.RecordData&gt;</code></div>
<div class="col-second odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#popSpan(com.google.adk.agents.InvocationContext,java.lang.String)" class="member-name-link">popSpan</a><wbr>(<a href="../../agents/InvocationContext.html" title="class in com.google.adk.agents">InvocationContext</a>&nbsp;context,
<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/String.html" title="class in java.lang" class="external-link">String</a>&nbsp;expectedKindPrefix)</code></div>
<div class="col-last odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4">
<div class="block">Pops the calling branch's top span record if its kind matches <code>expectedKindPrefix</code>.</div>
</div>
<div class="col-first even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/Optional.html" title="class in java.util" class="external-link">Optional</a><wbr>&lt;com.google.adk.plugins.agentanalytics.TraceManager.RecordData&gt;</code></div>
<div class="col-second even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#popSpan(com.google.adk.agents.InvocationContext,java.lang.String,java.lang.String)" class="member-name-link">popSpan</a><wbr>(<a href="../../agents/InvocationContext.html" title="class in com.google.adk.agents">InvocationContext</a>&nbsp;context,
<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/String.html" title="class in java.lang" class="external-link">String</a>&nbsp;expectedKindPrefix,
@Nullable <a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/String.html" title="class in java.lang" class="external-link">String</a>&nbsp;operationId)</code></div>
<div class="col-last even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4">
<div class="block">Pops the calling branch's matching span record.</div>
</div>
<div class="col-first odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/String.html" title="class in java.lang" class="external-link">String</a></code></div>
<div class="col-second odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#pushSpan(com.google.adk.agents.InvocationContext,java.lang.String)" class="member-name-link">pushSpan</a><wbr>(<a href="../../agents/InvocationContext.html" title="class in com.google.adk.agents">InvocationContext</a>&nbsp;context,
<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/String.html" title="class in java.lang" class="external-link">String</a>&nbsp;spanName)</code></div>
<div class="col-last odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4">
<div class="block">Pushes an ID-only span record onto the calling branch's stack.</div>
</div>
<div class="col-first even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code>void</code></div>
<div class="col-second even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#recordFirstToken(java.lang.String)" class="member-name-link">recordFirstToken</a><wbr>(<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/String.html" title="class in java.lang" class="external-link">String</a>&nbsp;spanId)</code></div>
<div class="col-last even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4">&nbsp;</div>
</div>
</div>
</div>
<div class="inherited-list">
<h3 id="methods-inherited-from-class-java.lang.Object">Methods inherited from class&nbsp;<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Object.html#method-summary" title="class in java.lang" class="external-link">Object</a></h3>
<code><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Object.html#clone()" title="clone()" class="external-link">clone</a>, <a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Object.html#equals(java.lang.Object)" title="equals(Object)" class="external-link">equals</a>, <a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Object.html#finalize()" title="finalize()" class="external-link">finalize</a>, <a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Object.html#getClass()" title="getClass()" class="external-link">getClass</a>, <a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Object.html#hashCode()" title="hashCode()" class="external-link">hashCode</a>, <a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Object.html#notify()" title="notify()" class="external-link">notify</a>, <a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Object.html#notifyAll()" title="notifyAll()" class="external-link">notifyAll</a>, <a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Object.html#toString()" title="toString()" class="external-link">toString</a>, <a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Object.html#wait()" title="wait()" class="external-link">wait</a>, <a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Object.html#wait(long)" title="wait(long)" class="external-link">wait</a>, <a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Object.html#wait(long,int)" title="wait(long, int)" class="external-link">wait</a></code></div>
</section>
</li>
</ul>
</section>
<section class="details">
<ul class="details-list">
<!-- ============ METHOD DETAIL ========== -->
<li>
<section class="method-details" id="method-detail">
<h2>Method Details</h2>
<ul class="member-list">
<li>
<section class="detail" id="getRootAgentName()">
<h3>getRootAgentName</h3>
<div class="horizontal-scroll">
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span class="return-type"><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/String.html" title="class in java.lang" class="external-link">String</a></span>&nbsp;<span class="element-name">getRootAgentName</span>()</div>
</div>
</section>
</li>
<li>
<section class="detail" id="initTrace(com.google.adk.agents.InvocationContext)">
<h3>initTrace</h3>
<div class="horizontal-scroll">
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span class="return-type">void</span>&nbsp;<span class="element-name">initTrace</span><wbr><span class="parameters">(<a href="../../agents/InvocationContext.html" title="class in com.google.adk.agents">InvocationContext</a>&nbsp;context)</span></div>
</div>
</section>
</li>
<li>
<section class="detail" id="initTraceIfNeeded(com.google.adk.agents.InvocationContext)">
<h3>initTraceIfNeeded</h3>
<div class="horizontal-scroll">
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span class="return-type">void</span>&nbsp;<span class="element-name">initTraceIfNeeded</span><wbr><span class="parameters">(<a href="../../agents/InvocationContext.html" title="class in com.google.adk.agents">InvocationContext</a>&nbsp;context)</span></div>
<div class="block">Sets the root agent name from the invocation context if it is still the sentinel default.
Null-safe: workflow-driven callbacks with no current agent leave the sentinel in place for a
later event to resolve.</div>
</div>
</section>
</li>
<li>
<section class="detail" id="getTraceId(com.google.adk.agents.InvocationContext)">
<h3>getTraceId</h3>
<div class="horizontal-scroll">
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span class="return-type"><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/String.html" title="class in java.lang" class="external-link">String</a></span>&nbsp;<span class="element-name">getTraceId</span><wbr><span class="parameters">(<a href="../../agents/InvocationContext.html" title="class in com.google.adk.agents">InvocationContext</a>&nbsp;context)</span></div>
</div>
</section>
</li>
<li>
<section class="detail" id="pushSpan(com.google.adk.agents.InvocationContext,java.lang.String)">
<h3>pushSpan</h3>
<div class="horizontal-scroll">
<div class="member-signature"><span class="annotations">@CanIgnoreReturnValue
</span><span class="modifiers">public</span>&nbsp;<span class="return-type"><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/String.html" title="class in java.lang" class="external-link">String</a></span>&nbsp;<span class="element-name">pushSpan</span><wbr><span class="parameters">(<a href="../../agents/InvocationContext.html" title="class in com.google.adk.agents">InvocationContext</a>&nbsp;context,
<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/String.html" title="class in java.lang" class="external-link">String</a>&nbsp;spanName)</span></div>
<div class="block">Pushes an ID-only span record onto the calling branch's stack. No OTel span is created.</div>
</div>
</section>
</li>
<li>
<section class="detail" id="attachCurrentSpan(com.google.adk.agents.InvocationContext)">
<h3>attachCurrentSpan</h3>
<div class="horizontal-scroll">
<div class="member-signature"><span class="annotations">@CanIgnoreReturnValue
</span><span class="modifiers">public</span>&nbsp;<span class="return-type"><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/String.html" title="class in java.lang" class="external-link">String</a></span>&nbsp;<span class="element-name">attachCurrentSpan</span><wbr><span class="parameters">(<a href="../../agents/InvocationContext.html" title="class in com.google.adk.agents">InvocationContext</a>&nbsp;context)</span></div>
<div class="block">Records the ambient OpenTelemetry span's IDs as the invocation root without creating or owning
any span, so plugin-emitted rows correlate with the host's existing tracing.</div>
</div>
</section>
</li>
<li>
<section class="detail" id="ensureInvocationSpan(com.google.adk.agents.InvocationContext)">
<h3>ensureInvocationSpan</h3>
<div class="horizontal-scroll">
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span class="return-type">void</span>&nbsp;<span class="element-name">ensureInvocationSpan</span><wbr><span class="parameters">(<a href="../../agents/InvocationContext.html" title="class in com.google.adk.agents">InvocationContext</a>&nbsp;context)</span></div>
</div>
</section>
</li>
<li>
<section class="detail" id="popSpan(com.google.adk.agents.InvocationContext,java.lang.String)">
<h3>popSpan</h3>
<div class="horizontal-scroll">
<div class="member-signature"><span class="annotations">@CanIgnoreReturnValue
</span><span class="modifiers">public</span>&nbsp;<span class="return-type"><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/Optional.html" title="class in java.util" class="external-link">Optional</a>&lt;com.google.adk.plugins.agentanalytics.TraceManager.RecordData&gt;</span>&nbsp;<span class="element-name">popSpan</span><wbr><span class="parameters">(<a href="../../agents/InvocationContext.html" title="class in com.google.adk.agents">InvocationContext</a>&nbsp;context,
<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/String.html" title="class in java.lang" class="external-link">String</a>&nbsp;expectedKindPrefix)</span></div>
<div class="block">Pops the calling branch's top span record if its kind matches <code>expectedKindPrefix</code>.
<p>The branch scoping prevents a concurrently completing <code>ParallelAgent</code> branch from
popping another branch's span; the kind check prevents a mismatched pop (e.g. an error callback
firing without its corresponding push) from corrupting the stack.</div>
</div>
</section>
</li>
<li>
<section class="detail" id="popSpan(com.google.adk.agents.InvocationContext,java.lang.String,java.lang.String)">
<h3>popSpan</h3>
<div class="horizontal-scroll">
<div class="member-signature"><span class="annotations">@CanIgnoreReturnValue
</span><span class="modifiers">public</span>&nbsp;<span class="return-type"><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/Optional.html" title="class in java.util" class="external-link">Optional</a>&lt;com.google.adk.plugins.agentanalytics.TraceManager.RecordData&gt;</span>&nbsp;<span class="element-name">popSpan</span><wbr><span class="parameters">(<a href="../../agents/InvocationContext.html" title="class in com.google.adk.agents">InvocationContext</a>&nbsp;context,
<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/String.html" title="class in java.lang" class="external-link">String</a>&nbsp;expectedKindPrefix,
@Nullable <a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/String.html" title="class in java.lang" class="external-link">String</a>&nbsp;operationId)</span></div>
<div class="block">Pops the calling branch's matching span record.
<p>With an <code>operationId</code>, the record is located by kind AND operation identity
(newest-first) rather than stack position: ADK executes an event's function calls concurrently
by default within one branch, so a completion must remove its own record even when a sibling
tool's record sits above it. Without an <code>operationId</code>, only the branch's top record is
popped, and only when its kind matches.</div>
</div>
</section>
</li>
<li>
<section class="detail" id="clearStack()">
<h3>clearStack</h3>
<div class="horizontal-scroll">
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span class="return-type">void</span>&nbsp;<span class="element-name">clearStack</span>()</div>
</div>
</section>
</li>
<li>
<section class="detail" id="getCurrentSpanAndParent(com.google.adk.agents.InvocationContext)">
<h3>getCurrentSpanAndParent</h3>
<div class="horizontal-scroll">
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span class="return-type">com.google.adk.plugins.agentanalytics.TraceManager.SpanIds</span>&nbsp;<span class="element-name">getCurrentSpanAndParent</span><wbr><span class="parameters">(<a href="../../agents/InvocationContext.html" title="class in com.google.adk.agents">InvocationContext</a>&nbsp;context)</span></div>
</div>
</section>
</li>
<li>
<section class="detail" id="getCurrentSpanId(com.google.adk.agents.InvocationContext)">
<h3>getCurrentSpanId</h3>
<div class="horizontal-scroll">
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span class="return-type"><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/Optional.html" title="class in java.util" class="external-link">Optional</a>&lt;<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/String.html" title="class in java.lang" class="external-link">String</a>&gt;</span>&nbsp;<span class="element-name">getCurrentSpanId</span><wbr><span class="parameters">(<a href="../../agents/InvocationContext.html" title="class in com.google.adk.agents">InvocationContext</a>&nbsp;context)</span></div>
</div>
</section>
</li>
<li>
<section class="detail" id="recordFirstToken(java.lang.String)">
<h3>recordFirstToken</h3>
<div class="horizontal-scroll">
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span class="return-type">void</span>&nbsp;<span class="element-name">recordFirstToken</span><wbr><span class="parameters">(<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/String.html" title="class in java.lang" class="external-link">String</a>&nbsp;spanId)</span></div>
</div>
</section>
</li>
<li>
<section class="detail" id="getStartTime(java.lang.String)">
<h3>getStartTime</h3>
<div class="horizontal-scroll">
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span class="return-type"><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/Optional.html" title="class in java.util" class="external-link">Optional</a>&lt;<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/time/Instant.html" title="class in java.time" class="external-link">Instant</a>&gt;</span>&nbsp;<span class="element-name">getStartTime</span><wbr><span class="parameters">(<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/String.html" title="class in java.lang" class="external-link">String</a>&nbsp;spanId)</span></div>
</div>
</section>
</li>
<li>
<section class="detail" id="getFirstTokenTime(java.lang.String)">
<h3>getFirstTokenTime</h3>
<div class="horizontal-scroll">
<div class="member-signature"><span class="modifiers">public</span>&nbsp;<span class="return-type"><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/Optional.html" title="class in java.util" class="external-link">Optional</a>&lt;<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/time/Instant.html" title="class in java.time" class="external-link">Instant</a>&gt;</span>&nbsp;<span class="element-name">getFirstTokenTime</span><wbr><span class="parameters">(<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/String.html" title="class in java.lang" class="external-link">String</a>&nbsp;spanId)</span></div>
</div>
</section>
</li>
</ul>
</section>
</li>
</ul>
</section>
<!-- ========= END OF CLASS DATA ========= -->
<footer>
<hr>
<p class="legal-copy"><small>Copyright &#169; 1980. All rights reserved.</small></p>
</footer>
</main>
</div>
</body>
</html>