Skip to content

fix: refactor multiline split state #1410

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Mar 29, 2024
15 changes: 15 additions & 0 deletions core/file_server/MultilineOptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,4 +181,19 @@ bool MultilineOptions::ParseRegex(const string& pattern, shared_ptr<boost::regex
return true;
}

const std::string&
UnmatchedContentTreatmentToString(MultilineOptions::UnmatchedContentTreatment unmatchedContentTreatment) {
switch (unmatchedContentTreatment) {
case MultilineOptions::UnmatchedContentTreatment::DISCARD:
static std::string discardStr = "discard";
return discardStr;
case MultilineOptions::UnmatchedContentTreatment::SINGLE_LINE:
static std::string singleLine = "single line";
return singleLine;
default:
static std::string unkonwn = "";
return unkonwn;
}
}

} // namespace logtail
2 changes: 2 additions & 0 deletions core/file_server/MultilineOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ class MultilineOptions {
bool mIsMultiline = false;
};

const std::string& UnmatchedContentTreatmentToString(MultilineOptions::UnmatchedContentTreatment unmatchedContentTreatment);

using MultilineConfig = std::pair<const MultilineOptions*, const PipelineContext*>;

} // namespace logtail
5 changes: 5 additions & 0 deletions core/monitor/MetricConstants.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ const std::string METRIC_PROC_PARSE_ERROR_TOTAL = "proc_parse_error_total";
const std::string METRIC_PROC_KEY_COUNT_NOT_MATCH_ERROR_TOTAL = "proc_key_count_not_match_error_total";
const std::string METRIC_PROC_HISTORY_FAILURE_TOTAL = "proc_history_failure_total";

const std::string METRIC_PROC_SPLIT_MULTILINE_LOG_SPLITTED_RECORDS_TOTAL
= "proc_split_multiline_log_splitted_records_total";
const std::string METRIC_PROC_SPLIT_MULTILINE_LOG_UNMATCHED_RECORDS_TOTAL
= "proc_split_multiline_log_unmatched_records_total";

// processor filter metrics
const std::string METRIC_PROC_FILTER_IN_SIZE_BYTES = "proc_filter_in_size_bytes";
const std::string METRIC_PROC_FILTER_OUT_SIZE_BYTES = "proc_filter_out_size_bytes";
Expand Down
2 changes: 2 additions & 0 deletions core/monitor/MetricConstants.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ extern const std::string METRIC_PROC_PARSE_OUT_SIZE_BYTES;
extern const std::string METRIC_PROC_PARSE_ERROR_TOTAL;
extern const std::string METRIC_PROC_KEY_COUNT_NOT_MATCH_ERROR_TOTAL;
extern const std::string METRIC_PROC_HISTORY_FAILURE_TOTAL;
extern const std::string METRIC_PROC_SPLIT_MULTILINE_LOG_SPLITTED_RECORDS_TOTAL;
extern const std::string METRIC_PROC_SPLIT_MULTILINE_LOG_UNMATCHED_RECORDS_TOTAL;

// processor filter metrics
extern const std::string METRIC_PROC_FILTER_IN_SIZE_BYTES;
Expand Down
4 changes: 2 additions & 2 deletions core/pipeline/Pipeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include "plugin/PluginRegistry.h"
#include "processor/ProcessorParseApsaraNative.h"
#include "processor/ProcessorSplitLogStringNative.h"
#include "processor/ProcessorSplitRegexNative.h"
#include "processor/ProcessorSplitMultilineLogStringNative.h"
#include "processor/ProcessorTagNative.h"
#include "processor/daemon/LogProcess.h"

Expand Down Expand Up @@ -113,7 +113,7 @@ bool Pipeline::Init(Config&& config) {
detail["SplitChar"] = Json::Value('\0');
detail["AppendingLogPositionMeta"] = Json::Value(inputFile->mFileReader.mAppendingLogPositionMeta);
} else if (inputFile->mMultiline.IsMultiline()) {
processor = PluginRegistry::GetInstance()->CreateProcessor(ProcessorSplitRegexNative::sName,
processor = PluginRegistry::GetInstance()->CreateProcessor(ProcessorSplitMultilineLogStringNative::sName,
to_string(++pluginIndex));
detail["Mode"] = Json::Value("custom");
detail["StartPattern"] = Json::Value(inputFile->mMultiline.mStartPattern);
Expand Down
4 changes: 2 additions & 2 deletions core/plugin/PluginRegistry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
#include "processor/ProcessorParseRegexNative.h"
#include "processor/ProcessorParseTimestampNative.h"
#include "processor/ProcessorSplitLogStringNative.h"
#include "processor/ProcessorSplitRegexNative.h"
#include "processor/ProcessorSplitMultilineLogStringNative.h"
#include "processor/ProcessorTagNative.h"
#if defined(__linux__) && !defined(__ANDROID__)
#include "processor/ProcessorSPL.h"
Expand Down Expand Up @@ -250,7 +250,7 @@ void PluginRegistry::LoadStaticPlugins() {
#endif

RegisterProcessorCreator(new StaticProcessorCreator<ProcessorSplitLogStringNative>());
RegisterProcessorCreator(new StaticProcessorCreator<ProcessorSplitRegexNative>());
RegisterProcessorCreator(new StaticProcessorCreator<ProcessorSplitMultilineLogStringNative>());
RegisterProcessorCreator(new StaticProcessorCreator<ProcessorParseApsaraNative>());
RegisterProcessorCreator(new StaticProcessorCreator<ProcessorParseDelimiterNative>());
RegisterProcessorCreator(new StaticProcessorCreator<ProcessorDesensitizeNative>());
Expand Down
Loading
Loading