Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions ocaml/tests/test_observer.ml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ module TracerProvider = struct
; "xs.host.name"
; "xs.host.uuid"
; "xs.observer.name"
; "xs.observer.uuid"
; "service.name"
]

Expand Down Expand Up @@ -301,6 +302,7 @@ let verify_json_fields_and_values ~json =
, `Assoc
[
("xs.pool.uuid", `String _)
; ("xs.observer.uuid", `String _)
; ("xs.observer.name", `String "test-observer")
; ("xs.host.uuid", `String _)
; ("xs.host.name", `String _)
Expand Down
15 changes: 8 additions & 7 deletions ocaml/xapi/xapi_observer.ml
Original file line number Diff line number Diff line change
Expand Up @@ -245,16 +245,19 @@ module Xapi_cluster = struct
end
end

let default_attributes ~__context ~host ~name_label ~component =
let default_attributes ~__context ~host ~observer ~component =
let pool = Helpers.get_pool ~__context in
let host_label = Db.Host.get_name_label ~__context ~self:host in
let host_uuid = Db.Host.get_uuid ~__context ~self:host in
let pool_uuid = Db.Pool.get_uuid ~__context ~self:pool in
let name_label = Db.Observer.get_name_label ~__context ~self:observer in
let observer_uuid = Db.Observer.get_uuid ~__context ~self:observer in
[
("xs.pool.uuid", pool_uuid)
; ("xs.host.name", host_label)
; ("xs.host.uuid", host_uuid)
; ("xs.observer.name", name_label)
; ("xs.observer.uuid", observer_uuid)
; ("service.name", to_string component)
]

Expand Down Expand Up @@ -289,13 +292,12 @@ module ObserverConfig = struct
from and updated instead of being regenerated. *)
let endpoints = Db.Observer.get_endpoints ~__context ~self:observer in
let host = Helpers.get_localhost ~__context in
let name_label = Db.Observer.get_name_label ~__context ~self:observer in
{
otel_service_name= to_string component
; otel_resource_attributes=
attributes_to_W3CBaggage
(Db.Observer.get_attributes ~__context ~self:observer
@ default_attributes ~__context ~host ~name_label ~component
@ default_attributes ~__context ~host ~observer ~component
)
; xs_exporter_zipkin_endpoints= zipkin_endpoints endpoints
; xs_exporter_bugtool_endpoint= bugtool_endpoint endpoints
Expand Down Expand Up @@ -513,11 +515,11 @@ let assert_valid_attributes attributes =
attributes

let register_component ~__context ~self ~host ~component =
let name_label = Db.Observer.get_name_label ~__context ~self in
let attributes =
default_attributes ~__context ~host ~name_label ~component
default_attributes ~__context ~host ~observer:self ~component
@ Db.Observer.get_attributes ~__context ~self
in
let name_label = Db.Observer.get_name_label ~__context ~self in
let uuid = Db.Observer.get_uuid ~__context ~self in
let endpoints = Db.Observer.get_endpoints ~__context ~self in
let enabled = Db.Observer.get_enabled ~__context ~self in
Expand Down Expand Up @@ -691,14 +693,13 @@ let set_attributes ~__context ~self ~value =
assert_valid_attributes value ;
let uuid = Db.Observer.get_uuid ~__context ~self in
let host = Helpers.get_localhost ~__context in
let name_label = Db.Observer.get_name_label ~__context ~self in
let observation_fn () =
List.iter
(fun c ->
let module Forwarder = (val get_forwarder c : ObserverInterface) in
Forwarder.set_attributes ~__context ~uuid
~attributes:
(default_attributes ~__context ~host ~name_label ~component:c
(default_attributes ~__context ~host ~observer:self ~component:c
@ value
)
)
Expand Down
Loading