blob: 28adbaf41c20a99e50cc7a106c041cf11b87bfb5 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
#pragma once
#include <stdint.h>
#include "opentelemetry/nostd/span.h"
#include "opentelemetry/version.h"
#include "src/common/fast_random_number_generator.h"
OPENTELEMETRY_BEGIN_NAMESPACE
namespace sdk
{
namespace common
{
/**
* Utility methods for creating random data, based on a seeded thread-local
* number generator.
*/
class Random
{
public:
/**
* @return an unsigned 64 bit random number
*/
static uint64_t GenerateRandom64() noexcept;
/**
* Fill the passed span with random bytes.
*
* @param buffer A span of bytes.
*/
static void GenerateRandomBuffer(opentelemetry::nostd::span<uint8_t> buffer) noexcept;
private:
/**
* @return a seeded thread-local random number generator.
*/
static FastRandomNumberGenerator &GetRandomNumberGenerator() noexcept;
};
} // namespace common
} // namespace sdk
OPENTELEMETRY_END_NAMESPACE
|