chore: Add agent engine telemetry

PiperOrigin-RevId: 765346182
This commit is contained in:
Shawn Yang
2025-05-30 14:49:14 -07:00
committed by Copybara-Service
parent 45ef668435
commit 3930a4b989
2 changed files with 39 additions and 0 deletions
+5
View File
@@ -18,6 +18,7 @@ from __future__ import annotations
import contextlib
from functools import cached_property
import logging
import os
import sys
from typing import AsyncGenerator
from typing import cast
@@ -40,6 +41,8 @@ logger = logging.getLogger('google_adk.' + __name__)
_NEW_LINE = '\n'
_EXCLUDED_PART_FIELD = {'inline_data': {'data'}}
_AGENT_ENGINE_TELEMETRY_TAG = 'remote_reasoning_engine'
_AGENT_ENGINE_TELEMETRY_ENV_VARIABLE_NAME = 'GOOGLE_CLOUD_AGENT_ENGINE_ID'
class Gemini(BaseLlm):
@@ -181,6 +184,8 @@ class Gemini(BaseLlm):
@cached_property
def _tracking_headers(self) -> dict[str, str]:
framework_label = f'google-adk/{version.__version__}'
if os.environ.get(_AGENT_ENGINE_TELEMETRY_ENV_VARIABLE_NAME):
framework_label = f'{framework_label}+{_AGENT_ENGINE_TELEMETRY_TAG}'
language_label = 'gl-python/' + sys.version.split()[0]
version_header_value = f'{framework_label} {language_label}'
tracking_headers = {