traceAI-a2a
Trace A2A requests across agents in Future AGI using the A2A SDK's native OpenTelemetry spans.
Install
Use Python 3.10 or later. This example uses the A2A SDK 1.3 API.
pip install "traceAI-a2a[a2a]" "a2a-sdk==1.3.0"
The adapter supports the older A2AClient API in SDK 0.2.x and the transport-based clients in SDK 0.3.x and 1.x. Keep your existing A2AInstrumentor().instrument(tracer_provider=provider) setup; you do not need a second client instrumentor.
Configure tracing
Set FI_API_KEY and FI_SECRET_KEY in your environment, then configure tracing before creating clients:
from fi_instrumentation import register
from fi_instrumentation.fi_types import ProjectType
from traceai_a2a import A2AInstrumentor
provider = register(
project_type=ProjectType.OBSERVE,
project_name="agent-workflows",
)
A2AInstrumentor().instrument(tracer_provider=provider)
The adapter routes A2A's native tracers to this provider without replacing the global OpenTelemetry provider. It enriches the native client operation rather than creating a second client span. Private transport-helper spans are suppressed within that operation.
Send a message
Point A2A_AGENT_URL at your agent's base URL. The SDK discovers its agent card and selects a supported transport.
import asyncio
import os
from uuid import uuid4
import httpx
from a2a.client import ClientConfig, create_client
from a2a.types import SendMessageRequest
async def main():
async with httpx.AsyncClient() as http:
client = await create_client(
os.environ["A2A_AGENT_URL"],
client_config=ClientConfig(httpx_client=http, streaming=False),
)
try:
request = SendMessageRequest(
message={
"message_id": str(uuid4()),
"role": 1, # ROLE_USER
"parts": [{"text": "Summarize the latest release notes."}],
}
)
async for event in client.send_message(request):
print(event)
finally:
await client.close()
try:
asyncio.run(main())
finally:
provider.force_flush()
In Future AGI, open Observe, select agent-workflows, and open the latest trace. The native a2a-python-sdk client span includes the operation, message role and part count, endpoint origin, streaming flag, and task ID/state when the response contains them. A2A does not itself perform a model call, so these spans do not include token usage or model costs.
Receive requests
The receiving service must extract incoming trace context. If your ASGI application does not already have OpenTelemetry HTTP server middleware, wrap the A2A application:
from traceai_a2a import A2ATracingMiddleware
# a2a_app is your existing A2A ASGI application.
app = A2ATracingMiddleware(a2a_app, tracer_provider=provider)
An existing outer OpenTelemetry SERVER span is reused. Configure your model/framework instrumentation separately to see the receiving agent's internal work beneath it. For gRPC servers, use an OpenTelemetry gRPC server interceptor to extract the propagated metadata; the ASGI middleware only handles HTTP.
Close streams when stopping early
Use ClientConfig(streaming=True) for an agent that supports streaming. A client span stays open until the stream is exhausted or explicitly closed. Use aclosing if you may stop early:
from contextlib import aclosing
async with aclosing(client.send_message(request)) as events:
async for event in events:
print(event)
break
The adapter also supports direct transport send_message_streaming() calls. Span context is active while the SDK advances the stream, not while your application handles a yielded event.
Privacy and troubleshooting
- Message bodies, artifacts, authentication headers, URL credentials/paths/queries, and exception messages/stack traces are not captured by this adapter. Task IDs and endpoint origins are recorded. Other instrumentors and application spans have their own privacy settings.
- Preserve
OTEL_INSTRUMENTATION_A2A_SDK_ENABLED=truewhen using the adapter. If native tracing is disabled, installation raises an error rather than reporting success without instrumenting clients. - Configure tracing once at startup. To restore the original SDK methods, call
A2AInstrumentor().uninstrument()after active requests and streams finish. - A bare
breakdoes not close an async iterator. Useaclosingto finish the span deterministically.
See the A2A Python SDK and the complete example.
Metadata
Release files for traceAI-a2a 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| traceai_a2a-0.1.1.tar.gz | 12.4 kB | With provenance | Details for traceai_a2a-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| traceai_a2a-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for traceai_a2a-0.1.1-py3-none-any.whl |
Total release size: 25.3 kB
Release files / traceai_a2a-0.1.1.tar.gz
| Download URL | traceai_a2a-0.1.1.tar.gz |
|---|---|
| Size | 12.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
947cc23c2cf2c96ae3ffecc76beb496881ae9e07a0b570def971323852363904
|
|
BLAKE2b-256 checksum How to use checksums |
8c0bc139c1d83b888213d8c491dc8b872cf09af31d417de1761833d79aeaf131
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 1, 2026.
Transparency logRelease files / traceai_a2a-0.1.1-py3-none-any.whl
| Download URL | traceai_a2a-0.1.1-py3-none-any.whl |
|---|---|
| Size | 12.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2c51882bdc60ebbd778eb43c35b2bc847d18a092f76ed466308e5d6295c7972f
|
|
BLAKE2b-256 checksum How to use checksums |
f380d4987c09eeec2bfe71a429859e5435cc9f0103d92b9e4a20b5e22aff4b8e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 1, 2026.
Transparency logSecurity for traceAI-a2a 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for traceai_a2a-0.1.1.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 1, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.