3232from dagster_cloud_cli .core .workspace import CodeLocationDeployData
3333from dagster_shared .record import replace
3434
35- from dagster_cloud .agent .instrumentation .constants import DAGSTER_CLOUD_AGENT_METRIC_PREFIX
36- from dagster_cloud .agent .instrumentation .run_launch import extract_run_attributes
37- from dagster_cloud .agent .instrumentation .schedule import inspect_schedule_result
38- from dagster_cloud .agent .instrumentation .sensor import inspect_sensor_result
3935from dagster_cloud .agent .queries import (
4036 ADD_AGENT_HEARTBEATS_MUTATION ,
4137 DEPLOYMENTS_QUERY ,
5955)
6056from dagster_cloud .batching import Batcher
6157from dagster_cloud .instance import DagsterCloudAgentInstance
62- from dagster_cloud .opentelemetry .observers .execution_observer import observe_execution
6358from dagster_cloud .util import SERVER_HANDLE_TAG , compressed_namedtuple_upload_file , is_isolated_run
6459from dagster_cloud .version import __version__
6560from dagster_cloud .workspace .user_code_launcher import (
@@ -981,29 +976,12 @@ def _handle_api_request(
981976 instance_ref = self ._get_user_code_instance_ref (deployment_name ),
982977 )
983978
984- schedule_attributes = {
985- "schedule" : args .schedule_name ,
986- "repository" : args .repository_origin .repository_name ,
987- "location" : args .repository_origin .code_location_origin .location_name ,
988- "deployment" : deployment_name ,
989- }
990-
991- with observe_execution (
992- opentelemetry = self ._instance .opentelemetry ,
993- event_key = f"{ DAGSTER_CLOUD_AGENT_METRIC_PREFIX } .schedule.evaluation" ,
994- short_description = "schedule evaluation requests" ,
995- attributes = schedule_attributes ,
996- result_evaluator_callback = inspect_schedule_result ,
997- ) as observer :
998- serialized_schedule_data_or_error = client .external_schedule_execution (
999- external_schedule_execution_args = args ,
1000- )
1001- observer .evaluate_result (
1002- serialized_data_or_error = serialized_schedule_data_or_error ,
1003- )
1004- return DagsterCloudApiGrpcResponse (
1005- serialized_response_or_error = serialized_schedule_data_or_error
1006- )
979+ serialized_schedule_data_or_error = client .external_schedule_execution (
980+ external_schedule_execution_args = args ,
981+ )
982+ return DagsterCloudApiGrpcResponse (
983+ serialized_response_or_error = serialized_schedule_data_or_error
984+ )
1007985
1008986 elif api_name == DagsterCloudApi .GET_EXTERNAL_SENSOR_EXECUTION_DATA :
1009987 client = self ._get_grpc_client (
@@ -1015,27 +993,12 @@ def _handle_api_request(
1015993 instance_ref = self ._get_user_code_instance_ref (deployment_name ),
1016994 )
1017995
1018- sensor_attributes = {
1019- "sensor" : args .sensor_name ,
1020- "repository" : args .repository_origin .repository_name ,
1021- "location" : args .repository_origin .code_location_origin .location_name ,
1022- "deployment" : deployment_name ,
1023- }
1024-
1025- with observe_execution (
1026- opentelemetry = self ._instance .opentelemetry ,
1027- event_key = f"{ DAGSTER_CLOUD_AGENT_METRIC_PREFIX } .sensor.evaluation" ,
1028- short_description = "sensor evaluation requests" ,
1029- attributes = sensor_attributes ,
1030- result_evaluator_callback = inspect_sensor_result ,
1031- ) as observer :
1032- serialized_sensor_data_or_error = client .external_sensor_execution (
1033- sensor_execution_args = args ,
1034- )
1035- observer .evaluate_result (serialized_sensor_data_or_error )
1036- return DagsterCloudApiGrpcResponse (
1037- serialized_response_or_error = serialized_sensor_data_or_error
1038- )
996+ serialized_sensor_data_or_error = client .external_sensor_execution (
997+ sensor_execution_args = args ,
998+ )
999+ return DagsterCloudApiGrpcResponse (
1000+ serialized_response_or_error = serialized_sensor_data_or_error
1001+ )
10391002 elif api_name == DagsterCloudApi .GET_EXTERNAL_NOTEBOOK_DATA :
10401003 client = self ._get_grpc_client (
10411004 user_code_launcher , deployment_name , cast ("str" , location_name )
@@ -1066,42 +1029,32 @@ def _handle_api_request(
10661029 ),
10671030 )
10681031
1069- run_attributes = extract_run_attributes (deployment_name , run )
1070- with observe_execution (
1071- opentelemetry = self ._instance .opentelemetry ,
1072- event_key = f"{ DAGSTER_CLOUD_AGENT_METRIC_PREFIX } .run.launches" ,
1073- short_description = "run execution requests" ,
1074- attributes = run_attributes ,
1075- ) as observer :
1076- launcher = scoped_instance .get_run_launcher_for_run (run ) # type: ignore # (instance subclass)
1032+ launcher = scoped_instance .get_run_launcher_for_run (run ) # type: ignore # (instance subclass)
10771033
1078- if is_isolated_run (run ):
1079- launcher .launch_run (LaunchRunContext (dagster_run = run , workspace = None ))
1080- else :
1081- scoped_instance .report_engine_event (
1082- f"Launching { run .run_id } without an isolated run environment." ,
1083- run ,
1084- cls = self .__class__ ,
1085- )
1034+ if is_isolated_run (run ):
1035+ launcher .launch_run (LaunchRunContext (dagster_run = run , workspace = None ))
1036+ else :
1037+ scoped_instance .report_engine_event (
1038+ f"Launching { run .run_id } without an isolated run environment." ,
1039+ run ,
1040+ cls = self .__class__ ,
1041+ )
10861042
1087- run_location_name = cast (
1088- "str" ,
1089- run .remote_job_origin .repository_origin .code_location_origin .location_name ,
1090- )
1043+ run_location_name = cast (
1044+ "str" ,
1045+ run .remote_job_origin .repository_origin .code_location_origin .location_name ,
1046+ )
10911047
1092- server = user_code_launcher .get_grpc_server (
1093- deployment_name , run_location_name
1094- )
1048+ server = user_code_launcher .get_grpc_server (deployment_name , run_location_name )
10951049
1096- # Record the server handle that we launched it on to for run monitoring
1097- scoped_instance .add_run_tags (
1098- run .run_id , new_tags = {SERVER_HANDLE_TAG : str (server .server_handle )}
1099- )
1050+ # Record the server handle that we launched it on to for run monitoring
1051+ scoped_instance .add_run_tags (
1052+ run .run_id , new_tags = {SERVER_HANDLE_TAG : str (server .server_handle )}
1053+ )
11001054
1101- launcher .launch_run_from_grpc_client (
1102- scoped_instance , run , server .server_endpoint .create_client ()
1103- )
1104- observer .evaluate_result (run = run )
1055+ launcher .launch_run_from_grpc_client (
1056+ scoped_instance , run , server .server_endpoint .create_client ()
1057+ )
11051058
11061059 return DagsterCloudApiSuccess ()
11071060 elif api_name == DagsterCloudApi .TERMINATE_RUN :
0 commit comments