Documentation

Connect your agent

Google ADK, in every place you are likely to run it.

What you are configuring

Two standard OpenTelemetry environment variables. They are not TraptureIQ settings. They are the OTLP exporter's own configuration, which ADK already honours:

VariableValue
OTEL_EXPORTER_OTLP_TRACES_ENDPOINThttps://api.traptureiq.com/v1/traces
OTEL_EXPORTER_OTLP_HEADERSX-API-Key=tiq_your_key_here

Plus , which google-adk does not bundle.

Running locally

You do not have to deploy anything to see what an agent costs. An agent on your laptop reports exactly like one on Cloud Run: same variables, same payloads, same dashboards. Cost per model, thinking-token share, per-sub-agent spend and the full latency waterfall are all available while you are still iterating, which is the point at which a prompt change or a model swap is still cheap to make.

1

Install the OTLP exporter

Terminal
pip install opentelemetry-exporter-otlp-proto-http
2

Set the environment variables with export

In the terminal you will run the agent from. Replace tiq_your_key_here with your API key and my-agent with your agent's name.

Local (adk web)
export OTEL_EXPORTER_OTLP_TRACES_ENDPOINT="https://api.traptureiq.com/v1/traces"
export OTEL_EXPORTER_OTLP_LOGS_ENDPOINT="https://api.traptureiq.com/v1/logs"
export OTEL_EXPORTER_OTLP_HEADERS="X-API-Key=tiq_your_key_here"
export OTEL_SERVICE_NAME="my-agent"
export OTEL_RESOURCE_ATTRIBUTES="deployment.environment=local"
3

Run adk web in the same terminal

Terminal
adk web .

Ask the agent something and allow 10–30 seconds. Spans leave on the OpenTelemetry batch processor's schedule, not the moment the agent replies. shortens that while you experiment; leave it out in production.

Use export, not a .env file

adk web reads these variables once, at startup, from the terminal. Your agent's .env is only loaded later, on the agent's first request, which is too late: nothing is exported and the dashboard stays empty. Exports last for that terminal session, so paste them again in a new terminal. (A .env is the right place for the deploy targets below.)

Supported ADK versions, and adk web, not adk run

Tested on every ADK 2.x release and on 1.39.1 (). Older 1.x releases send cost data but not the agent structure, so agent attribution and topology stay empty. adk run never initialises OpenTelemetry in any version, so your agent answers normally and nothing is exported. Use adk web or adk api_server.

Because the runs are tagged deployment.environment=local, they stay separable from production everywhere. The Cost dashboard can show development spend on its own, or exclude it. Without that variable both sum into a single number, which is how an agent budget stops being explainable.

Deploying with adk deploy

ADK has three deploy targets, and each takes environment variables differently. This is where connecting usually goes wrong: the deploy succeeds, the agent runs, and nothing arrives because the variables never reached the runtime.

TargetSupportedHow to pass env vars
cloud_runVerified--env KEY=VALUE on ADK ≥ 2.9; gcloud --set-env-vars after a -- separator on 2.8 and older. Not a .env file
gkeVerifiedNo flag and no passthrough. Use kubectl set env on the Deployment afterwards
agent_engineVerifiedA .env in the agent folder (requires ADK ≥ 2.11.0)

Agent Engine

Requires Google ADK 2.11.0 or newerAgent Engine is verified end to end on ADK 2.11.0, and that is the minimum we support. Check with adk --version, upgrade with pip install -U google-adk, then deploy. adk deploy agent_engine builds a container that runs adk api_server, the same entrypoint Cloud Run uses, so the standard OTLP variables are honoured. On 2.1.x and older the deploy produced a different kind of app that ignored them entirely; if you cannot upgrade from one of those, Troubleshooting has a workaround. Versions 2.2 to 2.10 read the variables the same way 2.11 does, but they are not verified or supported on Agent Engine: upgrade before troubleshooting anything else.

There is nothing Agent Engine specific to write. Put a .env and a requirements.txt next to agent.py and deploy. Both agent.py and __init__.py stay exactly as they are.

# my_agent/.env: picked up automatically at deploy time
GOOGLE_GENAI_USE_VERTEXAI=1
OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=https://api.traptureiq.com/v1/traces
OTEL_EXPORTER_OTLP_HEADERS=X-API-Key=tiq_your_key_here
OTEL_SERVICE_NAME=my-agent
Deprecated flags you may still see in older guides--adk_app, --adk_app_object, --env_file, --requirements_file and --staging_bucket are all deprecated as of ADK 2.6 and no longer needed. The .env and requirements.txt inside the agent folder are read automatically.

Cloud Run

How the variables get to Cloud Run depends on your ADK version (adk --version). From 2.9.0, adk deploy cloud_run has its own --env flag. On 2.8 and older there is none, so they go to gcloud run deploy after a -- separator.

adk deploy cloud_run \
  --project=$PROJECT_ID \
  --region=$LOCATION_ID \
  --service_name="my-first-agent" \
  --env "OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=https://api.traptureiq.com/v1/traces" \
  --env "OTEL_EXPORTER_OTLP_LOGS_ENDPOINT=https://api.traptureiq.com/v1/logs" \
  --env "OTEL_EXPORTER_OTLP_HEADERS=X-API-Key=tiq_your_key_here" \
  --env "OTEL_SERVICE_NAME=my-first-agent" \
  --env "OTEL_RESOURCE_ATTRIBUTES=deployment.environment=production" \
  my_first_agent
