From dd90bbf3dcd9fbe7f0bb4af275712a2c30281a9b Mon Sep 17 00:00:00 2001 From: Brian Xia Date: Wed, 25 Feb 2026 01:16:50 +0000 Subject: [PATCH] Emit metrics for CLI commands --- src/sagemaker/hyperpod/cli/commands/space.py | 10 ++++++++++ src/sagemaker/hyperpod/cli/commands/space_access.py | 1 + src/sagemaker/hyperpod/cli/commands/space_template.py | 9 +++++++++ 3 files changed, 20 insertions(+) diff --git a/src/sagemaker/hyperpod/cli/commands/space.py b/src/sagemaker/hyperpod/cli/commands/space.py index b44cce2d..6a2eb182 100644 --- a/src/sagemaker/hyperpod/cli/commands/space.py +++ b/src/sagemaker/hyperpod/cli/commands/space.py @@ -20,6 +20,7 @@ schema_pkg="hyperpod_space_template", registry=SCHEMA_REGISTRY, ) +@_hyperpod_telemetry_emitter(Feature.HYPERPOD_CLI, "create_space") @handle_cli_exceptions() def space_create(version, debug, config): """Create a space resource.""" @@ -32,6 +33,7 @@ def space_create(version, debug, config): @click.command("hyp-space") @click.option("--namespace", "-n", required=False, default="default", help="Kubernetes namespace") @click.option("--output", "-o", type=click.Choice(["table", "json"]), default="table") +@_hyperpod_telemetry_emitter(Feature.HYPERPOD_CLI, "list_spaces") @handle_cli_exceptions() def space_list(namespace, output): """List space resources.""" @@ -74,6 +76,7 @@ def space_list(namespace, output): @click.option("--name", required=True, help="Name of the space") @click.option("--namespace", "-n", required=False, default="default", help="Kubernetes namespace") @click.option("--output", "-o", type=click.Choice(["yaml", "json"]), default="yaml") +@_hyperpod_telemetry_emitter(Feature.HYPERPOD_CLI, "describe_space") @handle_cli_exceptions() def space_describe(name, namespace, output): """Describe a space resource.""" @@ -91,6 +94,7 @@ def space_describe(name, namespace, output): @click.command("hyp-space") @click.option("--name", required=True, help="Name of the space") @click.option("--namespace", "-n", required=False, default="default", help="Kubernetes namespace") +@_hyperpod_telemetry_emitter(Feature.HYPERPOD_CLI, "delete_space") @handle_cli_exceptions() def space_delete(name, namespace): """Delete a space resource.""" @@ -105,6 +109,7 @@ def space_delete(name, namespace): registry=SCHEMA_REGISTRY, is_update=True, ) +@_hyperpod_telemetry_emitter(Feature.HYPERPOD_CLI, "update_space") @handle_cli_exceptions() def space_update(version, config): """Update a space resource.""" @@ -119,6 +124,7 @@ def space_update(version, config): @click.command("hyp-space") @click.option("--name", required=True, help="Name of the space") @click.option("--namespace", "-n", required=False, default="default", help="Kubernetes namespace") +@_hyperpod_telemetry_emitter(Feature.HYPERPOD_CLI, "start_space") @handle_cli_exceptions() def space_start(name, namespace): """Start a space resource.""" @@ -130,6 +136,7 @@ def space_start(name, namespace): @click.command("hyp-space") @click.option("--name", required=True, help="Name of the space") @click.option("--namespace", "-n", required=False, default="default", help="Kubernetes namespace") +@_hyperpod_telemetry_emitter(Feature.HYPERPOD_CLI, "stop_space") @handle_cli_exceptions() def space_stop(name, namespace): """Stop a space resource.""" @@ -143,6 +150,7 @@ def space_stop(name, namespace): @click.option("--namespace", "-n", required=False, default="default", help="Kubernetes namespace") @click.option("--pod-name", required=False, help="Name of the pod to get logs from") @click.option("--container", required=False, help="Name of the container to get logs from") +@_hyperpod_telemetry_emitter(Feature.HYPERPOD_CLI, "get_logs_for_space") @handle_cli_exceptions() def space_get_logs(name, namespace, pod_name, container): """Get logs for a space resource.""" @@ -155,6 +163,8 @@ def space_get_logs(name, namespace, pod_name, container): @click.option("--name", required=True, help="Name of the space") @click.option("--namespace", "-n", required=False, default="default", help="Kubernetes namespace") @click.option("--local-port", required=False, default=DEFAULT_SPACE_PORT, help="Localhost port that is mapped to the space") +@_hyperpod_telemetry_emitter(Feature.HYPERPOD_CLI, "portforward_for_space") +@handle_cli_exceptions() def space_portforward(name, namespace, local_port): """Port forward to localhost for a space resource.""" # Validate input port diff --git a/src/sagemaker/hyperpod/cli/commands/space_access.py b/src/sagemaker/hyperpod/cli/commands/space_access.py index e0fc1408..adcb92e3 100644 --- a/src/sagemaker/hyperpod/cli/commands/space_access.py +++ b/src/sagemaker/hyperpod/cli/commands/space_access.py @@ -15,6 +15,7 @@ default="vscode-remote", help="Remote access type supported values: [vscode-remote, web-ui] [default: vscode-remote]" ) +@_hyperpod_telemetry_emitter(Feature.HYPERPOD_CLI, "create_space_access") @handle_cli_exceptions() def space_access_create(name, namespace, connection_type): """Create a space access resource.""" diff --git a/src/sagemaker/hyperpod/cli/commands/space_template.py b/src/sagemaker/hyperpod/cli/commands/space_template.py index d0bfd6a0..65e6f71b 100644 --- a/src/sagemaker/hyperpod/cli/commands/space_template.py +++ b/src/sagemaker/hyperpod/cli/commands/space_template.py @@ -4,10 +4,15 @@ from tabulate import tabulate from sagemaker.hyperpod.space.hyperpod_space_template import HPSpaceTemplate from sagemaker.hyperpod.common.cli_decorators import handle_cli_exceptions +from sagemaker.hyperpod.common.telemetry.telemetry_logging import ( + _hyperpod_telemetry_emitter, +) +from sagemaker.hyperpod.common.telemetry.constants import Feature @click.command("hyp-space-template") @click.option("--file", "-f", required=True, help="YAML file containing the configuration") +@_hyperpod_telemetry_emitter(Feature.HYPERPOD_CLI, "create_space_template") @handle_cli_exceptions() def space_template_create(file): """Create a space-template resource.""" @@ -19,6 +24,7 @@ def space_template_create(file): @click.command("hyp-space-template") @click.option("--namespace", "-n", required=False, default=None, help="Kubernetes namespace") @click.option("--output", "-o", type=click.Choice(["table", "json"]), default="table") +@_hyperpod_telemetry_emitter(Feature.HYPERPOD_CLI, "list_space_templates") @handle_cli_exceptions() def space_template_list(namespace, output): """List space-template resources.""" @@ -46,6 +52,7 @@ def space_template_list(namespace, output): @click.option("--name", required=True, help="Name of the space template") @click.option("--namespace", "-n", required=False, default=None, help="Kubernetes namespace") @click.option("--output", "-o", type=click.Choice(["yaml", "json"]), default="yaml") +@_hyperpod_telemetry_emitter(Feature.HYPERPOD_CLI, "describe_space_template") @handle_cli_exceptions() def space_template_describe(name, namespace, output): """Describe a space-template resource.""" @@ -60,6 +67,7 @@ def space_template_describe(name, namespace, output): @click.command("hyp-space-template") @click.option("--name", required=True, help="Name of the space template") @click.option("--namespace", "-n", required=False, default=None, help="Kubernetes namespace") +@_hyperpod_telemetry_emitter(Feature.HYPERPOD_CLI, "delete_space_template") @handle_cli_exceptions() def space_template_delete(name, namespace): """Delete a space-template resource.""" @@ -72,6 +80,7 @@ def space_template_delete(name, namespace): @click.option("--name", required=True, help="Name of the space template") @click.option("--namespace", "-n", required=False, default=None, help="Kubernetes namespace") @click.option("--file", "-f", required=True, help="YAML file containing the updated template") +@_hyperpod_telemetry_emitter(Feature.HYPERPOD_CLI, "update_space_template") @handle_cli_exceptions() def space_template_update(name, namespace, file): """Update a space-template resource."""