@@ -391,40 +391,30 @@ def create(
391391 .with_runtime (container_runtime )
392392 ).deploy (wait_for_completion = False )
393393
394- if is_fine_tuned_model :
395- # tracks unique deployments that were created in the user compartment
396- self .telemetry .record_event_async (
397- category = "aqua/custom/deployment" , action = "create" , detail = model_name
398- )
399- # tracks the shape used for deploying the custom models
400- self .telemetry .record_event_async (
401- category = "aqua/custom/deployment/create" ,
402- action = "shape" ,
403- detail = instance_shape ,
404- )
405- # tracks the shape used for deploying the custom models by name
406- self .telemetry .record_event_async (
407- category = f"aqua/custom/{ model_name } /deployment/create" ,
408- action = "shape" ,
409- detail = instance_shape ,
410- )
411- else :
412- # tracks unique deployments that were created in the user compartment
413- self .telemetry .record_event_async (
414- category = "aqua/service/deployment" , action = "create" , detail = model_name
415- )
416- # tracks the shape used for deploying the service models
417- self .telemetry .record_event_async (
418- category = "aqua/service/deployment/create" ,
419- action = "shape" ,
420- detail = instance_shape ,
421- )
422- # tracks the shape used for deploying the service models by name
423- self .telemetry .record_event_async (
424- category = f"aqua/service/{ model_name } /deployment/create" ,
425- action = "shape" ,
426- detail = instance_shape ,
427- )
394+ model_type = "custom" if is_fine_tuned_model else "service"
395+ deployment_id = deployment .dsc_model_deployment .id
396+ telemetry_kwargs = (
397+ {"ocid" : deployment_id [- 8 :]} if len (deployment_id ) > 8 else {}
398+ )
399+ # tracks unique deployments that were created in the user compartment
400+ self .telemetry .record_event_async (
401+ category = f"aqua/{ model_type } /deployment" ,
402+ action = "create" ,
403+ detail = model_name ,
404+ ** telemetry_kwargs ,
405+ )
406+ # tracks the shape used for deploying the custom or service models
407+ self .telemetry .record_event_async (
408+ category = f"aqua/{ model_type } /deployment/create" ,
409+ action = "shape" ,
410+ detail = instance_shape ,
411+ )
412+ # tracks the shape used for deploying the custom or service models by name
413+ self .telemetry .record_event_async (
414+ category = f"aqua/{ model_type } /{ model_name } /deployment/create" ,
415+ action = "shape" ,
416+ detail = instance_shape ,
417+ )
428418
429419 return AquaDeployment .from_oci_model_deployment (
430420 deployment .dsc_model_deployment , self .region
@@ -471,6 +461,18 @@ def list(self, **kwargs) -> List["AquaDeployment"]:
471461 )
472462 )
473463
464+ # log telemetry if MD is in active or failed state
465+ deployment_id = model_deployment .id
466+ state = model_deployment .lifecycle_state .upper ()
467+ if state in ["ACTIVE" , "FAILED" ]:
468+ # tracks unique deployments that were listed in the user compartment
469+ self .telemetry .record_event_async (
470+ category = f"aqua/deployment" ,
471+ action = "list" ,
472+ detail = deployment_id [- 8 :] if len (deployment_id ) > 8 else "" ,
473+ value = state ,
474+ )
475+
474476 # tracks number of times deployment listing was called
475477 self .telemetry .record_event_async (category = "aqua/deployment" , action = "list" )
476478
0 commit comments