mirror of
https://github.com/ocaml-tracing/ocaml-opentelemetry.git
synced 2026-03-09 12:23:32 -04:00
helpers for attributes
This commit is contained in:
parent
99d5ba78fc
commit
5d3fa1c8eb
1 changed files with 18 additions and 0 deletions
|
|
@ -317,6 +317,10 @@ module Conventions = struct
|
||||||
let name = "service.name"
|
let name = "service.name"
|
||||||
|
|
||||||
let namespace = "service.namespace"
|
let namespace = "service.namespace"
|
||||||
|
|
||||||
|
let instance_id = "service.instance.id"
|
||||||
|
|
||||||
|
let version = "service.version"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -383,6 +387,9 @@ module Globals = struct
|
||||||
(** Namespace for the service *)
|
(** Namespace for the service *)
|
||||||
let service_namespace = ref None
|
let service_namespace = ref None
|
||||||
|
|
||||||
|
(** Unique identifier for the service *)
|
||||||
|
let service_instance_id = ref None
|
||||||
|
|
||||||
let instrumentation_library =
|
let instrumentation_library =
|
||||||
default_instrumentation_library ~version:"0.1" ~name:"ocaml-opentelemetry"
|
default_instrumentation_library ~version:"0.1" ~name:"ocaml-opentelemetry"
|
||||||
()
|
()
|
||||||
|
|
@ -403,6 +410,10 @@ module Globals = struct
|
||||||
|> String.split_on_char ',' |> List.map parse_pair
|
|> String.split_on_char ',' |> List.map parse_pair
|
||||||
with _ -> []
|
with _ -> []
|
||||||
|
|
||||||
|
(** Add a global attribute *)
|
||||||
|
let add_global_attribute (key:string) (v:value) : unit =
|
||||||
|
global_attributes := _conv_key_value (key, v) :: !global_attributes
|
||||||
|
|
||||||
(* add global attributes to this list *)
|
(* add global attributes to this list *)
|
||||||
let merge_global_attributes_ into : _ list =
|
let merge_global_attributes_ into : _ list =
|
||||||
let not_redundant kv = List.for_all (fun kv' -> kv.key <> kv'.key) into in
|
let not_redundant kv = List.for_all (fun kv' -> kv.key <> kv'.key) into in
|
||||||
|
|
@ -415,6 +426,13 @@ module Globals = struct
|
||||||
~value:(Some (String_value service_name)) ()
|
~value:(Some (String_value service_name)) ()
|
||||||
:: l
|
:: l
|
||||||
in
|
in
|
||||||
|
let l =
|
||||||
|
match !service_instance_id with
|
||||||
|
| None -> l
|
||||||
|
| Some v ->
|
||||||
|
default_key_value ~key:Conventions.Attributes.Service.instance_id
|
||||||
|
~value:(Some (String_value v)) () :: l
|
||||||
|
in
|
||||||
let l =
|
let l =
|
||||||
match !service_namespace with
|
match !service_namespace with
|
||||||
| None -> l
|
| None -> l
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue