Skip to content

Commit

Permalink
Switch around CollectionMethodName for simplicity
Browse files Browse the repository at this point in the history
  • Loading branch information
Stringy committed Aug 2, 2024
1 parent c1444ad commit cf8912d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
21 changes: 12 additions & 9 deletions collector/lib/CollectionMethod.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,26 @@

#include <sstream>

#include <sys/types.h>

#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<uint8_t>(method) << ")";
CLOG(WARNING) << "Unexpected CollectionMethod: " << static_cast<uint8_t>(method);
return "unknown";
}
}

std::string CollectionMethodName(CollectionMethod method) {
std::stringstream ss;
ss << method;
return ss.str();
}

} // namespace collector
2 changes: 1 addition & 1 deletion collector/lib/CollectionMethod.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion collector/lib/CollectorService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit cf8912d

Please sign in to comment.