A .env file does not work on Cloud Run

adk deploy cloud_run copies the agent folder into the image but does not turn its .env into environment variables (2.9+ reads it only for the project and region). The agent then loads it at runtime, after telemetry is already set up, so the deploy succeeds, the agent answers, and nothing arrives. Use the commands above.

Using a global-only Gemini model? Set the location back

The deploy sets GOOGLE_CLOUD_LOCATION to your --region. Models served only on the global endpoint (for example gemini-3.5-flash) then fail every call with a 404. Add --env GOOGLE_CLOUD_LOCATION=global (2.9+), or ##GOOGLE_CLOUD_LOCATION=global inside --set-env-vars (2.8 and older).

Two more things that catch people
  • On 2.9+, the old -- --set-env-vars form fails: ADK already passes --update-env-vars, and gcloud accepts only one of the two.
  • --env values are joined with commas, with no escape. A value containing a comma (two OTLP headers, several resource attributes) is split apart. Keep such values to one entry, or set them afterwards with gcloud run services update --update-env-vars.
  • With --artifact_service_uri=gs://…, add google-cloud-storage to the agent's requirements.txt, or the container exits at startup.

GKE

adk deploy gke has neither an env flag nor a gcloud passthrough. The Deployment it generates has no env: block at all, so the variables go on afterwards with kubectl set env, which rolls the pods automatically:

adk deploy gke \
  --project=$PROJECT_ID \
  --region=$LOCATION_ID \
  --cluster_name=$CLUSTER_NAME \
  --service_name=my-first-agent \
  --app_name=my_first_agent \
  --with_ui \
  my_first_agent

kubectl set env deployment/my-first-agent \
  OTEL_EXPORTER_OTLP_TRACES_ENDPOINT="https://api.traptureiq.com/v1/traces" \
  OTEL_EXPORTER_OTLP_HEADERS="X-API-Key=tiq_your_key_here" \
  OTEL_SERVICE_NAME=my-first-agent \
  OTEL_RESOURCE_ATTRIBUTES=deployment.environment=production
No ^##^ escaping here

Unlike gcloud run deploy --set-env-vars, kubectl set env splits arguments on whitespace, not commas. A header value containing a comma needs no special form. Quote it and it arrives intact.

adk deploy gke expects a regional cluster

The single --region value is used twice: it becomes GOOGLE_CLOUD_LOCATION inside the image and it is passed to gcloud container clusters get-credentials --region. Against a zonal cluster one of the two is always wrong. Pass a zone and the image gets an invalid Vertex AI location.

Agent Engine: a .env in the agent folder

For agent_engine only, adk deploy reads the .env next to agent.py and passes its values to the deployed runtime (ADK ≥ 2.11.0). Cloud Run does not; see above.

Keep the key out of shared imagesA .env with your API key travels with the deployment. Fine for a personal test; for anything shared, keep the key in Secret Manager.
--trace_to_cloud and --otel_to_cloud are not thisThose flags export to Google Cloud Trace. They are unrelated to TraptureIQ and independent of it: enabling them sends nothing here, and leaving them off does not stop TraptureIQ working. The two exporters are configured separately, and you can run both at once.

Docker and other runtimes

docker run \
  -e OTEL_EXPORTER_OTLP_TRACES_ENDPOINT="https://api.traptureiq.com/v1/traces" \
  -e OTEL_EXPORTER_OTLP_HEADERS="X-API-Key=tiq_your_key_here" \
  my-agent

Capturing prompts and responses

Token counts and cost arrive without this. The prompt and response bodies, what fills the request/response panes in Observability, are a separate opt-in:

.env or environment variable
ADK_CAPTURE_MESSAGE_CONTENT_IN_SPANS=true
Every adk deploy turns this off unless you set itRunning locally the ADK default is true. But adk deploy writes false into the deployed environment whenever the variable is absent, so an agent that showed prompt bodies on your machine will stop showing them once deployed, with nothing in the logs to say why. Set it explicitly in .env if you want it.

Think about it before switching it on anywhere real: it means user prompts and model replies are stored in TraptureIQ, which may include personal data. Cost and traces work perfectly well without it.

Naming your agents

The agent name in the console comes from the span. There is nothing to register. Send a new name and it appears as a new agent. That also means a typo creates a second agent, so keep names stable once you have picked them. If OTEL_SERVICE_NAME is not set, the root agent's name is used instead.

Grouping calls into sessions

ADK sets a session id per conversation, which is what powers User journeys and Observability → Sessions. If you want spend attributed to an end user as well, set a user id on the ADK session. From ADK 2.1 that id travels only on log records, and only with log content capture on; see No per-user breakdown.

Send to a shared team tenant

By default an API key writes into its owner's tenant. To have an agent write into a shared team workspace instead, add the tenant id header:

.env or environment variable
OTEL_EXPORTER_OTLP_HEADERS="X-API-Key=tiq_your_key_here,X-Tenant-Id=<tenant-id>"

The tenant id is on Tenant picker → Manage tenants. Only tenants the key's owner belongs to are accepted.

Confirm it workedRun one prompt through the agent, then open Observability → Traces. A row should appear within 10–30 seconds, with tokens and a non-zero cost. If it does not, Troubleshooting covers the three usual causes.