You've already forked adk-python
mirror of
https://github.com/encounter/adk-python.git
synced 2026-03-30 10:57:20 -07:00
feat(cli): add otel_to_cloud flag to adk deploy cloud_run and adk deploy gke command
Co-authored-by: Wiktoria Walczak <wwalczak@google.com> PiperOrigin-RevId: 854087382
This commit is contained in:
committed by
Copybara-Service
parent
4dd5434847
commit
62fa4e513c
@@ -64,7 +64,7 @@ COPY --chown=myuser:myuser "agents/{app_name}/" "/app/agents/{app_name}/"
|
||||
|
||||
EXPOSE {port}
|
||||
|
||||
CMD adk {command} --port={port} {host_option} {service_option} {trace_to_cloud_option} {allow_origins_option} {a2a_option} "/app/agents"
|
||||
CMD adk {command} --port={port} {host_option} {service_option} {trace_to_cloud_option} {otel_to_cloud_option} {allow_origins_option} {a2a_option} "/app/agents"
|
||||
"""
|
||||
|
||||
_AGENT_ENGINE_APP_TEMPLATE: Final[str] = """
|
||||
@@ -487,6 +487,7 @@ def to_cloud_run(
|
||||
temp_folder: str,
|
||||
port: int,
|
||||
trace_to_cloud: bool,
|
||||
otel_to_cloud: bool,
|
||||
with_ui: bool,
|
||||
log_level: str,
|
||||
verbosity: str,
|
||||
@@ -523,6 +524,8 @@ def to_cloud_run(
|
||||
temp_folder: The temp folder for the generated Cloud Run source files.
|
||||
port: The port of the ADK api server.
|
||||
trace_to_cloud: Whether to enable Cloud Trace.
|
||||
otel_to_cloud: Whether to enable exporting OpenTelemetry signals
|
||||
to Google Cloud.
|
||||
with_ui: Whether to deploy with UI.
|
||||
verbosity: The verbosity level of the CLI.
|
||||
adk_version: The ADK version to use in Cloud Run.
|
||||
@@ -580,6 +583,7 @@ def to_cloud_run(
|
||||
use_local_storage,
|
||||
),
|
||||
trace_to_cloud_option='--trace_to_cloud' if trace_to_cloud else '',
|
||||
otel_to_cloud_option='--otel_to_cloud' if otel_to_cloud else '',
|
||||
allow_origins_option=allow_origins_option,
|
||||
adk_version=adk_version,
|
||||
host_option=host_option,
|
||||
@@ -956,6 +960,7 @@ def to_gke(
|
||||
temp_folder: str,
|
||||
port: int,
|
||||
trace_to_cloud: bool,
|
||||
otel_to_cloud: bool,
|
||||
with_ui: bool,
|
||||
log_level: str,
|
||||
adk_version: str,
|
||||
@@ -981,6 +986,8 @@ def to_gke(
|
||||
Dockerfile and deployment.yaml.
|
||||
port: The port of the ADK api server.
|
||||
trace_to_cloud: Whether to enable Cloud Trace.
|
||||
otel_to_cloud: Whether to enable exporting OpenTelemetry signals
|
||||
to Google Cloud.
|
||||
with_ui: Whether to deploy with UI.
|
||||
log_level: The logging level.
|
||||
adk_version: The ADK version to use in GKE.
|
||||
@@ -1051,6 +1058,7 @@ def to_gke(
|
||||
use_local_storage,
|
||||
),
|
||||
trace_to_cloud_option='--trace_to_cloud' if trace_to_cloud else '',
|
||||
otel_to_cloud_option='--otel_to_cloud' if otel_to_cloud else '',
|
||||
allow_origins_option=allow_origins_option,
|
||||
adk_version=adk_version,
|
||||
host_option=host_option,
|
||||
|
||||
@@ -1370,6 +1370,13 @@ def cli_api_server(
|
||||
default=False,
|
||||
help="Optional. Whether to enable Cloud Trace for cloud run.",
|
||||
)
|
||||
@click.option(
|
||||
"--otel_to_cloud",
|
||||
is_flag=True,
|
||||
show_default=True,
|
||||
default=False,
|
||||
help="Optional. Whether to enable OpenTelemetry for Agent Engine.",
|
||||
)
|
||||
@click.option(
|
||||
"--with_ui",
|
||||
is_flag=True,
|
||||
@@ -1450,6 +1457,7 @@ def cli_deploy_cloud_run(
|
||||
temp_folder: str,
|
||||
port: int,
|
||||
trace_to_cloud: bool,
|
||||
otel_to_cloud: bool,
|
||||
with_ui: bool,
|
||||
adk_version: str,
|
||||
log_level: str,
|
||||
@@ -1528,6 +1536,7 @@ def cli_deploy_cloud_run(
|
||||
temp_folder=temp_folder,
|
||||
port=port,
|
||||
trace_to_cloud=trace_to_cloud,
|
||||
otel_to_cloud=otel_to_cloud,
|
||||
allow_origins=allow_origins,
|
||||
with_ui=with_ui,
|
||||
log_level=log_level,
|
||||
@@ -1799,6 +1808,13 @@ def cli_deploy_agent_engine(
|
||||
default=False,
|
||||
help="Optional. Whether to enable Cloud Trace for GKE.",
|
||||
)
|
||||
@click.option(
|
||||
"--otel_to_cloud",
|
||||
is_flag=True,
|
||||
show_default=True,
|
||||
default=False,
|
||||
help="Optional. Whether to enable OpenTelemetry for GKE.",
|
||||
)
|
||||
@click.option(
|
||||
"--with_ui",
|
||||
is_flag=True,
|
||||
@@ -1855,6 +1871,7 @@ def cli_deploy_gke(
|
||||
temp_folder: str,
|
||||
port: int,
|
||||
trace_to_cloud: bool,
|
||||
otel_to_cloud: bool,
|
||||
with_ui: bool,
|
||||
adk_version: str,
|
||||
log_level: Optional[str] = None,
|
||||
@@ -1884,6 +1901,7 @@ def cli_deploy_gke(
|
||||
temp_folder=temp_folder,
|
||||
port=port,
|
||||
trace_to_cloud=trace_to_cloud,
|
||||
otel_to_cloud=otel_to_cloud,
|
||||
with_ui=with_ui,
|
||||
log_level=log_level,
|
||||
adk_version=adk_version,
|
||||
|
||||
@@ -262,6 +262,7 @@ def test_to_gke_happy_path(
|
||||
temp_folder=str(tmp_path),
|
||||
port=9090,
|
||||
trace_to_cloud=False,
|
||||
otel_to_cloud=False,
|
||||
with_ui=True,
|
||||
log_level="debug",
|
||||
adk_version="1.2.0",
|
||||
|
||||
@@ -122,6 +122,7 @@ def test_to_cloud_run_happy_path(
|
||||
temp_folder=str(tmp_path),
|
||||
port=8080,
|
||||
trace_to_cloud=True,
|
||||
otel_to_cloud=True,
|
||||
with_ui=with_ui,
|
||||
log_level="info",
|
||||
verbosity="info",
|
||||
@@ -154,6 +155,7 @@ def test_to_cloud_run_happy_path(
|
||||
assert "ENV GOOGLE_CLOUD_LOCATION=asia-northeast1" in dockerfile_content
|
||||
assert "RUN pip install google-adk==1.3.0" in dockerfile_content
|
||||
assert "--trace_to_cloud" in dockerfile_content
|
||||
assert "--otel_to_cloud" in dockerfile_content
|
||||
|
||||
# Check agent dependencies installation based on include_requirements
|
||||
if include_requirements:
|
||||
@@ -220,6 +222,7 @@ def test_to_cloud_run_cleans_temp_dir(
|
||||
temp_folder=str(tmp_dir),
|
||||
port=8080,
|
||||
trace_to_cloud=False,
|
||||
otel_to_cloud=False,
|
||||
with_ui=False,
|
||||
log_level="info",
|
||||
verbosity="info",
|
||||
@@ -258,6 +261,7 @@ def test_to_cloud_run_cleans_temp_dir_on_failure(
|
||||
temp_folder=str(tmp_dir),
|
||||
port=8080,
|
||||
trace_to_cloud=False,
|
||||
otel_to_cloud=False,
|
||||
with_ui=False,
|
||||
log_level="info",
|
||||
verbosity="info",
|
||||
@@ -326,6 +330,7 @@ def test_cloud_run_label_merging(
|
||||
temp_folder=str(tmp_path),
|
||||
port=8080,
|
||||
trace_to_cloud=False,
|
||||
otel_to_cloud=False,
|
||||
with_ui=False,
|
||||
log_level="info",
|
||||
verbosity="info",
|
||||
|
||||
Reference in New Issue
Block a user