* Copyright (c) 2024 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef HISYSEVENT_INTERFACE_ENCODE_INCLUDE_RAW_BASE_DEF_H
#define HISYSEVENT_INTERFACE_ENCODE_INCLUDE_RAW_BASE_DEF_H
#include <cstdarg>
#include <cstddef>
#include <cstdint>
#include <string>
#include "def.h"
namespace OHOS {
namespace HiviewDFX {
namespace Encoded {
constexpr char BASE_INFO_KEY_DOMAIN[] = "domain_";
constexpr char BASE_INFO_KEY_NAME[] = "name_";
constexpr char BASE_INFO_KEY_TYPE[] = "type_";
constexpr char BASE_INFO_KEY_TIME_STAMP[] = "time_";
constexpr char BASE_INFO_KEY_TIME_ZONE[] = "tz_";
constexpr char BASE_INFO_KEY_ID[] = "id_";
constexpr char BASE_INFO_KEY_PID[] = "pid_";
constexpr char BASE_INFO_KEY_TID[] = "tid_";
constexpr char BASE_INFO_KEY_UID[] = "uid_";
constexpr char BASE_INFO_KEY_TRACE_ID[] = "traceid_";
constexpr char BASE_INFO_KEY_SPAN_ID[] = "spanid_";
constexpr char BASE_INFO_KEY_PARENT_SPAN_ID[] = "pspanid_";
constexpr char BASE_INFO_KEY_TRACE_FLAG[] = "trace_flag_";
#pragma pack(1)
struct HiSysEventHeader {
char domain[MAX_DOMAIN_LENGTH + 1];
char name[MAX_EVENT_NAME_LENGTH + 1];
uint64_t timestamp;
uint8_t timeZone;
uint32_t uid;
uint32_t pid;
uint32_t tid;
uint64_t id;
uint8_t type : 2;
uint8_t isTraceOpened : 1;
};
struct TraceInfo {
uint8_t traceFlag;
uint64_t traceId;
uint32_t spanId;
uint32_t pSpanId;
};
struct ParamValueType {
uint8_t isArray : 1;
uint8_t valueType : 4;
uint8_t valueByteCnt : 3;
};
#pragma pack()
enum ValueType: uint8_t {
UNKNOWN = 0,
BOOL,
INT8,
UINT8,
INT16,
UINT16,
INT32,
UINT32,
INT64,
UINT64,
FLOAT,
DOUBLE,
STRING,
};
enum EncodeType: int8_t {
VARINT = 0,
LENGTH_DELIMITED = 1,
INVALID = 4,
};
int ParseTimeZone(long tzVal);
}
}
}
#endif