package opentelemetry

  1. Overview
  2. Docs
Instrumentation for https://opentelemetry.io

Install

dune-project
 Dependency

Authors

Maintainers

Sources

opentelemetry-0.12.tbz
sha256=ca92e7395495f73b46316607c514ce0dbe5fab129dddd9a17b353f835dcbf77d
sha512=ea2afd07c8db955364681f90388959db97d7b7f5b0836bc4045eca929968d6d77905e3aa66802226c0791c2552d0e281bdf2dbfe7ed90e9877ce3cedc343823f

doc/src/opentelemetry/rand_bytes.ml.html

Source file rand_bytes.ml

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
(* generate random IDs *)
let rand_ = Random.State.make_self_init ()

let ( let@ ) = ( @@ )

let default_rand_bytes_8 () : bytes =
  let@ () = Lock.with_lock in
  let b = Bytes.create 8 in
  for i = 0 to 1 do
    let r = Random.State.bits rand_ in
    (* 30 bits, of which we use 24 *)
    Bytes.set b (i * 3) (Char.chr (r land 0xff));
    Bytes.set b ((i * 3) + 1) (Char.chr ((r lsr 8) land 0xff));
    Bytes.set b ((i * 3) + 2) (Char.chr ((r lsr 16) land 0xff))
  done;
  let r = Random.State.bits rand_ in
  Bytes.set b 6 (Char.chr (r land 0xff));
  Bytes.set b 7 (Char.chr ((r lsr 8) land 0xff));
  b

let default_rand_bytes_16 () : bytes =
  let@ () = Lock.with_lock in
  let b = Bytes.create 16 in
  for i = 0 to 4 do
    let r = Random.State.bits rand_ in
    (* 30 bits, of which we use 24 *)
    Bytes.set b (i * 3) (Char.chr (r land 0xff));
    Bytes.set b ((i * 3) + 1) (Char.chr ((r lsr 8) land 0xff));
    Bytes.set b ((i * 3) + 2) (Char.chr ((r lsr 16) land 0xff))
  done;
  let r = Random.State.bits rand_ in
  Bytes.set b 15 (Char.chr (r land 0xff));
  (* last byte *)
  b

let rand_bytes_16 = ref default_rand_bytes_16

let rand_bytes_8 = ref default_rand_bytes_8