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<any>): StatListItem => { 19 info("Trace State Strategy data length is:", metricData.length) 20 let statListItems: Array<StatItem> = [] 21 for (let sqlIndex = 0; sqlIndex < metricData.length; sqlIndex++) { 22 let names = metricData[sqlIndex].event_name; 23 let counts = metricData[sqlIndex].count; 24 let sources = metricData[sqlIndex].source; 25 let severities = metricData[sqlIndex].serverity; 26 let statListItem: StatItem = { 27 name: names, 28 count: counts, 29 source: sources, 30 severity: severities 31 } 32 statListItems?.push(statListItem) 33 } 34 return { 35 stat: statListItems 36 } 37} 38 39export interface StatListItem { 40 stat: Array<StatItem> 41} 42 43export interface StatItem { 44 name: string 45 count: string 46 source: string 47 severity: string 48} 49