1 /* 2 * Copyright 2022 Google LLC 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 #ifndef FCP_CLIENT_PHASE_LOGGER_H_ 17 #define FCP_CLIENT_PHASE_LOGGER_H_ 18 19 #include "absl/strings/string_view.h" 20 #include "fcp/client/opstats/opstats_logger.h" 21 #include "fcp/client/stats.h" 22 #include "fcp/protos/federated_api.pb.h" 23 24 namespace fcp { 25 namespace client { 26 27 class PhaseLogger { 28 public: 29 virtual ~PhaseLogger() = default; 30 virtual void UpdateRetryWindowAndNetworkStats( 31 const ::google::internal::federatedml::v2::RetryWindow& retry_window, 32 const NetworkStats& network_stats) = 0; 33 virtual void SetModelIdentifier(absl::string_view model_identifier) = 0; 34 35 // Called when a run was started but immediately aborted. 36 virtual void LogTaskNotStarted(absl::string_view error_message) = 0; 37 // Called when a run was started but the runtime failed to initialize a 38 // noncritical component, and execution continue. 39 virtual void LogNonfatalInitializationError(absl::Status error_status) = 0; 40 // Called when a run was started but the runtime failed to initialize a 41 // component, and execution was halted. 42 virtual void LogFatalInitializationError(absl::Status error_status) = 0; 43 44 // Eligibility eval check-in phase. 45 // Called when an eligibility eval check-in starts. 46 virtual void LogEligibilityEvalCheckinStarted() = 0; 47 // Called when an IO error is encountered during eligibility eval check-in. 48 virtual void LogEligibilityEvalCheckinIOError( 49 absl::Status error_status, const NetworkStats& network_stats, 50 absl::Time time_before_checkin) = 0; 51 // Called when an invalid payload is received from the eligibility eval 52 // check-in result. 53 virtual void LogEligibilityEvalCheckinInvalidPayloadError( 54 absl::string_view error_message, const NetworkStats& network_stats, 55 absl::Time time_before_checkin) = 0; 56 // Called when the eligibility eval check-in is interrupted by the client. 57 virtual void LogEligibilityEvalCheckinClientInterrupted( 58 absl::Status error_status, const NetworkStats& network_stats, 59 absl::Time time_before_checkin) = 0; 60 // Called when the eligibility eval check-in is aborted by the server. 61 virtual void LogEligibilityEvalCheckinServerAborted( 62 absl::Status error_status, const NetworkStats& network_stats, 63 absl::Time time_before_checkin) = 0; 64 // Called when eligibility eval is not configured. 65 virtual void LogEligibilityEvalNotConfigured( 66 const NetworkStats& network_stats, absl::Time time_before_checkin) = 0; 67 // Called when eligibility eval check-in request is turned away by the server. 68 virtual void LogEligibilityEvalCheckinTurnedAway( 69 const NetworkStats& network_stats, absl::Time time_before_checkin) = 0; 70 virtual void LogEligibilityEvalCheckinPlanUriReceived( 71 const NetworkStats& network_stats, absl::Time time_before_checkin) = 0; 72 // Called when a valid eligibility eval plan is received. 73 virtual void LogEligibilityEvalCheckinCompleted( 74 const NetworkStats& network_stats, absl::Time time_before_checkin, 75 absl::Time time_before_plan_download) = 0; 76 77 // Eligibility eval computation phase. 78 // Called when the eligibility eval computation starts. 79 virtual void LogEligibilityEvalComputationStarted() = 0; 80 // Called when the input parameters for the eligibility eval task are invalid. 81 virtual void LogEligibilityEvalComputationInvalidArgument( 82 absl::Status error_status, const ExampleStats& example_stats, 83 absl::Time run_plan_start_time) = 0; 84 // Called when an example store error happened during eligibility eval 85 // computation. 86 virtual void LogEligibilityEvalComputationExampleIteratorError( 87 absl::Status error_status, const ExampleStats& example_stats, 88 absl::Time run_plan_start_time) = 0; 89 // Called when a tensorflow error happened during eligibiliity eval 90 // computation. 91 virtual void LogEligibilityEvalComputationTensorflowError( 92 absl::Status error_status, const ExampleStats& example_stats, 93 absl::Time run_plan_start_time, absl::Time reference_time) = 0; 94 // Called when the eligibility eval computation is interrupted. 95 virtual void LogEligibilityEvalComputationInterrupted( 96 absl::Status error_status, const ExampleStats& example_stats, 97 absl::Time run_plan_start_time, absl::Time reference_time) = 0; 98 // Called when the eligibility eval computation is completed. 99 virtual void LogEligibilityEvalComputationCompleted( 100 const ExampleStats& example_stats, absl::Time run_plan_start_time, 101 absl::Time reference_time) = 0; 102 103 // Check-in phase. 104 // Called when a regular check-in starts. 105 virtual void LogCheckinStarted() = 0; 106 // Called when an IO error occurred during check-in. 107 virtual void LogCheckinIOError(absl::Status error_status, 108 const NetworkStats& network_stats, 109 absl::Time time_before_checkin, 110 absl::Time reference_time) = 0; 111 // Called when an invalid payload is received from the check-in result. 112 virtual void LogCheckinInvalidPayload(absl::string_view error_message, 113 const NetworkStats& network_stats, 114 absl::Time time_before_checkin, 115 absl::Time reference_time) = 0; 116 // Called when check-in is interrupted by the client. 117 virtual void LogCheckinClientInterrupted(absl::Status error_status, 118 const NetworkStats& network_stats, 119 absl::Time time_before_checkin, 120 absl::Time reference_time) = 0; 121 // Called when check-in is aborted by the server. 122 virtual void LogCheckinServerAborted(absl::Status error_status, 123 const NetworkStats& network_stats, 124 absl::Time time_before_checkin, 125 absl::Time reference_time) = 0; 126 // Called when the client's check-in request is turned away by the server. 127 virtual void LogCheckinTurnedAway(const NetworkStats& network_stats, 128 absl::Time time_before_checkin, 129 absl::Time reference_time) = 0; 130 virtual void LogCheckinPlanUriReceived(absl::string_view task_name, 131 const NetworkStats& network_stats, 132 absl::Time time_before_checkin) = 0; 133 // Called when check-in is completed. 134 virtual void LogCheckinCompleted(absl::string_view task_name, 135 const NetworkStats& network_stats, 136 absl::Time time_before_checkin, 137 absl::Time time_before_plan_download, 138 absl::Time reference_time) = 0; 139 140 // Computation phase. 141 // Called when computation started. 142 virtual void LogComputationStarted() = 0; 143 // Called when the input parameters are invalid. 144 virtual void LogComputationInvalidArgument( 145 absl::Status error_status, const ExampleStats& example_stats, 146 const NetworkStats& network_stats, absl::Time run_plan_start_time) = 0; 147 // Called when an example store error occurred during computation. 148 virtual void LogComputationExampleIteratorError( 149 absl::Status error_status, const ExampleStats& example_stats, 150 const NetworkStats& network_stats, absl::Time run_plan_start_time) = 0; 151 // Called when an IO error happened during computation 152 virtual void LogComputationIOError(absl::Status error_status, 153 const ExampleStats& example_stats, 154 const NetworkStats& network_stats, 155 absl::Time run_plan_start_time) = 0; 156 // Called when a tensorflow error happened during computation. 157 virtual void LogComputationTensorflowError(absl::Status error_status, 158 const ExampleStats& example_stats, 159 const NetworkStats& network_stats, 160 absl::Time run_plan_start_time, 161 absl::Time reference_time) = 0; 162 // Called when computation is interrupted. 163 virtual void LogComputationInterrupted(absl::Status error_status, 164 const ExampleStats& example_stats, 165 const NetworkStats& network_stats, 166 absl::Time run_plan_start_time, 167 absl::Time reference_time) = 0; 168 // Called when computation is completed. 169 virtual void LogComputationCompleted(const ExampleStats& example_stats, 170 const NetworkStats& network_stats, 171 absl::Time run_plan_start_time, 172 absl::Time reference_time) = 0; 173 174 // Result upload phase. Result upload only happens when all the previous 175 // phases succeed. 176 // Called when result upload started. 177 virtual absl::Status LogResultUploadStarted() = 0; 178 // Called when an IO error occurred during result upload. 179 virtual void LogResultUploadIOError(absl::Status error_status, 180 const NetworkStats& network_stats, 181 absl::Time time_before_result_upload, 182 absl::Time reference_time) = 0; 183 // Called when the result upload is interrupted by the client. 184 virtual void LogResultUploadClientInterrupted( 185 absl::Status error_status, const NetworkStats& network_stats, 186 absl::Time time_before_result_upload, absl::Time reference_time) = 0; 187 // Called when the result upload is aborted by the server. 188 virtual void LogResultUploadServerAborted( 189 absl::Status error_status, const NetworkStats& network_stats, 190 absl::Time time_before_result_upload, absl::Time reference_time) = 0; 191 // Called when result upload is completed. 192 virtual void LogResultUploadCompleted(const NetworkStats& network_stats, 193 absl::Time time_before_result_upload, 194 absl::Time reference_time) = 0; 195 196 // Failure upload phase. Failure upload only happens when any of the previous 197 // phases failed. 198 // Called when failure upload starts. 199 virtual absl::Status LogFailureUploadStarted() = 0; 200 // Called when an IO error occurred during failure upload. 201 virtual void LogFailureUploadIOError(absl::Status error_status, 202 const NetworkStats& network_stats, 203 absl::Time time_before_failure_upload, 204 absl::Time reference_time) = 0; 205 // Called when the failure upload is interrupted by the client. 206 virtual void LogFailureUploadClientInterrupted( 207 absl::Status error_status, const NetworkStats& network_stats, 208 absl::Time time_before_failure_upload, absl::Time reference_time) = 0; 209 // Called when the failure upload is aborted by the server. 210 virtual void LogFailureUploadServerAborted( 211 absl::Status error_status, const NetworkStats& network_stats, 212 absl::Time time_before_failure_upload, absl::Time reference_time) = 0; 213 // Called when the failure upload is completed. 214 virtual void LogFailureUploadCompleted(const NetworkStats& network_stats, 215 absl::Time time_before_failure_upload, 216 absl::Time reference_time) = 0; 217 }; 218 219 } // namespace client 220 } // namespace fcp 221 222 #endif // FCP_CLIENT_PHASE_LOGGER_H_ 223