diff --git a/collector/lib/CollectionMethod.cpp b/collector/lib/CollectionMethod.cpp index c7d37bc282..211f99b75d 100644 --- a/collector/lib/CollectionMethod.cpp +++ b/collector/lib/CollectionMethod.cpp @@ -2,23 +2,26 @@ #include +#include + +#include "Logging.h" + namespace collector { std::ostream& operator<<(std::ostream& os, CollectionMethod method) { + return os << CollectionMethodName(method); +} + +const char* CollectionMethodName(CollectionMethod method) { switch (method) { case CollectionMethod::EBPF: - return os << "ebpf"; + return "ebpf"; case CollectionMethod::CORE_BPF: - return os << "core_bpf"; + return "core_bpf"; default: - return os << "unknown(" << static_cast(method) << ")"; + CLOG(WARNING) << "Unexpected CollectionMethod: " << static_cast(method); + return "unknown"; } } -std::string CollectionMethodName(CollectionMethod method) { - std::stringstream ss; - ss << method; - return ss.str(); -} - } // namespace collector diff --git a/collector/lib/CollectionMethod.h b/collector/lib/CollectionMethod.h index 62570fd124..1a290a7dc9 100644 --- a/collector/lib/CollectionMethod.h +++ b/collector/lib/CollectionMethod.h @@ -11,7 +11,7 @@ enum class CollectionMethod : uint8_t { std::ostream& operator<<(std::ostream& os, CollectionMethod method); -std::string CollectionMethodName(CollectionMethod method); +const char* CollectionMethodName(CollectionMethod method); } // namespace collector diff --git a/collector/lib/CollectorService.cpp b/collector/lib/CollectorService.cpp index 2f83e10a28..4b41300d9d 100644 --- a/collector/lib/CollectorService.cpp +++ b/collector/lib/CollectorService.cpp @@ -150,7 +150,7 @@ bool CollectorService::WaitForGRPCServer() { bool SetupKernelDriver(CollectorService& collector, const std::string& GRPCServer, const CollectorConfig& config) { auto& startup_diagnostics = StartupDiagnostics::GetInstance(); - std::string cm_name = CollectionMethodName(config.GetCollectionMethod()); + std::string cm_name(CollectionMethodName(config.GetCollectionMethod())); startup_diagnostics.DriverAvailable(cm_name);