LCOV - code coverage report
Current view: top level - source/extensions/tracers/zipkin - util.h (source / functions) Hit Total Coverage
Test: coverage.dat Lines: 0 7 0.0 %
Date: 2024-01-05 06:35:25 Functions: 0 4 0.0 %

          Line data    Source code
       1             : #pragma once
       2             : 
       3             : #include <string>
       4             : #include <vector>
       5             : 
       6             : #include "envoy/common/time.h"
       7             : 
       8             : #include "source/common/common/byte_order.h"
       9             : #include "source/common/protobuf/utility.h"
      10             : 
      11             : namespace Envoy {
      12             : namespace Extensions {
      13             : namespace Tracers {
      14             : namespace Zipkin {
      15             : 
      16             : /**
      17             :  * Utility class with a few convenient methods
      18             :  */
      19             : class Util {
      20             : public:
      21             :   /**
      22             :    * Returns a randomly-generated 64-bit integer number.
      23             :    */
      24             :   static uint64_t generateRandom64(TimeSource& time_source);
      25             : 
      26             :   /**
      27             :    * Returns byte string representation of a number.
      28             :    *
      29             :    * @param value Number that will be represented in byte string.
      30             :    * @return std::string byte string representation of a number.
      31             :    */
      32           0 :   template <typename Type> static std::string toByteString(Type value) {
      33           0 :     return {reinterpret_cast<const char*>(&value), sizeof(Type)};
      34           0 :   }
      35             : 
      36             :   /**
      37             :    * Returns big endian byte string representation of a number.
      38             :    *
      39             :    * @param value Number that will be represented in byte string.
      40             :    * @param flip indicates to flip order or not.
      41             :    * @return std::string byte string representation of a number.
      42             :    */
      43           0 :   template <typename Type> static std::string toBigEndianByteString(Type value) {
      44           0 :     auto bytes = toEndianness<ByteOrder::BigEndian>(value);
      45           0 :     return {reinterpret_cast<const char*>(&bytes), sizeof(Type)};
      46           0 :   }
      47             : 
      48             :   using Replacements = std::vector<std::pair<const std::string, const std::string>>;
      49             : 
      50             :   /**
      51             :    * Returns a wrapped uint64_t value as a string. In addition to that, it also pushes back a
      52             :    * replacement to the given replacements vector. The replacement includes the supplied name
      53             :    * as a key, for identification in a JSON stream.
      54             :    *
      55             :    * @param value unt64_t number that will be represented in string.
      56             :    * @param name std::string that is the key for the value being replaced.
      57             :    * @param replacements a container to hold the required replacements when serializing this value.
      58             :    * @return ProtobufWkt::Value wrapped uint64_t as a string.
      59             :    */
      60             :   static ProtobufWkt::Value uint64Value(uint64_t value, absl::string_view name,
      61             :                                         Replacements& replacements);
      62             : };
      63             : 
      64             : } // namespace Zipkin
      65             : } // namespace Tracers
      66             : } // namespace Extensions
      67             : } // namespace Envoy

Generated by: LCOV version 1.15