@google/adk 2.4.0 → 2.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/a2a/a2a_remote_agent.js +17 -2
- package/dist/cjs/a2a/a2a_remote_agent_utils.js +8 -4
- package/dist/cjs/a2a/agent_card.js +5 -81
- package/dist/cjs/a2a/agent_to_a2a.js +7 -0
- package/dist/cjs/a2a/event_converter_utils.js +10 -3
- package/dist/cjs/agents/agent_engine_client.js +282 -55
- package/dist/cjs/agents/base_agent.js +111 -68
- package/dist/cjs/agents/functions.js +62 -85
- package/dist/cjs/agents/instructions.js +7 -6
- package/dist/cjs/agents/invocation_context.js +2 -2
- package/dist/cjs/agents/llm_agent.js +105 -95
- package/dist/cjs/agents/processors/content_processor_utils.js +42 -15
- package/dist/cjs/agents/processors/content_request_processor.js +28 -11
- package/dist/cjs/agents/processors/context_compactor_request_processor.js +5 -1
- package/dist/cjs/agents/processors/instructions_llm_request_processor.js +1 -1
- package/dist/cjs/agents/processors/nl_planning_processor.js +2 -1
- package/dist/cjs/artifacts/file_artifact_service.js +1 -1
- package/dist/cjs/cli/cli_eval.js +884 -17
- package/dist/cjs/cli/utils/cleanup.js +84 -0
- package/dist/cjs/cli/utils/envs.js +33 -2
- package/dist/cjs/cli/utils/evals.js +75 -8
- package/dist/cjs/cli/utils/logs.js +128 -9
- package/dist/cjs/cli/utils/path_validation.js +83 -0
- package/dist/cjs/code_executors/container_code_executor.js +158 -36
- package/dist/cjs/common.js +50 -12
- package/dist/cjs/context/compaction_utils.js +19 -0
- package/dist/cjs/events/event.js +7 -3
- package/dist/cjs/features/feature_registry.js +5 -0
- package/dist/cjs/index.js +29 -14
- package/dist/cjs/models/google_llm.js +33 -2
- package/dist/cjs/models/interactions_utils.js +3 -0
- package/dist/cjs/plugins/base_plugin.js +45 -21
- package/dist/cjs/plugins/plugin_manager.js +27 -0
- package/dist/cjs/runner/runner.js +306 -189
- package/dist/cjs/sessions/base_session_service.js +1 -4
- package/dist/cjs/sessions/database_session_service.js +191 -19
- package/dist/cjs/sessions/db/operations.js +70 -1
- package/dist/cjs/sessions/db/schema.js +4 -0
- package/dist/cjs/sessions/in_memory_session_service.js +2 -2
- package/dist/cjs/sessions/vertex_ai_session_service.js +11 -3
- package/dist/cjs/skills/loader.js +29 -28
- package/dist/cjs/telemetry/api/instrumentation.js +632 -0
- package/dist/cjs/telemetry/api/internal/common/accumulators.js +169 -0
- package/dist/cjs/telemetry/api/internal/common/attributes.js +131 -0
- package/dist/cjs/telemetry/api/internal/common/config.js +159 -0
- package/dist/cjs/telemetry/api/internal/common/error.js +98 -0
- package/dist/cjs/telemetry/api/internal/common/finish_reason.js +63 -0
- package/dist/cjs/telemetry/api/internal/common/genai_messages.js +217 -0
- package/dist/cjs/telemetry/api/internal/common/http_exchange.js +169 -0
- package/dist/cjs/telemetry/api/internal/common/provider_name.js +87 -0
- package/dist/cjs/telemetry/api/internal/common/redaction.js +148 -0
- package/dist/cjs/telemetry/api/internal/common/serialization.js +58 -0
- package/dist/cjs/telemetry/api/internal/common/token_usage.js +118 -0
- package/dist/cjs/telemetry/api/internal/logs/inference.js +50 -0
- package/dist/cjs/telemetry/api/internal/logs/logger.js +46 -0
- package/dist/cjs/telemetry/api/internal/logs/mcp.js +141 -0
- package/dist/cjs/telemetry/api/internal/metrics/agent.js +128 -0
- package/dist/cjs/telemetry/api/internal/metrics/inference_start_hook.js +56 -0
- package/dist/cjs/telemetry/api/internal/metrics/meters.js +189 -0
- package/dist/cjs/telemetry/api/internal/metrics/tool.js +147 -0
- package/dist/cjs/telemetry/api/internal/metrics/workflow.js +132 -0
- package/dist/cjs/telemetry/api/internal/trace/agent.js +52 -0
- package/dist/cjs/telemetry/api/internal/trace/compaction.js +78 -0
- package/dist/cjs/telemetry/api/internal/trace/inference.js +132 -0
- package/dist/cjs/telemetry/api/internal/trace/live.js +52 -0
- package/dist/cjs/telemetry/api/internal/trace/node.js +73 -0
- package/dist/cjs/telemetry/api/internal/trace/propagation.js +67 -0
- package/dist/cjs/telemetry/api/internal/trace/tool.js +122 -0
- package/dist/cjs/telemetry/api/internal/trace/tracer.js +77 -0
- package/dist/cjs/telemetry/api/internal/trace/workflow.js +77 -0
- package/dist/cjs/telemetry/export/agent_engine.js +90 -0
- package/dist/cjs/telemetry/export/agent_runtime.js +73 -0
- package/dist/cjs/telemetry/export/google_cloud.js +763 -0
- package/dist/cjs/telemetry/export/request_driven_metric_reader.js +303 -0
- package/dist/cjs/telemetry/{setup.js → export/setup.js} +72 -5
- package/dist/cjs/tools/agent_tool.js +9 -1
- package/dist/cjs/tools/application_integration_tool/application_integration_toolset.js +22 -34
- package/dist/cjs/tools/application_integration_tool/clients/connections_client.js +60 -20
- package/dist/cjs/tools/application_integration_tool/clients/integration_client.js +26 -10
- package/dist/cjs/tools/application_integration_tool/integration_connector_tool.js +14 -23
- package/dist/cjs/tools/base_toolset.js +1 -1
- package/dist/cjs/tools/computer_use/base_computer.js +125 -0
- package/dist/cjs/tools/computer_use/computer_use_actions.js +502 -0
- package/dist/cjs/tools/computer_use/computer_use_tool.js +244 -0
- package/dist/cjs/tools/computer_use/computer_use_toolset.js +360 -0
- package/dist/cjs/tools/function_tool.js +15 -5
- package/dist/cjs/tools/google_api_tool/google_api_toolset.js +3 -2
- package/dist/cjs/tools/google_api_tool/googleapi_to_openapi_converter.js +3 -1
- package/dist/cjs/tools/load_artifacts_tool.js +15 -5
- package/dist/cjs/tools/load_memory_tool.js +2 -5
- package/dist/cjs/tools/mcp/mcp_session_manager.js +23 -3
- package/dist/cjs/tools/mcp/mcp_tool.js +7 -3
- package/dist/cjs/tools/mcp/mcp_toolset.js +18 -6
- package/dist/cjs/tools/openapi_tool/auth/auth_helpers.js +30 -29
- package/dist/cjs/tools/openapi_tool/auth/credential_exchangers/oauth2_exchanger.js +2 -2
- package/dist/cjs/tools/openapi_tool/rest_api_tool.js +45 -14
- package/dist/cjs/tools/skill/load_skill_resource_tool.js +7 -0
- package/dist/cjs/tools/skill/load_skill_tool.js +3 -0
- package/dist/cjs/tools/skill/run_skill_script_tool.js +12 -2
- package/dist/cjs/tools/toolbox_toolset.js +47 -28
- package/dist/cjs/utils/async_queue.js +37 -3
- package/dist/cjs/utils/client_labels.js +9 -11
- package/dist/cjs/utils/env_aware_utils.js +13 -7
- package/dist/cjs/utils/error_utils.js +40 -2
- package/dist/cjs/utils/failover_utils.js +10 -9
- package/dist/cjs/utils/gemini_schema_util.js +125 -12
- package/dist/cjs/utils/id_provider.js +63 -0
- package/dist/cjs/utils/model_name.js +15 -0
- package/dist/cjs/utils/simple_zod_to_json.js +13 -31
- package/dist/cjs/utils/ssrf_guard.js +46 -16
- package/dist/cjs/version.js +1 -1
- package/dist/cjs/workflow/index.js +2 -0
- package/dist/cjs/workflow/node_runner.js +24 -80
- package/dist/cjs/workflow/nodes/parallel_worker.js +18 -7
- package/dist/cjs/workflow/run_llm_agent_as_node.js +19 -14
- package/dist/cjs/workflow/utils/retry_utils.js +2 -2
- package/dist/cjs/workflow/workflow.js +12 -12
- package/dist/esm/a2a/a2a_remote_agent.js +23 -3
- package/dist/esm/a2a/a2a_remote_agent_utils.js +8 -4
- package/dist/esm/a2a/agent_card.js +5 -83
- package/dist/esm/a2a/agent_to_a2a.js +7 -0
- package/dist/esm/a2a/event_converter_utils.js +10 -3
- package/dist/esm/agents/agent_engine_client.js +293 -55
- package/dist/esm/agents/base_agent.js +111 -72
- package/dist/esm/agents/functions.js +67 -89
- package/dist/esm/agents/instructions.js +7 -6
- package/dist/esm/agents/invocation_context.js +2 -2
- package/dist/esm/agents/llm_agent.js +111 -100
- package/dist/esm/agents/processors/content_processor_utils.js +42 -15
- package/dist/esm/agents/processors/content_request_processor.js +28 -11
- package/dist/esm/agents/processors/context_compactor_request_processor.js +5 -1
- package/dist/esm/agents/processors/instructions_llm_request_processor.js +1 -1
- package/dist/esm/agents/processors/nl_planning_processor.js +2 -1
- package/dist/esm/artifacts/file_artifact_service.js +1 -1
- package/dist/esm/cli/cli_eval.js +880 -17
- package/dist/esm/cli/utils/cleanup.js +56 -0
- package/dist/esm/cli/utils/envs.js +33 -2
- package/dist/esm/cli/utils/evals.js +74 -8
- package/dist/esm/cli/utils/logs.js +128 -9
- package/dist/esm/cli/utils/path_validation.js +45 -0
- package/dist/esm/code_executors/container_code_executor.js +158 -36
- package/dist/esm/common.js +49 -6
- package/dist/esm/context/compaction_utils.js +19 -0
- package/dist/esm/events/event.js +7 -3
- package/dist/esm/features/feature_registry.js +5 -0
- package/dist/esm/index.js +27 -15
- package/dist/esm/models/google_llm.js +33 -2
- package/dist/esm/models/interactions_utils.js +3 -0
- package/dist/esm/plugins/base_plugin.js +45 -21
- package/dist/esm/plugins/plugin_manager.js +27 -0
- package/dist/esm/runner/runner.js +310 -192
- package/dist/esm/sessions/base_session_service.js +1 -4
- package/dist/esm/sessions/database_session_service.js +191 -19
- package/dist/esm/sessions/db/operations.js +70 -1
- package/dist/esm/sessions/db/schema.js +4 -0
- package/dist/esm/sessions/in_memory_session_service.js +2 -2
- package/dist/esm/sessions/vertex_ai_session_service.js +11 -3
- package/dist/esm/skills/loader.js +29 -28
- package/dist/esm/telemetry/api/instrumentation.js +655 -0
- package/dist/esm/telemetry/api/internal/common/accumulators.js +139 -0
- package/dist/esm/telemetry/api/internal/common/attributes.js +94 -0
- package/dist/esm/telemetry/api/internal/common/config.js +128 -0
- package/dist/esm/telemetry/api/internal/common/error.js +69 -0
- package/dist/esm/telemetry/api/internal/common/finish_reason.js +35 -0
- package/dist/esm/telemetry/api/internal/common/genai_messages.js +188 -0
- package/dist/esm/telemetry/api/internal/common/http_exchange.js +142 -0
- package/dist/esm/telemetry/api/internal/common/provider_name.js +59 -0
- package/dist/esm/telemetry/api/internal/common/redaction.js +121 -0
- package/dist/esm/telemetry/api/internal/common/serialization.js +30 -0
- package/dist/esm/telemetry/api/internal/common/token_usage.js +85 -0
- package/dist/esm/telemetry/api/internal/logs/inference.js +23 -0
- package/dist/esm/telemetry/api/internal/logs/logger.js +19 -0
- package/dist/esm/telemetry/api/internal/logs/mcp.js +113 -0
- package/dist/esm/telemetry/api/internal/metrics/agent.js +107 -0
- package/dist/esm/telemetry/api/internal/metrics/inference_start_hook.js +29 -0
- package/dist/esm/telemetry/api/internal/metrics/meters.js +165 -0
- package/dist/esm/telemetry/api/internal/metrics/tool.js +119 -0
- package/dist/esm/telemetry/api/internal/metrics/workflow.js +112 -0
- package/dist/esm/telemetry/api/internal/trace/agent.js +25 -0
- package/dist/esm/telemetry/api/internal/trace/compaction.js +50 -0
- package/dist/esm/telemetry/api/internal/trace/inference.js +107 -0
- package/dist/esm/telemetry/api/internal/trace/live.js +28 -0
- package/dist/esm/telemetry/api/internal/trace/node.js +44 -0
- package/dist/esm/telemetry/api/internal/trace/propagation.js +39 -0
- package/dist/esm/telemetry/api/internal/trace/tool.js +96 -0
- package/dist/esm/telemetry/api/internal/trace/tracer.js +52 -0
- package/dist/esm/telemetry/api/internal/trace/workflow.js +54 -0
- package/dist/esm/telemetry/export/agent_engine.js +67 -0
- package/dist/esm/telemetry/export/agent_runtime.js +46 -0
- package/dist/esm/telemetry/export/google_cloud.js +733 -0
- package/dist/esm/telemetry/export/request_driven_metric_reader.js +276 -0
- package/dist/esm/telemetry/export/setup.js +160 -0
- package/dist/esm/tools/agent_tool.js +9 -1
- package/dist/esm/tools/application_integration_tool/application_integration_toolset.js +23 -35
- package/dist/esm/tools/application_integration_tool/clients/connections_client.js +64 -21
- package/dist/esm/tools/application_integration_tool/clients/integration_client.js +26 -10
- package/dist/esm/tools/application_integration_tool/integration_connector_tool.js +14 -23
- package/dist/esm/tools/base_toolset.js +1 -1
- package/dist/esm/tools/computer_use/base_computer.js +99 -0
- package/dist/esm/tools/computer_use/computer_use_actions.js +477 -0
- package/dist/esm/tools/computer_use/computer_use_tool.js +217 -0
- package/dist/esm/tools/computer_use/computer_use_toolset.js +344 -0
- package/dist/esm/tools/function_tool.js +15 -5
- package/dist/esm/tools/google_api_tool/google_api_toolset.js +3 -2
- package/dist/esm/tools/google_api_tool/googleapi_to_openapi_converter.js +3 -1
- package/dist/esm/tools/load_artifacts_tool.js +15 -5
- package/dist/esm/tools/load_memory_tool.js +2 -5
- package/dist/esm/tools/mcp/mcp_session_manager.js +23 -3
- package/dist/esm/tools/mcp/mcp_tool.js +7 -3
- package/dist/esm/tools/mcp/mcp_toolset.js +18 -6
- package/dist/esm/tools/openapi_tool/auth/auth_helpers.js +27 -26
- package/dist/esm/tools/openapi_tool/auth/credential_exchangers/oauth2_exchanger.js +2 -2
- package/dist/esm/tools/openapi_tool/rest_api_tool.js +45 -14
- package/dist/esm/tools/skill/load_skill_resource_tool.js +7 -0
- package/dist/esm/tools/skill/load_skill_tool.js +3 -0
- package/dist/esm/tools/skill/run_skill_script_tool.js +12 -2
- package/dist/esm/tools/toolbox_toolset.js +47 -28
- package/dist/esm/utils/async_queue.js +37 -3
- package/dist/esm/utils/client_labels.js +9 -11
- package/dist/esm/utils/env_aware_utils.js +12 -7
- package/dist/esm/utils/error_utils.js +37 -1
- package/dist/esm/utils/failover_utils.js +10 -9
- package/dist/esm/utils/gemini_schema_util.js +124 -11
- package/dist/esm/utils/id_provider.js +33 -0
- package/dist/esm/utils/model_name.js +14 -0
- package/dist/esm/utils/simple_zod_to_json.js +13 -31
- package/dist/esm/utils/ssrf_guard.js +55 -15
- package/dist/esm/version.js +1 -1
- package/dist/esm/workflow/index.js +2 -1
- package/dist/esm/workflow/node_runner.js +26 -80
- package/dist/esm/workflow/nodes/parallel_worker.js +16 -6
- package/dist/esm/workflow/run_llm_agent_as_node.js +19 -14
- package/dist/esm/workflow/utils/retry_utils.js +2 -2
- package/dist/esm/workflow/workflow.js +12 -12
- package/dist/types/a2a/a2a_remote_agent.d.ts +6 -0
- package/dist/types/a2a/a2a_remote_agent_utils.d.ts +3 -2
- package/dist/types/agents/agent_engine_client.d.ts +121 -3
- package/dist/types/agents/base_agent.d.ts +2 -0
- package/dist/types/agents/processors/content_processor_utils.d.ts +9 -9
- package/dist/types/agents/run_config.d.ts +14 -0
- package/dist/types/cli/cli_eval.d.ts +172 -9
- package/dist/types/cli/utils/cleanup.d.ts +18 -0
- package/dist/types/cli/utils/envs.d.ts +13 -3
- package/dist/types/cli/utils/evals.d.ts +64 -1
- package/dist/types/cli/utils/logs.d.ts +19 -2
- package/dist/types/cli/utils/path_validation.d.ts +30 -0
- package/dist/types/code_executors/container_code_executor.d.ts +49 -8
- package/dist/types/common.d.ts +16 -9
- package/dist/types/context/compaction_utils.d.ts +13 -1
- package/dist/types/events/event.d.ts +3 -0
- package/dist/types/features/feature_registry.d.ts +1 -0
- package/dist/types/index.d.ts +9 -6
- package/dist/types/plugins/base_plugin.d.ts +50 -21
- package/dist/types/plugins/plugin_manager.d.ts +13 -0
- package/dist/types/runner/runner.d.ts +11 -0
- package/dist/types/sessions/base_session_service.d.ts +0 -2
- package/dist/types/sessions/db/operations.d.ts +2 -1
- package/dist/types/sessions/db/schema.d.ts +5 -3
- package/dist/types/telemetry/api/instrumentation.d.ts +259 -0
- package/dist/types/telemetry/api/internal/common/accumulators.d.ts +91 -0
- package/dist/types/telemetry/api/internal/common/attributes.d.ts +90 -0
- package/dist/types/telemetry/api/internal/common/config.d.ts +61 -0
- package/dist/types/telemetry/api/internal/common/error.d.ts +29 -0
- package/dist/types/telemetry/api/internal/common/finish_reason.d.ts +18 -0
- package/dist/types/telemetry/api/internal/common/genai_messages.d.ts +26 -0
- package/dist/types/telemetry/api/internal/common/http_exchange.d.ts +50 -0
- package/dist/types/telemetry/api/internal/common/provider_name.d.ts +16 -0
- package/dist/types/telemetry/api/internal/common/redaction.d.ts +14 -0
- package/dist/types/telemetry/api/internal/common/serialization.d.ts +18 -0
- package/dist/types/telemetry/api/internal/common/token_usage.d.ts +47 -0
- package/dist/types/telemetry/api/internal/logs/inference.d.ts +15 -0
- package/dist/types/telemetry/api/internal/logs/logger.d.ts +13 -0
- package/dist/types/telemetry/api/internal/logs/mcp.d.ts +31 -0
- package/dist/types/telemetry/api/internal/metrics/agent.d.ts +28 -0
- package/dist/types/telemetry/api/internal/metrics/inference_start_hook.d.ts +12 -0
- package/dist/types/telemetry/api/internal/metrics/meters.d.ts +57 -0
- package/dist/types/telemetry/api/internal/metrics/tool.d.ts +44 -0
- package/dist/types/telemetry/api/internal/metrics/workflow.d.ts +32 -0
- package/dist/types/telemetry/api/internal/trace/agent.d.ts +14 -0
- package/dist/types/telemetry/api/internal/trace/compaction.d.ts +20 -0
- package/dist/types/telemetry/api/internal/trace/inference.d.ts +31 -0
- package/dist/types/telemetry/api/internal/trace/live.d.ts +21 -0
- package/dist/types/telemetry/api/internal/trace/node.d.ts +22 -0
- package/dist/types/telemetry/api/internal/trace/propagation.d.ts +22 -0
- package/dist/types/telemetry/api/internal/trace/tool.d.ts +57 -0
- package/dist/types/telemetry/api/internal/trace/tracer.d.ts +31 -0
- package/dist/types/telemetry/api/internal/trace/workflow.d.ts +21 -0
- package/dist/types/telemetry/export/agent_engine.d.ts +23 -0
- package/dist/types/telemetry/export/agent_runtime.d.ts +40 -0
- package/dist/types/telemetry/export/google_cloud.d.ts +189 -0
- package/dist/types/telemetry/export/request_driven_metric_reader.d.ts +144 -0
- package/dist/types/telemetry/{setup.d.ts → export/setup.d.ts} +3 -0
- package/dist/types/tools/agent_tool.d.ts +1 -1
- package/dist/types/tools/application_integration_tool/clients/connections_client.d.ts +13 -4
- package/dist/types/tools/base_toolset.d.ts +1 -1
- package/dist/types/tools/computer_use/base_computer.d.ts +281 -0
- package/dist/types/tools/computer_use/computer_use_actions.d.ts +53 -0
- package/dist/types/tools/computer_use/computer_use_tool.d.ts +108 -0
- package/dist/types/tools/computer_use/computer_use_toolset.d.ts +132 -0
- package/dist/types/tools/google_api_tool/google_api_toolset.d.ts +2 -0
- package/dist/types/tools/load_artifacts_tool.d.ts +5 -1
- package/dist/types/tools/load_memory_tool.d.ts +13 -7
- package/dist/types/tools/mcp/mcp_session_manager.d.ts +16 -0
- package/dist/types/tools/openapi_tool/auth/auth_helpers.d.ts +8 -8
- package/dist/types/tools/openapi_tool/openapi_spec_parser/operation_parser.d.ts +7 -3
- package/dist/types/tools/toolbox_toolset.d.ts +15 -20
- package/dist/types/utils/async_queue.d.ts +14 -0
- package/dist/types/utils/env_aware_utils.d.ts +11 -0
- package/dist/types/utils/error_utils.d.ts +4 -0
- package/dist/types/utils/gemini_schema_util.d.ts +27 -6
- package/dist/types/utils/id_provider.d.ts +43 -0
- package/dist/types/utils/model_name.d.ts +8 -0
- package/dist/types/utils/ssrf_guard.d.ts +2 -0
- package/dist/types/version.d.ts +1 -1
- package/dist/types/workflow/index.d.ts +1 -1
- package/dist/types/workflow/nodes/parallel_worker.d.ts +8 -1
- package/dist/web/index_web.js +86 -88
- package/dist/web/index_web.js.map +4 -4
- package/package.json +13 -15
- package/dist/cjs/telemetry/google_cloud.js +0 -116
- package/dist/cjs/telemetry/tracing.js +0 -393
- package/dist/esm/telemetry/google_cloud.js +0 -99
- package/dist/esm/telemetry/setup.js +0 -88
- package/dist/esm/telemetry/tracing.js +0 -361
- package/dist/types/telemetry/google_cloud.d.ts +0 -9
- package/dist/types/telemetry/tracing.d.ts +0 -143
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import type { Attributes, Span } from '@opentelemetry/api';
|
|
7
|
+
import type { LlmRequest } from '../../../../models/llm_request.js';
|
|
8
|
+
import type { LlmResponse } from '../../../../models/llm_response.js';
|
|
9
|
+
import { type ResolvedTelemetryConfig } from '../common/config.js';
|
|
10
|
+
import { type OperationDetails } from '../common/genai_messages.js';
|
|
11
|
+
/** Parameters for {@link startInferenceSpan}. */
|
|
12
|
+
export interface StartInferenceSpanParams {
|
|
13
|
+
readonly llmRequest: LlmRequest;
|
|
14
|
+
/** Attributes the span shares with the call's log record. */
|
|
15
|
+
readonly commonAttributes: Attributes;
|
|
16
|
+
}
|
|
17
|
+
/** Starts a `generate_content {model}` span under the active context. */
|
|
18
|
+
export declare function startInferenceSpan({ llmRequest, commonAttributes, }: StartInferenceSpanParams): Span;
|
|
19
|
+
/**
|
|
20
|
+
* Builds the attributes one model response contributes to both the span and
|
|
21
|
+
* the log record: its finish reason and its token usage.
|
|
22
|
+
*/
|
|
23
|
+
export declare function buildResponseAttributes(llmResponse: LlmResponse): Attributes;
|
|
24
|
+
/** Records one model response on its `generate_content` span. */
|
|
25
|
+
export declare function setInferenceResponseAttributes(span: Span, llmResponse: LlmResponse, config: ResolvedTelemetryConfig): void;
|
|
26
|
+
/**
|
|
27
|
+
* Records the operation details of a model call on its span, as JSON: all of
|
|
28
|
+
* them when content capture includes spans, otherwise only the view without
|
|
29
|
+
* message content.
|
|
30
|
+
*/
|
|
31
|
+
export declare function setInferenceOperationDetails(span: Span, details: OperationDetails, config: ResolvedTelemetryConfig): void;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { Content } from '@google/genai';
|
|
7
|
+
import type { Span } from '@opentelemetry/api';
|
|
8
|
+
import type { InvocationContext } from '../../../../agents/invocation_context.js';
|
|
9
|
+
/** Parameters for recording live history `send_data` attributes on a span. */
|
|
10
|
+
export interface SetSendDataAttributesParams {
|
|
11
|
+
/** The invocation context for the current agent run. */
|
|
12
|
+
readonly invocationContext: InvocationContext;
|
|
13
|
+
/** The ID of the event. */
|
|
14
|
+
readonly eventId: string;
|
|
15
|
+
/** A list of content objects. */
|
|
16
|
+
readonly data: Content[];
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Sets `send_data` attributes on the given span.
|
|
20
|
+
*/
|
|
21
|
+
export declare function setSendDataAttributes(span: Span, { invocationContext, eventId, data }: SetSendDataAttributesParams): void;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import type { Span } from '@opentelemetry/api';
|
|
7
|
+
import type { BaseNode } from '../../../../workflow/base_node.js';
|
|
8
|
+
/**
|
|
9
|
+
* Whether a node is traced by a span of its own kind rather than by
|
|
10
|
+
* `invoke_node`: an agent opens `invoke_agent` and a workflow
|
|
11
|
+
* `invoke_workflow`.
|
|
12
|
+
*/
|
|
13
|
+
export declare function hasOwnInvocationSpan(node: BaseNode): boolean;
|
|
14
|
+
/** Parameters for {@link startNodeSpan}. */
|
|
15
|
+
export interface StartNodeSpanParams {
|
|
16
|
+
readonly nodeName: string;
|
|
17
|
+
readonly sessionId: string;
|
|
18
|
+
}
|
|
19
|
+
/** Starts an `invoke_node {nodeName}` span under the active context. */
|
|
20
|
+
export declare function startNodeSpan({ nodeName, sessionId, }: StartNodeSpanParams): Span;
|
|
21
|
+
/** Records the ids of the events a node emitted on its span, if it emitted any. */
|
|
22
|
+
export declare function setAssociatedEventIds(span: Span, eventIds: readonly string[]): void;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import type { TextMapGetter } from '@opentelemetry/api';
|
|
7
|
+
/** Incoming request headers, such as Node's `IncomingMessage.headers`. */
|
|
8
|
+
export type IncomingHeaders = Readonly<Record<string, string | string[] | undefined>>;
|
|
9
|
+
/**
|
|
10
|
+
* Reads incoming request headers for the propagator, matching names
|
|
11
|
+
* case-insensitively. An array value is returned as is; the W3C propagator
|
|
12
|
+
* reads its first element.
|
|
13
|
+
*/
|
|
14
|
+
export declare const INCOMING_HEADERS_GETTER: TextMapGetter<IncomingHeaders>;
|
|
15
|
+
/**
|
|
16
|
+
* Returns the headers a `fetch(input, init)` call sends, with each injected
|
|
17
|
+
* header added unless the call already sets it.
|
|
18
|
+
*
|
|
19
|
+
* As in `fetch`, `init.headers` replaces the headers of a `Request` input
|
|
20
|
+
* when given, and the `Request` headers are kept otherwise.
|
|
21
|
+
*/
|
|
22
|
+
export declare function addMissingHeaders(input: Parameters<typeof globalThis.fetch>[0], init: Parameters<typeof globalThis.fetch>[1], injected: Readonly<Record<string, string>>): Headers;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import type { Attributes, Span } from '@opentelemetry/api';
|
|
7
|
+
import type { Event } from '../../../../events/event.js';
|
|
8
|
+
import type { Skill } from '../../../../skills/skill.js';
|
|
9
|
+
import type { BaseTool } from '../../../../tools/base_tool.js';
|
|
10
|
+
import type { ResolvedTelemetryConfig } from '../common/config.js';
|
|
11
|
+
/** The outcome of one tool call, as recorded on its `execute_tool` span. */
|
|
12
|
+
export type ToolCallOutcome = {
|
|
13
|
+
readonly kind: 'response';
|
|
14
|
+
readonly functionResponseEvent?: Event;
|
|
15
|
+
/** An error type the tool reported in its response instead of throwing. */
|
|
16
|
+
readonly errorType?: string;
|
|
17
|
+
} | {
|
|
18
|
+
readonly kind: 'error';
|
|
19
|
+
readonly errorType: string;
|
|
20
|
+
};
|
|
21
|
+
/** Parameters for {@link buildToolCallAttributes}. */
|
|
22
|
+
export interface ToolCallAttributesParams {
|
|
23
|
+
readonly tool: BaseTool;
|
|
24
|
+
readonly args: Record<string, unknown>;
|
|
25
|
+
readonly agentName?: string;
|
|
26
|
+
readonly outcome: ToolCallOutcome;
|
|
27
|
+
readonly config: ResolvedTelemetryConfig;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Builds the attributes of an `execute_tool` span.
|
|
31
|
+
*
|
|
32
|
+
* The call arguments and result are message content, so they are recorded
|
|
33
|
+
* only when content capture includes spans, and the result has credential
|
|
34
|
+
* secrets removed.
|
|
35
|
+
*/
|
|
36
|
+
export declare function buildToolCallAttributes({ tool, args, agentName, outcome, config, }: ToolCallAttributesParams): Attributes;
|
|
37
|
+
/** Builds the attributes of an `execute_tool (merged)` span. */
|
|
38
|
+
export declare function buildMergedToolCallsAttributes(responseEventId: string): Attributes;
|
|
39
|
+
/** What a skill tool reported about the skill it worked on. */
|
|
40
|
+
export interface SkillReport {
|
|
41
|
+
/** The skill name the tool was asked for, which may not exist. */
|
|
42
|
+
readonly skillName: string;
|
|
43
|
+
/** The resource or script path, for a resource load or a script run. */
|
|
44
|
+
readonly resourceName?: string;
|
|
45
|
+
/** Whether the tool loaded the skill itself, as opposed to part of it. */
|
|
46
|
+
readonly isSkillLoad: boolean;
|
|
47
|
+
/** Whether the tool executed a skill script. */
|
|
48
|
+
readonly isSkillScript?: boolean;
|
|
49
|
+
/** The skill, once the tool has resolved it. */
|
|
50
|
+
readonly skill?: Skill;
|
|
51
|
+
}
|
|
52
|
+
/** Names an `execute_tool` span after the skill and resource it touched. */
|
|
53
|
+
export declare function buildSkillSpanName(toolName: string, report: SkillReport): string;
|
|
54
|
+
/** Builds the skill attributes of an `execute_tool` span. */
|
|
55
|
+
export declare function buildSkillAttributes(report: SkillReport): Attributes;
|
|
56
|
+
/** Records a skill on its `execute_tool` span: the span name and attributes. */
|
|
57
|
+
export declare function setSkillSpanAttributes(span: Span, toolName: string, report: SkillReport): void;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { type Context, type Span, type Tracer } from '@opentelemetry/api';
|
|
7
|
+
/**
|
|
8
|
+
* Returns the ADK tracer from the global `TracerProvider`.
|
|
9
|
+
*
|
|
10
|
+
* Resolved on every call rather than once at import, like the logger, so the
|
|
11
|
+
* tracer carries the schema URL whichever provider the application registers
|
|
12
|
+
* and whenever it registers it.
|
|
13
|
+
*/
|
|
14
|
+
export declare function getTracer(): Tracer;
|
|
15
|
+
/**
|
|
16
|
+
* Binds an async generator to OpenTelemetry context for trace propagation.
|
|
17
|
+
*
|
|
18
|
+
* @param ctx The OpenTelemetry context to bind the generator to.
|
|
19
|
+
* @param generator The async generator to be bound to the context.
|
|
20
|
+
* @returns A new async generator that executes all operations within the provided context.
|
|
21
|
+
*/
|
|
22
|
+
export declare function bindOtelContextToAsyncGenerator<T>(ctx: Context, generator: AsyncGenerator<T, void, void>): AsyncGenerator<T, void, void>;
|
|
23
|
+
/**
|
|
24
|
+
* Records a failure on a span: the exception and an ERROR status.
|
|
25
|
+
*
|
|
26
|
+
* The status message is the error type rather than the error message, which
|
|
27
|
+
* can carry user data that the content capture setting does not gate. Only an
|
|
28
|
+
* `Error` instance is recorded as an exception; any other thrown value is
|
|
29
|
+
* recorded by its type alone.
|
|
30
|
+
*/
|
|
31
|
+
export declare function setSpanError(span: Span, error: unknown): void;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { type Context, type Span } from '@opentelemetry/api';
|
|
7
|
+
/** Parameters for {@link startWorkflowSpan}. */
|
|
8
|
+
export interface StartWorkflowSpanParams {
|
|
9
|
+
readonly workflowName: string;
|
|
10
|
+
readonly sessionId: string;
|
|
11
|
+
readonly nested: boolean;
|
|
12
|
+
readonly parentContext?: Context;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Starts an `invoke_workflow {workflowName}` span.
|
|
16
|
+
*
|
|
17
|
+
* A workflow started inside another workflow is marked
|
|
18
|
+
* `gen_ai.workflow.nested`; the outermost one carries no such attribute. The
|
|
19
|
+
* top span of a trace also carries `supportID` when the request supplied one.
|
|
20
|
+
*/
|
|
21
|
+
export declare function startWorkflowSpan({ workflowName, sessionId, nested, parentContext, }: StartWorkflowSpanParams): Span;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Runs `fn` in a context that continues an Agent Engine request trace.
|
|
8
|
+
*
|
|
9
|
+
* When `Google-Agent-Engine-Traceparent` holds a valid W3C traceparent and no
|
|
10
|
+
* span is active, the Agent Engine span becomes the remote parent of the
|
|
11
|
+
* spans `fn` starts. An invalid value is ignored. The `traceparent` header is
|
|
12
|
+
* recorded as the `supportID` attribute of the invocation's top span.
|
|
13
|
+
*
|
|
14
|
+
* Without either header, `fn` runs in the active context unchanged.
|
|
15
|
+
*
|
|
16
|
+
* @experimental (Experimental, subject to change)
|
|
17
|
+
*
|
|
18
|
+
* @param headers The incoming request headers, such as Node's
|
|
19
|
+
* `IncomingMessage.headers`.
|
|
20
|
+
* @param fn The request handler to run.
|
|
21
|
+
* @returns What `fn` returns.
|
|
22
|
+
*/
|
|
23
|
+
export declare function runWithAgentEngineContext<T>(headers: Readonly<Record<string, string | string[] | undefined>>, fn: () => T): T;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import type { OTelHooks } from './setup.js';
|
|
7
|
+
/**
|
|
8
|
+
* Hooks a server calls at the start and end of every request, so telemetry is
|
|
9
|
+
* exported while the request still holds the CPU.
|
|
10
|
+
*
|
|
11
|
+
* Neither hook throws, and {@link AgentRuntimeRequestHooks.onRequestEnd}
|
|
12
|
+
* never rejects: a telemetry failure never breaks the request.
|
|
13
|
+
*
|
|
14
|
+
* @experimental (Experimental, subject to change)
|
|
15
|
+
*/
|
|
16
|
+
export interface AgentRuntimeRequestHooks {
|
|
17
|
+
/** Call when a request arrives. */
|
|
18
|
+
onRequestStart(): void;
|
|
19
|
+
/**
|
|
20
|
+
* Call when the handler ends the response, before the response completes.
|
|
21
|
+
* Resolves once metrics are drained and spans and logs are flushed.
|
|
22
|
+
*/
|
|
23
|
+
onRequestEnd(): Promise<void>;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Builds the request hooks that drive export for the given processors and
|
|
27
|
+
* readers on a runtime that throttles the CPU between requests.
|
|
28
|
+
*
|
|
29
|
+
* Each request start and end drives every request-driven metric reader in
|
|
30
|
+
* `otelHooks.metricReaders`. Each request end also force-flushes every span and
|
|
31
|
+
* log record processor in `otelHooks`. Other metric readers are left alone:
|
|
32
|
+
* flushing them would collect outside the request-driven reader's spacing
|
|
33
|
+
* rules.
|
|
34
|
+
*
|
|
35
|
+
* @experimental (Experimental, subject to change)
|
|
36
|
+
*
|
|
37
|
+
* @param otelHooks The processors and readers to drive, usually the result of
|
|
38
|
+
* {@link getGcpExporters}.
|
|
39
|
+
*/
|
|
40
|
+
export declare function agentRuntimeRequestHooks(otelHooks: OTelHooks): AgentRuntimeRequestHooks;
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { Resource } from '@opentelemetry/resources';
|
|
7
|
+
import { BatchLogRecordProcessor, BatchLogRecordProcessorOptions, LogRecordExporter, ReadWriteLogRecord } from '@opentelemetry/sdk-logs';
|
|
8
|
+
import { AggregationTemporality, InstrumentType, PushMetricExporter, ResourceMetrics } from '@opentelemetry/sdk-metrics';
|
|
9
|
+
import { ReadableSpan, SpanExporter } from '@opentelemetry/sdk-trace-base';
|
|
10
|
+
import { GoogleAuth } from 'google-auth-library';
|
|
11
|
+
import { agentRuntimeRequestHooks, type AgentRuntimeRequestHooks } from './agent_runtime.js';
|
|
12
|
+
import { OtelExportersConfig, OTelHooks } from './setup.js';
|
|
13
|
+
export { agentRuntimeRequestHooks, type AgentRuntimeRequestHooks };
|
|
14
|
+
/**
|
|
15
|
+
* Resolved project identifiers from the Cloud Resource Manager API.
|
|
16
|
+
*/
|
|
17
|
+
export interface ProjectInfo {
|
|
18
|
+
readonly id: string;
|
|
19
|
+
readonly number: string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Clears the cached project identifiers.
|
|
23
|
+
*/
|
|
24
|
+
export declare function clearProjectCache(): void;
|
|
25
|
+
/**
|
|
26
|
+
* Selects standard or mTLS endpoint based on environment settings.
|
|
27
|
+
*/
|
|
28
|
+
export declare function getTelemetryEndpoint(defaultEndpoint: string, mtlsEndpoint: string): string;
|
|
29
|
+
/**
|
|
30
|
+
* Returns the Vertex Agent Engine User-Agent header when telemetry is enabled.
|
|
31
|
+
*/
|
|
32
|
+
export declare function getAgentEngineUserAgentHeader(): Record<string, string>;
|
|
33
|
+
/**
|
|
34
|
+
* Authenticated OTLP trace exporter wrapper sending spans to Google Cloud.
|
|
35
|
+
*/
|
|
36
|
+
export declare class AuthenticatedTraceExporter implements SpanExporter {
|
|
37
|
+
private readonly auth;
|
|
38
|
+
private readonly endpoint;
|
|
39
|
+
private readonly userAgentHeaders;
|
|
40
|
+
private readonly delegate;
|
|
41
|
+
private currentHeaders;
|
|
42
|
+
private warnedAuthFailure;
|
|
43
|
+
constructor(auth: GoogleAuth, endpoint: string, userAgentHeaders?: Record<string, string>);
|
|
44
|
+
/**
|
|
45
|
+
* Exports spans to Google Cloud.
|
|
46
|
+
*
|
|
47
|
+
* @param spans Spans to export.
|
|
48
|
+
* @param resultCallback Callback called with the export result.
|
|
49
|
+
*/
|
|
50
|
+
export(spans: ReadableSpan[], resultCallback: (result: {
|
|
51
|
+
code: number;
|
|
52
|
+
error?: Error;
|
|
53
|
+
}) => void): void;
|
|
54
|
+
private exportAsync;
|
|
55
|
+
/**
|
|
56
|
+
* Shuts down the trace exporter.
|
|
57
|
+
*/
|
|
58
|
+
shutdown(): Promise<void>;
|
|
59
|
+
/**
|
|
60
|
+
* Flushes pending traces.
|
|
61
|
+
*/
|
|
62
|
+
forceFlush(): Promise<void>;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Authenticated OTLP metric exporter wrapper sending metrics to Google Cloud.
|
|
66
|
+
*/
|
|
67
|
+
export declare class AuthenticatedMetricExporter implements PushMetricExporter {
|
|
68
|
+
private readonly auth;
|
|
69
|
+
private readonly endpoint;
|
|
70
|
+
private readonly userAgentHeaders;
|
|
71
|
+
private readonly delegate;
|
|
72
|
+
private currentHeaders;
|
|
73
|
+
private warnedAuthFailure;
|
|
74
|
+
constructor(auth: GoogleAuth, endpoint: string, userAgentHeaders?: Record<string, string>);
|
|
75
|
+
/**
|
|
76
|
+
* Exports metrics to Google Cloud.
|
|
77
|
+
*
|
|
78
|
+
* @param metrics Metrics to export.
|
|
79
|
+
* @param resultCallback Callback called with the export result.
|
|
80
|
+
*/
|
|
81
|
+
export(metrics: ResourceMetrics, resultCallback: (result: {
|
|
82
|
+
code: number;
|
|
83
|
+
error?: Error;
|
|
84
|
+
}) => void): void;
|
|
85
|
+
private exportAsync;
|
|
86
|
+
/**
|
|
87
|
+
* Shuts down the metric exporter.
|
|
88
|
+
*/
|
|
89
|
+
shutdown(): Promise<void>;
|
|
90
|
+
/**
|
|
91
|
+
* Flushes pending metrics.
|
|
92
|
+
*/
|
|
93
|
+
forceFlush(): Promise<void>;
|
|
94
|
+
/**
|
|
95
|
+
* Selects aggregation temporality for instrument type.
|
|
96
|
+
*
|
|
97
|
+
* @param instrumentType Instrument type.
|
|
98
|
+
*/
|
|
99
|
+
selectAggregationTemporality(instrumentType: InstrumentType): AggregationTemporality;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Authenticated OTLP log exporter wrapper sending logs to Google Cloud.
|
|
103
|
+
*/
|
|
104
|
+
export declare class AuthenticatedLogExporter implements LogRecordExporter {
|
|
105
|
+
private readonly auth;
|
|
106
|
+
private readonly endpoint;
|
|
107
|
+
private readonly userAgentHeaders;
|
|
108
|
+
private readonly delegate;
|
|
109
|
+
private currentHeaders;
|
|
110
|
+
private warnedAuthFailure;
|
|
111
|
+
constructor(auth: GoogleAuth, endpoint: string, userAgentHeaders?: Record<string, string>);
|
|
112
|
+
/**
|
|
113
|
+
* Exports log records to Google Cloud.
|
|
114
|
+
*
|
|
115
|
+
* @param logs Log records to export.
|
|
116
|
+
* @param resultCallback Callback called with the export result.
|
|
117
|
+
*/
|
|
118
|
+
export(logs: ReadWriteLogRecord[], resultCallback: (result: {
|
|
119
|
+
code: number;
|
|
120
|
+
error?: Error;
|
|
121
|
+
}) => void): void;
|
|
122
|
+
private exportAsync;
|
|
123
|
+
/**
|
|
124
|
+
* Shuts down the log exporter.
|
|
125
|
+
*/
|
|
126
|
+
shutdown(): Promise<void>;
|
|
127
|
+
/**
|
|
128
|
+
* Flushes pending log records.
|
|
129
|
+
*/
|
|
130
|
+
forceFlush(): Promise<void>;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Options for configuring {@link GCPBatchLogRecordProcessor}.
|
|
134
|
+
*/
|
|
135
|
+
export interface GCPBatchLogRecordProcessorOptions extends Partial<BatchLogRecordProcessorOptions> {
|
|
136
|
+
readonly exporter: LogRecordExporter;
|
|
137
|
+
readonly projectId?: string;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Batching log processor keeping Cloud Logging log names and labels stable.
|
|
141
|
+
*/
|
|
142
|
+
export declare class GCPBatchLogRecordProcessor extends BatchLogRecordProcessor {
|
|
143
|
+
private readonly defaultLogName;
|
|
144
|
+
private readonly logResource;
|
|
145
|
+
constructor(exporterOrOptions: LogRecordExporter | GCPBatchLogRecordProcessorOptions, projectId?: string);
|
|
146
|
+
onEmit(logRecord: ReadWriteLogRecord): void;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Looks up project number and ID via Cloud Resource Manager API with in-memory caching.
|
|
150
|
+
*
|
|
151
|
+
* Successful lookups require the `resourcemanager.projects.get` permission.
|
|
152
|
+
*
|
|
153
|
+
* @param project The project ID or number to query.
|
|
154
|
+
* @param auth Optional GoogleAuth instance to use.
|
|
155
|
+
* @returns Resolved project identifiers, or empty strings if resolution fails.
|
|
156
|
+
*/
|
|
157
|
+
export declare function fetchProject(project?: string, auth?: GoogleAuth): Promise<ProjectInfo>;
|
|
158
|
+
/**
|
|
159
|
+
* Resolves the GCP project ID from parameter, environment, or Application Default Credentials.
|
|
160
|
+
*
|
|
161
|
+
* @param auth Optional GoogleAuth instance to use for resolution.
|
|
162
|
+
* @returns The resolved project ID, or undefined if it cannot be determined.
|
|
163
|
+
*/
|
|
164
|
+
export declare function getGcpProjectId(auth?: GoogleAuth): Promise<string | undefined>;
|
|
165
|
+
/**
|
|
166
|
+
* Builds the OTel resource describing a Google Cloud deployment.
|
|
167
|
+
*
|
|
168
|
+
* Applies layered precedence: common resource, Agent Runtime resource,
|
|
169
|
+
* OTel environment detector, GCP detector, and Agent Registry URN enrichment.
|
|
170
|
+
*
|
|
171
|
+
* @param projectId Optional project ID. Falls back to GOOGLE_CLOUD_PROJECT or ADC.
|
|
172
|
+
* @returns Detected Resource object.
|
|
173
|
+
*/
|
|
174
|
+
export declare function getGcpResource(projectId?: string): Promise<Resource>;
|
|
175
|
+
/**
|
|
176
|
+
* Returns OTel processors and readers configured for export to Google Cloud.
|
|
177
|
+
*
|
|
178
|
+
* Sends traces, metrics, and logs via OTLP over HTTP to telemetry.googleapis.com.
|
|
179
|
+
* On Agent Runtime (`GOOGLE_CLOUD_AGENT_ENGINE_ID` set) the metric reader is
|
|
180
|
+
* request-driven and starts no background timer. Custom servers calling
|
|
181
|
+
* `getGcpExporters` with {@link maybeSetOtelProviders} on Agent Runtime must
|
|
182
|
+
* wrap each request with {@link agentRuntimeRequestHooks} to drive the metric
|
|
183
|
+
* reader and flush the span and log processors; without those hooks, the reader
|
|
184
|
+
* never collects except on `forceFlush()` or `shutdown()`.
|
|
185
|
+
*
|
|
186
|
+
* @param config Configuration options for enabled signals and project.
|
|
187
|
+
* @returns OTelHooks containing configured processors and readers.
|
|
188
|
+
*/
|
|
189
|
+
export declare function getGcpExporters(config?: OtelExportersConfig): Promise<OTelHooks>;
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { MetricReader, type PushMetricExporter } from '@opentelemetry/sdk-metrics';
|
|
7
|
+
/**
|
|
8
|
+
* The minimum spacing, in milliseconds, between two metric exports to
|
|
9
|
+
* telemetry.googleapis.com.
|
|
10
|
+
*
|
|
11
|
+
* Every ADK metric reader that exports there stays at or above it: it is the
|
|
12
|
+
* default floor of {@link RequestDrivenMetricReader} and the export interval of
|
|
13
|
+
* the periodic reader. The backend tolerates slightly faster points to absorb
|
|
14
|
+
* drift, but that is not a supported rate.
|
|
15
|
+
*/
|
|
16
|
+
export declare const MIN_EXPORT_INTERVAL_MS = 5000;
|
|
17
|
+
declare const REQUEST_DRIVEN_METRIC_READER_SIGNATURE_SYMBOL: unique symbol;
|
|
18
|
+
/** Options for {@link RequestDrivenMetricReader}. */
|
|
19
|
+
export interface RequestDrivenMetricReaderOptions {
|
|
20
|
+
/** The exporter each collect is sent to. */
|
|
21
|
+
readonly exporter: PushMetricExporter;
|
|
22
|
+
/**
|
|
23
|
+
* The spacing of the guidepost grid, in milliseconds. Defaults to
|
|
24
|
+
* `OTEL_METRIC_EXPORT_INTERVAL`, or 60000.
|
|
25
|
+
*/
|
|
26
|
+
readonly exportIntervalMillis?: number;
|
|
27
|
+
/**
|
|
28
|
+
* The timeout of one collect and one export, in milliseconds. Defaults to
|
|
29
|
+
* `OTEL_METRIC_EXPORT_TIMEOUT`, or 30000.
|
|
30
|
+
*/
|
|
31
|
+
readonly exportTimeoutMillis?: number;
|
|
32
|
+
/**
|
|
33
|
+
* The minimum spacing between two collects, in milliseconds. Defaults to
|
|
34
|
+
* `GOOGLE_CLOUD_AGENT_ENGINE_METRICS_COLLECTION_INTERVAL_FLOOR_MS`, or
|
|
35
|
+
* `MIN_EXPORT_INTERVAL_MS`.
|
|
36
|
+
*/
|
|
37
|
+
readonly floorMillis?: number;
|
|
38
|
+
/** A monotonic millisecond clock. Defaults to `performance.now`. */
|
|
39
|
+
readonly now?: () => number;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Returns whether `obj` is a {@link RequestDrivenMetricReader}, including one
|
|
43
|
+
* from another copy of this package.
|
|
44
|
+
*/
|
|
45
|
+
export declare function isRequestDrivenMetricReader(obj: unknown): obj is RequestDrivenMetricReader;
|
|
46
|
+
/**
|
|
47
|
+
* A metric reader that collects and exports only from the request path, with
|
|
48
|
+
* no background timer.
|
|
49
|
+
*
|
|
50
|
+
* On a runtime that bills per request, such as Agent Runtime, the CPU is
|
|
51
|
+
* throttled as soon as a request ends. A periodic reader's timer gets no CPU
|
|
52
|
+
* between requests, so its exports are delayed or dropped. This reader keeps
|
|
53
|
+
* three invariants instead:
|
|
54
|
+
*
|
|
55
|
+
* - I1, export only while serving: every collect runs while a request is in
|
|
56
|
+
* flight, the only time the CPU is guaranteed.
|
|
57
|
+
* - I2, a floor: two collects are never closer than `floorMillis`.
|
|
58
|
+
* - I3, a guidepost: the export period is a grid of hint times, not a
|
|
59
|
+
* schedule. Under sustained load a passed guidepost forces a collect, so
|
|
60
|
+
* points cannot pile up.
|
|
61
|
+
*
|
|
62
|
+
* Collects are triggered by:
|
|
63
|
+
*
|
|
64
|
+
* - {@link onRequestEnd}, when the last request in flight ends and the floor
|
|
65
|
+
* allows it (the drain).
|
|
66
|
+
* - {@link onRequestStart}, when the request overlaps another one and a
|
|
67
|
+
* guidepost has passed. A guidepost that lands within the floor of the last
|
|
68
|
+
* collect is muted, and the grid moves one period on.
|
|
69
|
+
* - The start of a model call, when 1.5 periods have passed since the later
|
|
70
|
+
* of the start of the busy period and the last collect. The model-call
|
|
71
|
+
* instrumentation calls this through a hook the reader installs when a
|
|
72
|
+
* `MeterProvider` registers it. Because that hook uses a single
|
|
73
|
+
* process-global slot where the last registered reader wins, only a single
|
|
74
|
+
* active reader is supported.
|
|
75
|
+
*
|
|
76
|
+
* Residual loss case: a request shorter than the floor that ends right after
|
|
77
|
+
* a collect has its drain muted by the floor. If it is the last request
|
|
78
|
+
* before the process goes idle, no later collect comes and its points are
|
|
79
|
+
* lost.
|
|
80
|
+
*
|
|
81
|
+
* The defaults come from `OTEL_METRIC_EXPORT_INTERVAL` (60000),
|
|
82
|
+
* `OTEL_METRIC_EXPORT_TIMEOUT` (30000) and
|
|
83
|
+
* `GOOGLE_CLOUD_AGENT_ENGINE_METRICS_COLLECTION_INTERVAL_FLOOR_MS` (5000). An
|
|
84
|
+
* explicit option wins over its variable. A value that is not a valid number
|
|
85
|
+
* logs a warning and uses the default.
|
|
86
|
+
*
|
|
87
|
+
* None of the request methods throws or rejects.
|
|
88
|
+
*/
|
|
89
|
+
export declare class RequestDrivenMetricReader extends MetricReader {
|
|
90
|
+
readonly [REQUEST_DRIVEN_METRIC_READER_SIGNATURE_SYMBOL] = true;
|
|
91
|
+
private readonly exporter;
|
|
92
|
+
private readonly now;
|
|
93
|
+
private readonly periodMillis;
|
|
94
|
+
private readonly exportTimeoutMillis;
|
|
95
|
+
private readonly floorMillis;
|
|
96
|
+
private readonly inferenceStartHook;
|
|
97
|
+
private inFlight;
|
|
98
|
+
private lastCollect?;
|
|
99
|
+
/** When in-flight last went from zero to one. */
|
|
100
|
+
private busyStart?;
|
|
101
|
+
private nextDue;
|
|
102
|
+
/** The collect now running; set while one runs, so collects never overlap. */
|
|
103
|
+
private runningCollect?;
|
|
104
|
+
private isShutdown;
|
|
105
|
+
private warnedNoRequest;
|
|
106
|
+
constructor({ exporter, exportIntervalMillis, exportTimeoutMillis, floorMillis, now, }: RequestDrivenMetricReaderOptions);
|
|
107
|
+
/** Marks a request as started, and collects if a guidepost has passed. */
|
|
108
|
+
onRequestStart(): void;
|
|
109
|
+
/**
|
|
110
|
+
* Marks a request as ended. Collects when no request is left in flight and
|
|
111
|
+
* the floor allows it, and resolves once any running collect has exported.
|
|
112
|
+
*/
|
|
113
|
+
onRequestEnd(): Promise<void>;
|
|
114
|
+
/** Collects at a model-call start if the busy period is overdue. */
|
|
115
|
+
onInferenceStart(): void;
|
|
116
|
+
/**
|
|
117
|
+
* Registers the model-call start hook when a provider initializes this
|
|
118
|
+
* reader.
|
|
119
|
+
*
|
|
120
|
+
* Because the hook uses a single process-global slot where the last
|
|
121
|
+
* registered reader wins, only a single active reader is supported.
|
|
122
|
+
*/
|
|
123
|
+
protected onInitialized(): void;
|
|
124
|
+
/** Shuts down the reader, exports remaining metrics, and cleans up hooks. */
|
|
125
|
+
protected onShutdown(): Promise<void>;
|
|
126
|
+
/** Flushes any in-flight and pending metric exports. */
|
|
127
|
+
protected onForceFlush(): Promise<void>;
|
|
128
|
+
private canCollect;
|
|
129
|
+
private floorAllows;
|
|
130
|
+
/**
|
|
131
|
+
* Returns whether the current busy period has gone 1.5 periods without a
|
|
132
|
+
* collect. A collect from an earlier busy period does not count, so a short
|
|
133
|
+
* request after an idle gap is never overdue: collecting at its model call
|
|
134
|
+
* would set the floor and mute the drain that carries its points.
|
|
135
|
+
*/
|
|
136
|
+
private isOverdue;
|
|
137
|
+
/** Starts a collect, and moves the guidepost grid past `now`. */
|
|
138
|
+
private startCollect;
|
|
139
|
+
/** Runs one collect and export as the running collect. Never rejects. */
|
|
140
|
+
private runExclusive;
|
|
141
|
+
private collectAndExport;
|
|
142
|
+
private export;
|
|
143
|
+
}
|
|
144
|
+
export {};
|
|
@@ -7,10 +7,13 @@ import { Resource } from '@opentelemetry/resources';
|
|
|
7
7
|
import { LogRecordProcessor } from '@opentelemetry/sdk-logs';
|
|
8
8
|
import { MetricReader } from '@opentelemetry/sdk-metrics';
|
|
9
9
|
import { SpanProcessor } from '@opentelemetry/sdk-trace-base';
|
|
10
|
+
import type { GoogleAuth } from 'google-auth-library';
|
|
10
11
|
export interface OtelExportersConfig {
|
|
11
12
|
enableTracing?: boolean;
|
|
12
13
|
enableMetrics?: boolean;
|
|
13
14
|
enableLogging?: boolean;
|
|
15
|
+
projectId?: string;
|
|
16
|
+
auth?: GoogleAuth;
|
|
14
17
|
}
|
|
15
18
|
/**
|
|
16
19
|
* Configuration hooks for OpenTelemetry setup.
|
|
@@ -37,7 +37,7 @@ export declare function isAgentTool(obj: unknown): obj is AgentTool;
|
|
|
37
37
|
* application. The agent's input schema is used to define the tool's input
|
|
38
38
|
* parameters, and the agent's output is returned as the tool's result.
|
|
39
39
|
*
|
|
40
|
-
*
|
|
40
|
+
* @param config The configuration of the agent tool.
|
|
41
41
|
*/
|
|
42
42
|
export declare class AgentTool extends BaseTool {
|
|
43
43
|
/** A unique symbol to identify ADK agent tool class. */
|