1 /*
2 * Copyright (c) 2021 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 #include "bytrace_hisysevent_parser.h"
17
18 namespace SysTuning {
19 namespace TraceStreamer {
BytraceHiSysEventParser(TraceDataCache * dataCache,const TraceStreamerFilters * filters)20 BytraceHiSysEventParser::BytraceHiSysEventParser(TraceDataCache* dataCache, const TraceStreamerFilters* filters)
21 : EventParserBase(dataCache, filters)
22 {
23 }
24
25 BytraceHiSysEventParser::~BytraceHiSysEventParser() = default;
ParseHiSysEventDataItem(const std::string & buffer,const uint64_t lineSeq,bool & haveSplitSeg)26 void BytraceHiSysEventParser::ParseHiSysEventDataItem(const std::string& buffer,
27 const uint64_t lineSeq,
28 bool& haveSplitSeg)
29 {
30 json jMessage;
31 if (!jMessage.accept(buffer)) {
32 return;
33 }
34 jMessage = json::parse(buffer);
35 streamFilters_->hiSysEventMeasureFilter_->FilterAllHiSysEvent(jMessage, lineSeq, haveSplitSeg);
36 return;
37 }
Finish()38 void BytraceHiSysEventParser::Finish()
39 {
40 auto startTime = streamFilters_->hiSysEventMeasureFilter_->GetPluginStartTime();
41 if (startTime != INVALID_UINT64) {
42 traceDataCache_->UpdateTraceTime(startTime);
43 }
44 auto endTime = streamFilters_->hiSysEventMeasureFilter_->GetPluginEndTime();
45 if (endTime != INVALID_UINT64) {
46 traceDataCache_->UpdateTraceTime(endTime);
47 }
48 }
49 } // namespace TraceStreamer
50 } // namespace SysTuning
51