Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CP-48195: Split tracing library to avoid future cyclic dependencies #5551

Merged
merged 3 commits into from
Apr 22, 2024

Conversation

GabrielBuica
Copy link
Contributor

@GabrielBuica GabrielBuica commented Apr 9, 2024

This PR is meant to split the tracing library in 2 parts:

  • tracing.ml that represents the core of the library;
  • tracing_export.ml that creates and manages the exporter thread.

This is to avoid cyclic dependencies between tracing and forkexecd.

Instrumentation of forkexecd will be done as a follow-up PR.

dune-project Outdated Show resolved Hide resolved
xapi-tracing-export.opam Outdated Show resolved Hide resolved
@GabrielBuica GabrielBuica force-pushed the private/dbuica/CP-48195-v2 branch 2 times, most recently from 97f0194 to 874ffc8 Compare April 9, 2024 16:24
ocaml/forkexecd/lib/forkhelpers.ml Outdated Show resolved Hide resolved
@@ -357,10 +362,12 @@ let execute_command_get_output_inner ?env ?stdin ?(syslog_stdout = NoSyslogging)
)
(fun () -> List.iter Unix.close !to_close)

let execute_command_get_output ?env ?(syslog_stdout = NoSyslogging)
let execute_command_get_output ?traceparent ?env ?(syslog_stdout = NoSyslogging)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is traceparent written this way in other code already? Otherwise I would prefer a better spelling.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are some places that call the parent span traceparent, some that call it parent, some that call it tracing. Given the function used is called with_tracing is it more preferable to call it tracing?

@@ -357,10 +362,12 @@ let execute_command_get_output_inner ?env ?stdin ?(syslog_stdout = NoSyslogging)
)
(fun () -> List.iter Unix.close !to_close)

let execute_command_get_output ?env ?(syslog_stdout = NoSyslogging)
let execute_command_get_output ?traceparent ?env ?(syslog_stdout = NoSyslogging)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is traceparent written this way in other code already? Otherwise I would prefer a better spelling.

module Attributes : sig
type 'a t

val fold : (string -> 'a -> 'b -> 'b) -> 'a t -> 'b -> 'b
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This smells funny. We have a new abstract type 'a t that has no way to create or observe it.

ocaml/libs/tracing/tracing_export.ml Outdated Show resolved Hide resolved
ocaml/libs/tracing/tracing_export.ml Outdated Show resolved Hide resolved
ocaml/libs/tracing/tracing_export.ml Outdated Show resolved Hide resolved
ocaml/libs/tracing/tracing_export.ml Outdated Show resolved Hide resolved
ocaml/libs/tracing/tracing_export.ml Outdated Show resolved Hide resolved
ocaml/libs/tracing/tracing_export.mli Outdated Show resolved Hide resolved
@GabrielBuica GabrielBuica force-pushed the private/dbuica/CP-48195-v2 branch from 031bce8 to ac1baee Compare April 17, 2024 14:45
@GabrielBuica GabrielBuica marked this pull request as ready for review April 17, 2024 14:45
@GabrielBuica GabrielBuica changed the title CP-48195 Instrument forkhelpers.ml with dt CP-48195: Split tracing library to avoid future cyclic dependencies Apr 17, 2024
@GabrielBuica GabrielBuica force-pushed the private/dbuica/CP-48195-v2 branch from bcc563a to ee9906b Compare April 19, 2024 12:34
Copy link
Member

@psafont psafont left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commits need to be squashed before merging

Attempts to split the tracing library into components and exporter
parts.

While trying to instrument `forkhelpers.ml` with tracing, I found a
cycle dependency: `Tracing(Exporter)` -> `Open_uri` -> `Stunnel` ->
`Forkhelpers`. This splits the tracing library between exporting
functionality and components.

Signed-off-by: Gabriel Buica <[email protected]>
Small improvements to `tracing_export.ml` and `tracing_exoprt.mli`.

Issues found while splitting the library such as: missing documentation
and small code refactoring for better readability.

Signed-off-by: Gabriel Buica <[email protected]>
Adds `with_tracing` helper function to `forkhelpers.ml`.

This is to show that there are no more cycle dependecies between
`tracing` library and `forexecd` and it will be used in a follow-up PR
to instrument `forkhelpers` with tracing.

Signed-off-by: Gabriel Buica <[email protected]>
@GabrielBuica GabrielBuica force-pushed the private/dbuica/CP-48195-v2 branch from ee9906b to d049d43 Compare April 19, 2024 14:49
@GabrielBuica
Copy link
Contributor Author

BVT 197315

Copy link
Member

@mg12 mg12 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bvt passed

@robhoes robhoes merged commit f208e2f into xapi-project:master Apr 22, 2024
14 checks passed
@GabrielBuica GabrielBuica deleted the private/dbuica/CP-48195-v2 branch January 8, 2025 10:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants