1
- #include " SensorClientFormatter .h"
1
+ #include " Formatter .h"
2
2
3
3
#include < uuid/uuid.h>
4
4
16
16
namespace collector ::output {
17
17
18
18
using SignalStreamMessage = sensor::SignalStreamMessage;
19
- using Signal = SensorClientFormatter ::Signal;
20
- using ProcessSignal = SensorClientFormatter ::ProcessSignal;
21
- using LineageInfo = SensorClientFormatter ::LineageInfo;
19
+ using Signal = Formatter ::Signal;
20
+ using ProcessSignal = Formatter ::ProcessSignal;
21
+ using LineageInfo = Formatter ::LineageInfo;
22
22
23
23
using Timestamp = google::protobuf::Timestamp;
24
24
using TimeUtil = google::protobuf::util::TimeUtil;
@@ -57,17 +57,17 @@ std::string extract_proc_args(sinsp_threadinfo* tinfo) {
57
57
58
58
} // namespace
59
59
60
- SensorClientFormatter::SensorClientFormatter (sinsp* inspector, const CollectorConfig& config)
60
+ Formatter::Formatter (sinsp* inspector, const CollectorConfig& config)
61
61
: event_names_(EventNames::GetInstance()),
62
62
event_extractor_ (std::make_unique<system_inspector::EventExtractor>()),
63
63
container_metadata_(inspector),
64
64
config_(config) {
65
65
event_extractor_->Init (inspector);
66
66
}
67
67
68
- SensorClientFormatter ::~SensorClientFormatter () = default ;
68
+ Formatter ::~Formatter () = default ;
69
69
70
- const sensor::ProcessSignal* SensorClientFormatter ::ToProtoMessage (sinsp_evt* event) {
70
+ const sensor::ProcessSignal* Formatter ::ToProtoMessage (sinsp_evt* event) {
71
71
if (process_signals[event->get_type ()] == ProcessSignalType::UNKNOWN_PROCESS_TYPE) {
72
72
return nullptr ;
73
73
}
@@ -82,7 +82,7 @@ const sensor::ProcessSignal* SensorClientFormatter::ToProtoMessage(sinsp_evt* ev
82
82
return CreateProcessSignal (event);
83
83
}
84
84
85
- const sensor::ProcessSignal* SensorClientFormatter ::ToProtoMessage (sinsp_threadinfo* tinfo) {
85
+ const sensor::ProcessSignal* Formatter ::ToProtoMessage (sinsp_threadinfo* tinfo) {
86
86
Reset ();
87
87
if (!ValidateProcessDetails (tinfo)) {
88
88
CLOG (INFO) << " Dropping process event: " << tinfo;
@@ -92,7 +92,7 @@ const sensor::ProcessSignal* SensorClientFormatter::ToProtoMessage(sinsp_threadi
92
92
return CreateProcessSignal (tinfo);
93
93
}
94
94
95
- ProcessSignal* SensorClientFormatter ::CreateProcessSignal (sinsp_evt* event) {
95
+ ProcessSignal* Formatter ::CreateProcessSignal (sinsp_evt* event) {
96
96
auto signal = AllocateRoot ();
97
97
98
98
// set id
@@ -174,7 +174,7 @@ ProcessSignal* SensorClientFormatter::CreateProcessSignal(sinsp_evt* event) {
174
174
return signal ;
175
175
}
176
176
177
- ProcessSignal* SensorClientFormatter ::CreateProcessSignal (sinsp_threadinfo* tinfo) {
177
+ ProcessSignal* Formatter ::CreateProcessSignal (sinsp_threadinfo* tinfo) {
178
178
auto signal = AllocateRoot ();
179
179
180
180
// set id
@@ -237,7 +237,7 @@ ProcessSignal* SensorClientFormatter::CreateProcessSignal(sinsp_threadinfo* tinf
237
237
return signal ;
238
238
}
239
239
240
- std::string SensorClientFormatter ::ToString (sinsp_evt* event) {
240
+ std::string Formatter ::ToString (sinsp_evt* event) {
241
241
std::stringstream ss;
242
242
const std::string* path = event_extractor_->get_exepath (event);
243
243
const std::string* name = event_extractor_->get_comm (event);
@@ -254,7 +254,7 @@ std::string SensorClientFormatter::ToString(sinsp_evt* event) {
254
254
return ss.str ();
255
255
}
256
256
257
- bool SensorClientFormatter ::ValidateProcessDetails (const sinsp_threadinfo* tinfo) {
257
+ bool Formatter ::ValidateProcessDetails (const sinsp_threadinfo* tinfo) {
258
258
if (tinfo == nullptr ) {
259
259
return false ;
260
260
}
@@ -266,11 +266,11 @@ bool SensorClientFormatter::ValidateProcessDetails(const sinsp_threadinfo* tinfo
266
266
return true ;
267
267
}
268
268
269
- bool SensorClientFormatter ::ValidateProcessDetails (sinsp_evt* event) {
269
+ bool Formatter ::ValidateProcessDetails (sinsp_evt* event) {
270
270
return ValidateProcessDetails (event->get_thread_info ());
271
271
}
272
272
273
- void SensorClientFormatter ::UpdateLineageStats (const std::vector<LineageInfo>& lineage) {
273
+ void Formatter ::UpdateLineageStats (const std::vector<LineageInfo>& lineage) {
274
274
int string_total = std::accumulate (lineage.cbegin (), lineage.cend (), 0 , [](int acc, const auto & l) {
275
275
return acc + l.parent_exec_file_path ().size ();
276
276
});
@@ -281,7 +281,7 @@ void SensorClientFormatter::UpdateLineageStats(const std::vector<LineageInfo>& l
281
281
COUNTER_ADD (CollectorStats::process_lineage_string_total, string_total);
282
282
}
283
283
284
- std::vector<LineageInfo> SensorClientFormatter ::GetProcessLineage (sinsp_threadinfo* tinfo) {
284
+ std::vector<LineageInfo> Formatter ::GetProcessLineage (sinsp_threadinfo* tinfo) {
285
285
std::vector<LineageInfo> lineage;
286
286
if (tinfo == nullptr ) {
287
287
return lineage;
0 commit comments