1 /* 2 * Copyright (c) 2021-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 16 #ifndef HIVIEWDFX_HITRACE_ID_H 17 #define HIVIEWDFX_HITRACE_ID_H 18 19 #include "hitrace/hitracechainc.h" 20 21 #ifdef __cplusplus 22 23 namespace OHOS { 24 namespace HiviewDFX { 25 class HiTraceId final { 26 public: 27 HiTraceId(); 28 HiTraceId(const HiTraceIdStruct& id); 29 HiTraceId(const uint8_t* pIdArray, int len); 30 ~HiTraceId() = default; 31 32 bool IsValid() const; 33 bool IsFlagEnabled(HiTraceFlag flag) const; 34 void EnableFlag(HiTraceFlag flag); 35 int GetFlags() const; 36 void SetFlags(int flags); 37 uint64_t GetChainId() const; 38 void SetChainId(uint64_t chainId); 39 uint64_t GetSpanId() const; 40 void SetSpanId(uint64_t spanId); 41 uint64_t GetParentSpanId() const; 42 void SetParentSpanId(uint64_t parentSpanId); 43 int ToBytes(uint8_t* pIdArray, int len) const; 44 45 private: 46 HiTraceIdStruct id_; 47 friend class HiTraceChain; 48 }; 49 } // namespace HiviewDFX 50 } // namespace OHOS 51 52 #endif // __cplusplus 53 54 #endif // HIVIEWDFX_HITRACE_ID_H 55