1
#include "source/extensions/tracers/zipkin/util.h"
2

            
3
#include <chrono>
4
#include <random>
5
#include <regex>
6

            
7
#include "source/common/common/hex.h"
8
#include "source/common/common/utility.h"
9

            
10
#include "absl/strings/str_cat.h"
11
#include "absl/strings/str_join.h"
12

            
13
namespace Envoy {
14
namespace Extensions {
15
namespace Tracers {
16
namespace Zipkin {
17

            
18
30
uint64_t Util::generateRandom64(TimeSource& time_source) {
19
30
  uint64_t seed = std::chrono::duration_cast<std::chrono::nanoseconds>(
20
30
                      time_source.systemTime().time_since_epoch())
21
30
                      .count();
22
30
  std::mt19937_64 rand_64(seed);
23
30
  return rand_64();
24
30
}
25

            
26
Protobuf::Value Util::uint64Value(uint64_t value, absl::string_view name,
27
92
                                  Replacements& replacements) {
28
92
  const std::string string_value = std::to_string(value);
29
92
  replacements.push_back({absl::StrCat("\"", name, "\":\"", string_value, "\""),
30
92
                          absl::StrCat("\"", name, "\":", string_value)});
31
92
  return ValueUtil::stringValue(string_value);
32
92
}
33

            
34
} // namespace Zipkin
35
} // namespace Tracers
36
} // namespace Extensions
37
} // namespace Envoy