25
25
#include < memory>
26
26
#include < sstream>
27
27
#include < string>
28
+ #include < utility>
28
29
#include < variant>
29
30
#include < vector>
30
31
@@ -143,6 +144,12 @@ class EventManager final {
143
144
public:
144
145
static EventManager &Instance ();
145
146
147
+ EventManager (const EventManager &manager) = delete ;
148
+
149
+ const EventManager &operator =(const EventManager &manager) = delete ;
150
+
151
+ ~EventManager () = default ;
152
+
146
153
bool IsEmpty ();
147
154
148
155
// We added `const json &custom_fields` here because we need to support typed custom
@@ -167,11 +174,6 @@ class EventManager final {
167
174
private:
168
175
EventManager ();
169
176
170
- EventManager (const EventManager &manager) = delete ;
171
-
172
- const EventManager &operator =(const EventManager &manager) = delete ;
173
-
174
- private:
175
177
absl::flat_hash_map<std::string, std::shared_ptr<BaseEventReporter>> reporter_map_;
176
178
absl::flat_hash_map<rpc::ExportEvent_SourceType, std::shared_ptr<LogEventReporter>>
177
179
export_log_reporter_map_;
@@ -183,7 +185,7 @@ class RayEventContext final {
183
185
public:
184
186
static RayEventContext &Instance ();
185
187
186
- RayEventContext () {}
188
+ RayEventContext () = default ;
187
189
188
190
void SetEventContext (
189
191
rpc::Event_SourceType source_type,
@@ -201,31 +203,31 @@ class RayEventContext final {
201
203
void UpdateCustomFields (
202
204
const absl::flat_hash_map<std::string, std::string> &custom_fields);
203
205
204
- inline void SetSourceType (rpc::Event_SourceType source_type) {
205
- source_type_ = source_type;
206
- }
206
+ void SetSourceType (rpc::Event_SourceType source_type) { source_type_ = source_type; }
207
207
208
- inline const rpc::Event_SourceType &GetSourceType () const { return source_type_; }
208
+ const rpc::Event_SourceType &GetSourceType () const { return source_type_; }
209
209
210
- inline const std::string &GetSourceHostname () const { return source_hostname_; }
210
+ const std::string &GetSourceHostname () const { return source_hostname_; }
211
211
212
- inline int32_t GetSourcePid () const { return source_pid_; }
212
+ int32_t GetSourcePid () const { return source_pid_; }
213
213
214
- inline const absl::flat_hash_map<std::string, std::string> &GetCustomFields () const {
214
+ const absl::flat_hash_map<std::string, std::string> &GetCustomFields () const {
215
215
return custom_fields_;
216
216
}
217
217
218
- inline bool GetInitialzed () const {
218
+ bool GetInitialzed () const {
219
219
return source_type_ != rpc::Event_SourceType::Event_SourceType_COMMON;
220
220
}
221
221
222
- private:
223
- static RayEventContext &GlobalInstance ();
224
-
225
222
RayEventContext (const RayEventContext &event_context) = delete ;
226
223
227
224
const RayEventContext &operator =(const RayEventContext &event_context) = delete ;
228
225
226
+ ~RayEventContext () = default ;
227
+
228
+ private:
229
+ static RayEventContext &GlobalInstance ();
230
+
229
231
rpc::Event_SourceType source_type_ = rpc::Event_SourceType::Event_SourceType_COMMON;
230
232
std::string source_hostname_ = boost::asio::ip::host_name();
231
233
int32_t source_pid_ = getpid();
@@ -251,12 +253,12 @@ class RayEvent {
251
253
// deconstructed. Otherwise we might have memory issues.
252
254
RayEvent (rpc::Event_Severity severity,
253
255
RayLogLevel log_severity,
254
- const std::string & label,
256
+ std::string label,
255
257
const char *file_name,
256
258
int line_number)
257
259
: severity_(severity),
258
260
log_severity_ (log_severity),
259
- label_(label),
261
+ label_(std::move( label) ),
260
262
file_name_(file_name),
261
263
line_number_(line_number) {}
262
264
@@ -296,15 +298,15 @@ class RayEvent {
296
298
297
299
~RayEvent ();
298
300
301
+ RayEvent (const RayEvent &event) = delete ;
302
+
303
+ const RayEvent &operator =(const RayEvent &event) = delete ;
304
+
299
305
private:
300
306
RayEvent () = default ;
301
307
302
308
void SendMessage (const std::string &message);
303
309
304
- RayEvent (const RayEvent &event) = delete ;
305
-
306
- const RayEvent &operator =(const RayEvent &event) = delete ;
307
-
308
310
// Only for test
309
311
static void SetLevel (const std::string &event_level);
310
312
// Only for test
@@ -331,13 +333,12 @@ using ExportEventDataPtr = std::variant<std::shared_ptr<rpc::ExportTaskEventData
331
333
class RayExportEvent {
332
334
public:
333
335
explicit RayExportEvent (ExportEventDataPtr event_data_ptr)
334
- : event_data_ptr_(event_data_ptr) {}
336
+ : event_data_ptr_(std::move( event_data_ptr) ) {}
335
337
336
338
~RayExportEvent ();
337
339
338
340
void SendEvent ();
339
341
340
- private:
341
342
RayExportEvent (const RayExportEvent &event) = delete ;
342
343
343
344
const RayExportEvent &operator =(const RayExportEvent &event) = delete ;
@@ -366,7 +367,7 @@ bool IsExportAPIEnabledSourceType(
366
367
// / \param emit_event_to_log_file if True, it will emit the event to the process log file
367
368
// / (e.g., gcs_server.out). Otherwise, event will only be recorded to the event log file.
368
369
// / \return void.
369
- void RayEventInit (const std::vector<SourceTypeVariant> source_types,
370
+ void RayEventInit (const std::vector<SourceTypeVariant> & source_types,
370
371
const absl::flat_hash_map<std::string, std::string> &custom_fields,
371
372
const std::string &log_dir,
372
373
const std::string &event_level = " warning" ,
@@ -376,7 +377,7 @@ void RayEventInit(const std::vector<SourceTypeVariant> source_types,
376
377
// / and has been separated out so RayEventInit can be called multiple times in
377
378
// / tests.
378
379
// / **Note**: This should only be called from tests.
379
- void RayEventInit_ (const std::vector<SourceTypeVariant> source_types,
380
+ void RayEventInit_ (const std::vector<SourceTypeVariant> & source_types,
380
381
const absl::flat_hash_map<std::string, std::string> &custom_fields,
381
382
const std::string &log_dir,
382
383
const std::string &event_level,
0 commit comments