1/* 2 * Copyright (C) 2022 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 16import { info } from '../../../log/Log.js'; 17 18export const initTraceStateStrategy = (metricData: Array<{ 19 event_name: string; 20 stat_type: string; 21 count: number; 22 source: string; 23 serverity: string; 24}>): StatListItem => { 25 info('Trace State Strategy data length is:', metricData.length); 26 let statListItems: Array<StatItem> = []; 27 for (let sqlIndex = 0; sqlIndex < metricData.length; sqlIndex++) { 28 let names = metricData[sqlIndex].event_name; 29 let counts = metricData[sqlIndex].count; 30 let sources = metricData[sqlIndex].source; 31 let severities = metricData[sqlIndex].serverity; 32 let statListItem: StatItem = { 33 name: names, 34 count: counts, 35 source: sources, 36 severity: severities, 37 }; 38 statListItems?.push(statListItem); 39 } 40 return { 41 stat: statListItems, 42 }; 43}; 44 45export interface StatListItem { 46 stat: Array<StatItem>; 47} 48 49export interface StatItem { 50 name: string; 51 count: number; 52 source: string; 53 severity: string; 54} 55