From b3c174d8e575864ef1feaa7128627ce26e15b4d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=84=E9=A3=8F?= Date: Wed, 27 Nov 2024 02:21:55 +0000 Subject: [PATCH] polish --- core/monitor/Monitor.cpp | 6 ++-- core/pipeline/plugin/PluginRegistry.cpp | 8 ++--- .../FlusherFile.cpp} | 30 +++++++++---------- .../FlusherLocalFile.h => file/FlusherFile.h} | 4 +-- ...torMetric.cpp => InputInternalMetrics.cpp} | 10 +++---- ...MonitorMetric.h => InputInternalMetrics.h} | 2 +- 6 files changed, 30 insertions(+), 30 deletions(-) rename core/plugin/flusher/{local_file/FlusherLocalFile.cpp => file/FlusherFile.cpp} (80%) rename core/plugin/flusher/{local_file/FlusherLocalFile.h => file/FlusherFile.h} (95%) rename core/plugin/input/{InputSelfMonitorMetric.cpp => InputInternalMetrics.cpp} (86%) rename core/plugin/input/{InputSelfMonitorMetric.h => InputInternalMetrics.h} (96%) diff --git a/core/monitor/Monitor.cpp b/core/monitor/Monitor.cpp index 4e8d47938f..21a51952de 100644 --- a/core/monitor/Monitor.cpp +++ b/core/monitor/Monitor.cpp @@ -767,7 +767,7 @@ const string LoongCollectorMonitor::GetInnerSelfMonitorMetricPipeline() { { "inputs": [ { - "Type": "input_self_monitor_metric", + "Type": "input_internal_metrics", "Agent": { "Enable": false, "Interval": 1 @@ -796,8 +796,8 @@ const string LoongCollectorMonitor::GetInnerSelfMonitorMetricPipeline() { ], "flushers": [ { - "Type": "flusher_local_file", - "FileName": "./log/self_metrics.log" + "Type": "flusher_file", + "FilePath": "./log/self_metrics.log" } ] } diff --git a/core/pipeline/plugin/PluginRegistry.cpp b/core/pipeline/plugin/PluginRegistry.cpp index 4b0f5c1c27..bf0d7acbe6 100644 --- a/core/pipeline/plugin/PluginRegistry.cpp +++ b/core/pipeline/plugin/PluginRegistry.cpp @@ -26,17 +26,17 @@ #include "app_config/AppConfig.h" #include "common/Flags.h" #include "plugin/flusher/blackhole/FlusherBlackHole.h" -#include "plugin/flusher/local_file/FlusherLocalFile.h" +#include "plugin/flusher/file/FlusherFile.h" #include "plugin/flusher/sls/FlusherSLS.h" #include "plugin/input/InputContainerStdio.h" #include "plugin/input/InputFile.h" #include "plugin/input/InputPrometheus.h" #if defined(__linux__) && !defined(__ANDROID__) #include "plugin/input/InputFileSecurity.h" +#include "plugin/input/InputInternalMetrics.h" #include "plugin/input/InputNetworkObserver.h" #include "plugin/input/InputNetworkSecurity.h" #include "plugin/input/InputProcessSecurity.h" -#include "plugin/input/InputSelfMonitorMetric.h" #endif #include "logger/Logger.h" #include "pipeline/plugin/creator/CProcessor.h" @@ -127,7 +127,7 @@ bool PluginRegistry::IsValidNativeFlusherPlugin(const string& name) const { void PluginRegistry::LoadStaticPlugins() { RegisterInputCreator(new StaticInputCreator()); RegisterInputCreator(new StaticInputCreator()); - RegisterInputCreator(new StaticInputCreator()); + RegisterInputCreator(new StaticInputCreator()); #if defined(__linux__) && !defined(__ANDROID__) RegisterInputCreator(new StaticInputCreator()); RegisterInputCreator(new StaticInputCreator()); @@ -159,7 +159,7 @@ void PluginRegistry::LoadStaticPlugins() { RegisterFlusherCreator(new StaticFlusherCreator()); RegisterFlusherCreator(new StaticFlusherCreator()); - RegisterFlusherCreator(new StaticFlusherCreator()); + RegisterFlusherCreator(new StaticFlusherCreator()); } void PluginRegistry::LoadDynamicPlugins(const set& plugins) { diff --git a/core/plugin/flusher/local_file/FlusherLocalFile.cpp b/core/plugin/flusher/file/FlusherFile.cpp similarity index 80% rename from core/plugin/flusher/local_file/FlusherLocalFile.cpp rename to core/plugin/flusher/file/FlusherFile.cpp index ff1f26f932..73eb646547 100644 --- a/core/plugin/flusher/local_file/FlusherLocalFile.cpp +++ b/core/plugin/flusher/file/FlusherFile.cpp @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "plugin/flusher/local_file/FlusherLocalFile.h" +#include "plugin/flusher/file/FlusherFile.h" #include #include @@ -24,16 +24,16 @@ using namespace std; namespace logtail { -const string FlusherLocalFile::sName = "flusher_local_file"; +const string FlusherFile::sName = "flusher_file"; -bool FlusherLocalFile::Init(const Json::Value& config, Json::Value& optionalGoPipeline) { +bool FlusherFile::Init(const Json::Value& config, Json::Value& optionalGoPipeline) { static uint32_t cnt = 0; GenerateQueueKey(to_string(++cnt)); SenderQueueManager::GetInstance()->CreateQueue(mQueueKey, mPluginID, *mContext); string errorMsg; - // FileName - if (!GetMandatoryStringParam(config, "FileName", mFileName, errorMsg)) { + // FilePath + if (!GetMandatoryStringParam(config, "FilePath", mFilePath, errorMsg)) { PARAM_ERROR_RETURN(mContext->GetLogger(), mContext->GetAlarm(), errorMsg, @@ -44,14 +44,14 @@ bool FlusherLocalFile::Init(const Json::Value& config, Json::Value& optionalGoPi mContext->GetRegion()); } // Pattern - GetMandatoryStringParam(config, "Pattern", mPattern, errorMsg); + // GetMandatoryStringParam(config, "Pattern", mPattern, errorMsg); // MaxFileSize - GetMandatoryUIntParam(config, "MaxFileSize", mMaxFileSize, errorMsg); + // GetMandatoryUIntParam(config, "MaxFileSize", mMaxFileSize, errorMsg); // MaxFiles - GetMandatoryUIntParam(config, "MaxFiles", mMaxFileSize, errorMsg); + // GetMandatoryUIntParam(config, "MaxFiles", mMaxFileSize, errorMsg); // create file writer - auto file_sink = std::make_shared(mFileName, mMaxFileSize, mMaxFiles, true); + auto file_sink = std::make_shared(mFilePath, mMaxFileSize, mMaxFiles, true); mFileWriter = std::make_shared( sName, file_sink, spdlog::thread_pool(), spdlog::async_overflow_policy::block); mFileWriter->set_pattern(mPattern); @@ -62,7 +62,7 @@ bool FlusherLocalFile::Init(const Json::Value& config, Json::Value& optionalGoPi return true; } -bool FlusherLocalFile::Send(PipelineEventGroup&& g) { +bool FlusherFile::Send(PipelineEventGroup&& g) { if (g.IsReplay()) { return SerializeAndPush(std::move(g)); } else { @@ -72,19 +72,19 @@ bool FlusherLocalFile::Send(PipelineEventGroup&& g) { } } -bool FlusherLocalFile::Flush(size_t key) { +bool FlusherFile::Flush(size_t key) { BatchedEventsList res; mBatcher.FlushQueue(key, res); return SerializeAndPush(std::move(res)); } -bool FlusherLocalFile::FlushAll() { +bool FlusherFile::FlushAll() { vector res; mBatcher.FlushAll(res); return SerializeAndPush(std::move(res)); } -bool FlusherLocalFile::SerializeAndPush(PipelineEventGroup&& group) { +bool FlusherFile::SerializeAndPush(PipelineEventGroup&& group) { string serializedData, errorMsg; BatchedEvents g(std::move(group.MutableEvents()), std::move(group.GetSizedTags()), @@ -101,7 +101,7 @@ bool FlusherLocalFile::SerializeAndPush(PipelineEventGroup&& group) { return true; } -bool FlusherLocalFile::SerializeAndPush(BatchedEventsList&& groupList) { +bool FlusherFile::SerializeAndPush(BatchedEventsList&& groupList) { string serializedData; for (auto& group : groupList) { string errorMsg; @@ -116,7 +116,7 @@ bool FlusherLocalFile::SerializeAndPush(BatchedEventsList&& groupList) { return true; } -bool FlusherLocalFile::SerializeAndPush(vector&& groupLists) { +bool FlusherFile::SerializeAndPush(vector&& groupLists) { for (auto& groupList : groupLists) { SerializeAndPush(std::move(groupList)); } diff --git a/core/plugin/flusher/local_file/FlusherLocalFile.h b/core/plugin/flusher/file/FlusherFile.h similarity index 95% rename from core/plugin/flusher/local_file/FlusherLocalFile.h rename to core/plugin/flusher/file/FlusherFile.h index b9f891318b..0f8e706ac5 100644 --- a/core/plugin/flusher/local_file/FlusherLocalFile.h +++ b/core/plugin/flusher/file/FlusherFile.h @@ -26,7 +26,7 @@ namespace logtail { -class FlusherLocalFile : public Flusher { +class FlusherFile : public Flusher { public: static const std::string sName; @@ -42,7 +42,7 @@ class FlusherLocalFile : public Flusher { bool SerializeAndPush(std::vector&& groupLists); std::shared_ptr mFileWriter; - std::string mFileName; + std::string mFilePath; std::string mPattern = "%v"; uint32_t mMaxFileSize = 1024 * 1024 * 10; uint32_t mMaxFiles = 10; diff --git a/core/plugin/input/InputSelfMonitorMetric.cpp b/core/plugin/input/InputInternalMetrics.cpp similarity index 86% rename from core/plugin/input/InputSelfMonitorMetric.cpp rename to core/plugin/input/InputInternalMetrics.cpp index 3633ff8444..01f77c62b1 100644 --- a/core/plugin/input/InputSelfMonitorMetric.cpp +++ b/core/plugin/input/InputInternalMetrics.cpp @@ -14,11 +14,11 @@ * limitations under the License. */ -#include "plugin/input/InputSelfMonitorMetric.h" +#include "plugin/input/InputInternalMetrics.h" namespace logtail { -const std::string InputSelfMonitorMetric::sName = "input_self_monitor_metric"; +const std::string InputInternalMetrics::sName = "input_internal_metrics"; bool GetEnabled(const Json::Value& rule) { if (rule.isMember("Enable") && rule["Enable"].isBool()) @@ -39,7 +39,7 @@ void ParseSelfMonitorMetricRule(std::string&& ruleKey, const Json::Value& ruleJs } } -bool InputSelfMonitorMetric::Init(const Json::Value& config, Json::Value& optionalGoPipeline) { +bool InputInternalMetrics::Init(const Json::Value& config, Json::Value& optionalGoPipeline) { ParseSelfMonitorMetricRule("Agent", config, mSelfMonitorMetricRules.mAgentMetricsRule); ParseSelfMonitorMetricRule("Runner", config, mSelfMonitorMetricRules.mRunnerMetricsRule); ParseSelfMonitorMetricRule("Pipeline", config, mSelfMonitorMetricRules.mPipelineMetricsRule); @@ -49,12 +49,12 @@ bool InputSelfMonitorMetric::Init(const Json::Value& config, Json::Value& option return true; } -bool InputSelfMonitorMetric::Start() { +bool InputInternalMetrics::Start() { SelfMonitorServer::GetInstance()->UpdateMetricPipeline(mContext, &mSelfMonitorMetricRules); return true; } -bool InputSelfMonitorMetric::Stop(bool isPipelineRemoving) { +bool InputInternalMetrics::Stop(bool isPipelineRemoving) { if (isPipelineRemoving) { SelfMonitorServer::GetInstance()->RemoveMetricPipeline(); } diff --git a/core/plugin/input/InputSelfMonitorMetric.h b/core/plugin/input/InputInternalMetrics.h similarity index 96% rename from core/plugin/input/InputSelfMonitorMetric.h rename to core/plugin/input/InputInternalMetrics.h index 85740e389f..694edf85af 100644 --- a/core/plugin/input/InputSelfMonitorMetric.h +++ b/core/plugin/input/InputInternalMetrics.h @@ -21,7 +21,7 @@ namespace logtail { -class InputSelfMonitorMetric : public Input { +class InputInternalMetrics : public Input { public: static const std::string sName;