mirror of
https://github.com/ocaml-tracing/ocaml-opentelemetry.git
synced 2026-03-07 18:37:56 -05:00
refactor: use _conv_key_value
This commit is contained in:
parent
69889a7b9a
commit
9ba57c5df1
1 changed files with 13 additions and 17 deletions
|
|
@ -183,15 +183,21 @@ end
|
|||
|
||||
type key_value = string * [`Int of int | `String of string | `Bool of bool | `None]
|
||||
|
||||
(**/**)
|
||||
let _conv_value =
|
||||
let open Proto.Common in
|
||||
function
|
||||
| `Int i -> Some (Int_value (Int64.of_int i))
|
||||
| `String s -> Some (String_value s)
|
||||
| `Bool b -> Some (Bool_value b)
|
||||
| `None -> None
|
||||
|
||||
(**/**)
|
||||
|
||||
(**/**)
|
||||
let _conv_key_value (k,v) =
|
||||
let open Proto.Common in
|
||||
let value = match v with
|
||||
| `Int i -> Some (Int_value (Int64.of_int i))
|
||||
| `String s -> Some (String_value s)
|
||||
| `Bool b -> Some (Bool_value b)
|
||||
| `None -> None
|
||||
in
|
||||
let value = _conv_value v in
|
||||
default_key_value ~key:k ~value ()
|
||||
|
||||
(**/**)
|
||||
|
|
@ -320,17 +326,7 @@ end = struct
|
|||
|
||||
let attributes =
|
||||
let open Proto.Common in
|
||||
let l = List.map
|
||||
(fun (k,v) ->
|
||||
let value = match v with
|
||||
| `Int i -> Some (Int_value (Int64.of_int i))
|
||||
| `String s -> Some (String_value s)
|
||||
| `Bool b -> Some (Bool_value b)
|
||||
| `None -> None
|
||||
in
|
||||
default_key_value ~key:k ~value ())
|
||||
attrs
|
||||
in
|
||||
let l = List.map _conv_key_value attrs in
|
||||
let l =
|
||||
default_key_value ~key:"service.name"
|
||||
~value:(Some (String_value service_name)) () :: l
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue