sync code

This commit is contained in:
Ned Wright
2025-08-08 11:06:28 +00:00
parent dd19bf6158
commit da20943c09
145 changed files with 4157 additions and 1016 deletions

View File

@@ -37,6 +37,7 @@ FogStream::sendLog(const Report &log)
ScopedContext ctx;
ctx.registerValue<bool>("Obfuscate log field", true);
dbgTrace(D_REPORT) << "Sending log to fog";
LogRest rest(log);
i_msg->sendAsyncMessage(HTTPMethod::POST, fog_log_uri, rest, MessageCategory::LOG);
}

View File

@@ -14,15 +14,23 @@
#include "log_generator.h"
using namespace std;
USE_DEBUG_FLAG(D_LOGGING);
extern const string unnamed_service;
LogGen::~LogGen()
{
try {
if (send_log) Singleton::Consume<I_Logging>::by<LogGen>()->sendLog(log);
if (send_log) {
dbgTrace(D_LOGGING) << "sending log";
Singleton::Consume<I_Logging>::by<LogGen>()->sendLog(log);
} else {
dbgTrace(D_LOGGING) << "not sending log";
}
} catch (...) {
dbgWarning(D_LOGGING) << "Failed to send log";
}
}
LogGen &

View File

@@ -157,7 +157,7 @@ protected:
private:
void init();
void sendLog(const std::vector<char> &data);
void sendLogData(const std::vector<char> &data);
I_MainLoop::RoutineID log_send_routine = -1;
};

View File

@@ -162,11 +162,17 @@ public:
sendLog(const Report &log) override
{
if (getConf("agent.config.log.useBulkMode", "Enable bulk of logs", true)) {
dbgTrace(D_REPORT) << "Adding log to bulk";
reports.setBulkSize(getConfigurationWithDefault<uint>(100, "Logging", "Sent log bulk size"));
reports.push(log);
if (reports.sizeQueue() >= 4) {
auto persistence_only = getConf("agent.config.log.skip.enable", "Enable Log skipping", true);
sendBufferedLogsImpl(false, persistence_only);
dbgTrace(D_REPORT)
<< "Sending buffered logs from queue size: "
<< reports.sizeQueue()
<< ", persistence_only: "
<< persistence_only;
sendBufferedLogsImpl(false, persistence_only);
}
} else {
LogEventLogsSent(true).notify();
@@ -230,10 +236,22 @@ private:
for (auto &iter : local_streams) {
LogBulkRest sub_batch;
for (const auto &log : batch) {
if (log.isStreamActive(iter.first)) sub_batch.push(log);
if (log.isStreamActive(iter.first)) {
dbgTrace(D_REPORT)
<< "stream: "
<< (int) iter.first
<< " is active. adding log to sub-batch";
sub_batch.push(log);
}
}
if (sub_batch.size()) {
dbgTrace(D_REPORT)
<< "Sending log to stream: "
<< (int) iter.first
<< ", batch size: "
<< sub_batch.size();
iter.second->sendLog(sub_batch, persistence_only);
if (is_async) i_mainloop->yield();
}

View File

@@ -55,13 +55,13 @@ SyslogStream::sendLog(const Report &log)
vector<char> data(syslog_report.begin(), syslog_report.end());
log_send_routine = mainloop->addOneTimeRoutine(
I_MainLoop::RoutineType::Offline,
[this, data] () { sendLog(data); },
[this, data] () { sendLogData(data); },
"Logging Syslog stream messaging"
);
}
void
SyslogStream::sendLog(const vector<char> &data)
SyslogStream::sendLogData(const vector<char> &data)
{
dbgTrace(D_REPORT) << "Sending Syslog log." << " Max logs per send: " << max_logs_per_send;
sendLogWithQueue(data);