Skip to content

Commit 1c14e7c

Browse files
committed
fixup! CP-48195: Set Tracing.observe default to false
Signed-off-by: Gabriel Buica <danutgabriel.buica@cloud.com>
1 parent 6351706 commit 1c14e7c

File tree

3 files changed

+12
-18
lines changed

3 files changed

+12
-18
lines changed

ocaml/libs/tracing/tracing.ml

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,6 @@ let observe = Atomic.make false
8888

8989
let set_observe = Atomic.set observe
9090

91-
let get_observe () = Atomic.get observe
92-
9391
module SpanKind = struct
9492
type t = Server | Consumer | Client | Producer | Internal [@@deriving rpcty]
9593

@@ -563,20 +561,18 @@ let set ?enabled ?attributes ?endpoints ~uuid () =
563561
failwith
564562
(Printf.sprintf "The TracerProvider : %s does not exist" uuid)
565563
in
566-
Hashtbl.replace tracer_providers uuid provider
567-
) ;
568-
if
569-
List.for_all
570-
(fun provider -> not provider.TracerProvider.enabled)
571-
(get_tracer_providers ())
572-
then (
573-
set_observe false ;
574-
Xapi_stdext_threads.Threadext.Mutex.execute Spans.lock (fun () ->
564+
Hashtbl.replace tracer_providers uuid provider ;
565+
if
566+
List.for_all
567+
(fun provider -> not provider.TracerProvider.enabled)
568+
(get_tracer_providers ())
569+
then (
570+
set_observe false ;
575571
Hashtbl.clear Spans.spans ;
576572
Hashtbl.clear Spans.finished_spans
577-
)
578-
) else if not (get_observe ()) then
579-
set_observe true
573+
) else
574+
set_observe true
575+
)
580576

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

620616
let with_tracing ?(attributes = []) ?(parent = None) ~name f =
621-
if not (get_observe ()) then
617+
if not (Atomic.get observe) then
622618
f None
623619
else
624620
let tracer = get_tracer ~name in

ocaml/libs/tracing/tracing.mli

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,6 @@ val with_tracing :
176176

177177
val set_observe : bool -> unit
178178

179-
val get_observe : unit -> bool
180-
181179
val validate_attribute : string * string -> bool
182180

183181
(** [EnvHelpers] module is a helper module for the tracing library to easily

ocaml/xapi/xapi_observer.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ module Dom0ObserverConfig (ObserverComponent : OBSERVER_COMPONENT) :
309309

310310
let update_config ~__context ~observer ~uuid =
311311
if Db.Observer.get_enabled ~__context ~self:observer then (
312-
if not (Tracing.get_observe ()) then Tracing.set_observe true ;
312+
Tracing.set_observe true ;
313313
let observer_config =
314314
ObserverConfig.config_of_observer ~__context
315315
~component:ObserverComponent.component ~observer

0 commit comments

Comments
 (0)