Skip to content

Commit

Permalink
fixup! request loop plus span parent update
Browse files Browse the repository at this point in the history
  • Loading branch information
GabrielBuica committed Jul 23, 2024
1 parent 7b9f204 commit d7e8c63
Showing 1 changed file with 19 additions and 23 deletions.
42 changes: 19 additions & 23 deletions ocaml/libs/http-lib/http_svr.ml
Original file line number Diff line number Diff line change
Expand Up @@ -512,10 +512,29 @@ let request_of_bio_exn ~proxy_seen ~read_timeout ~total_timeout ~max_length span
let request_of_bio ?proxy_seen ~read_timeout ~total_timeout ~max_length span ic
=
try
let tracer = Tracing.Tracer.get_tracer ~name:"http_tracer" in
let loop_span =
match Tracing.Tracer.start ~tracer ~name:__FUNCTION__ ~parent:None () with
| Ok span ->
span
| Error _ ->
None
in
let r, proxy =
request_of_bio_exn ~proxy_seen ~read_timeout ~total_timeout ~max_length
span ic
in
let parent_span = traceparent_of_request r in
let loop_span =
match loop_span with
| Some span ->
Tracing.Tracer.update_span_with_parent span parent_span
| None ->
None
in
let _ : (Tracing.Span.t option, exn) result =
Tracing.Tracer.finish loop_span
in
(Some r, proxy)
with e ->
D.warn "%s (%s)" (Printexc.to_string e) __LOC__ ;
Expand Down Expand Up @@ -663,33 +682,10 @@ let handle_connection ~header_read_timeout ~header_total_timeout
along in the loop below. *)
let rec loop ~read_timeout ~total_timeout span proxy_seen =
(* 1. we must successfully parse a request *)
let tracer = Tracing.Tracer.get_tracer ~name:"http_tracer" in
let loop_span =
match
Tracing.Tracer.start ~tracer
~name:(__FUNCTION__ ^ ".parse_loop")
~parent:None ()
with
| Ok span ->
span
| Error _ ->
None
in
let req, proxy =
request_of_bio ?proxy_seen ~read_timeout ~total_timeout
~max_length:max_header_length span ic
in
let parent_span = Option.bind req traceparent_of_request in
let loop_span =
match loop_span with
| Some span ->
Tracing.Tracer.update_span_with_parent span parent_span
| None ->
None
in
let _ : (Tracing.Span.t option, exn) result =
Tracing.Tracer.finish loop_span
in

(* 2. now we attempt to process the request *)
let finished =
Expand Down

0 comments on commit d7e8c63

Please sign in to comment.