mirror of
https://github.com/ocaml-tracing/ocaml-opentelemetry.git
synced 2026-03-08 03:47:59 -04:00
feat: opentelemetry.domain shim
This commit is contained in:
parent
abe022dbc0
commit
f55775a55c
3 changed files with 44 additions and 0 deletions
14
src/domain/dune
Normal file
14
src/domain/dune
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
(library
|
||||
(name opentelemetry_domain)
|
||||
(synopsis "Compatibility package for the Domain module for opentelemetry")
|
||||
(public_name opentelemetry.domain)
|
||||
(modules opentelemetry_domain))
|
||||
|
||||
(executable
|
||||
(modules gen)
|
||||
(name gen))
|
||||
|
||||
(rule
|
||||
(targets opentelemetry_domain.ml)
|
||||
(action
|
||||
(run ./gen.exe)))
|
||||
26
src/domain/gen.ml
Normal file
26
src/domain/gen.ml
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
let domain_4 =
|
||||
{|
|
||||
let cpu_relax = ignore
|
||||
let relax_loop : int -> unit = ignore
|
||||
|}
|
||||
|
||||
let domain_5 =
|
||||
{|
|
||||
let cpu_relax = Domain.cpu_relax
|
||||
let relax_loop i =
|
||||
for _j = 1 to i do cpu_relax () done
|
||||
|}
|
||||
|
||||
let write_file file s =
|
||||
let oc = open_out file in
|
||||
output_string oc s;
|
||||
close_out oc
|
||||
|
||||
let () =
|
||||
let version = Scanf.sscanf Sys.ocaml_version "%d.%d.%s" (fun x y _ -> x, y) in
|
||||
write_file "opentelemetry_domain.ml"
|
||||
(if version >= (5, 0) then
|
||||
domain_5
|
||||
else
|
||||
domain_4);
|
||||
()
|
||||
4
src/domain/opentelemetry_domain.mli
Normal file
4
src/domain/opentelemetry_domain.mli
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
val cpu_relax : unit -> unit
|
||||
|
||||
val relax_loop : int -> unit
|
||||
(** Call {!cpu_relax} n times *)
|
||||
Loading…
Add table
Reference in a new issue