Skip to content

Commit

Permalink
fixup! CP-48195: Set Tracing.observe default to false
Browse files Browse the repository at this point in the history
Signed-off-by: Gabriel Buica <[email protected]>
  • Loading branch information
GabrielBuica committed Apr 29, 2024
1 parent 6351706 commit 1c14e7c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 18 deletions.
26 changes: 11 additions & 15 deletions ocaml/libs/tracing/tracing.ml
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,6 @@ let observe = Atomic.make false

let set_observe = Atomic.set observe

let get_observe () = Atomic.get observe

module SpanKind = struct
type t = Server | Consumer | Client | Producer | Internal [@@deriving rpcty]

Expand Down Expand Up @@ -563,20 +561,18 @@ let set ?enabled ?attributes ?endpoints ~uuid () =
failwith
(Printf.sprintf "The TracerProvider : %s does not exist" uuid)
in
Hashtbl.replace tracer_providers uuid provider
) ;
if
List.for_all
(fun provider -> not provider.TracerProvider.enabled)
(get_tracer_providers ())
then (
set_observe false ;
Xapi_stdext_threads.Threadext.Mutex.execute Spans.lock (fun () ->
Hashtbl.replace tracer_providers uuid provider ;
if
List.for_all
(fun provider -> not provider.TracerProvider.enabled)
(get_tracer_providers ())
then (
set_observe false ;
Hashtbl.clear Spans.spans ;
Hashtbl.clear Spans.finished_spans
)
) else if not (get_observe ()) then
set_observe true
) else
set_observe true
)

let create ~enabled ~attributes ~endpoints ~name_label ~uuid =
let endpoints = List.map endpoint_of_string endpoints in
Expand Down Expand Up @@ -618,7 +614,7 @@ let enable_span_garbage_collector ?(timeout = 86400.) () =
Spans.GC.initialise_thread ~timeout

let with_tracing ?(attributes = []) ?(parent = None) ~name f =
if not (get_observe ()) then
if not (Atomic.get observe) then
f None
else
let tracer = get_tracer ~name in
Expand Down
2 changes: 0 additions & 2 deletions ocaml/libs/tracing/tracing.mli
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,6 @@ val with_tracing :

val set_observe : bool -> unit

val get_observe : unit -> bool

val validate_attribute : string * string -> bool

(** [EnvHelpers] module is a helper module for the tracing library to easily
Expand Down
2 changes: 1 addition & 1 deletion ocaml/xapi/xapi_observer.ml
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ module Dom0ObserverConfig (ObserverComponent : OBSERVER_COMPONENT) :

let update_config ~__context ~observer ~uuid =
if Db.Observer.get_enabled ~__context ~self:observer then (
if not (Tracing.get_observe ()) then Tracing.set_observe true ;
Tracing.set_observe true ;
let observer_config =
ObserverConfig.config_of_observer ~__context
~component:ObserverComponent.component ~observer
Expand Down

0 comments on commit 1c14e7c

Please sign in to comment.