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-45235: Support for xe-cli to transmit traceparent #5633

Merged
merged 1 commit into from
Jun 6, 2024

Conversation

GabrielBuica
Copy link
Contributor

@GabrielBuica GabrielBuica commented May 15, 2024

Adds the possibility of xe commands to pass a traceparent.

This can be done through the following ways:

  • a command arg: xe <cmd> --traceparent <traceparent> (or xe <cmd> traceparent=<traceparent>);
  • a environment variable: TRACEPARENT=<traceparent>:
  • specifying traceparent=<traceparent> in .xe.

Priority is given in the same order as above.

This should enable creating a single trace from the xe-cli caller through xapi.

ocaml/xe-cli/newcli.ml Outdated Show resolved Hide resolved
@@ -286,6 +292,10 @@ let parse_args =
List.rev !l
in
let extras_rest = process_args extras in
(*if traceparent is set as env var update it after we process the extras.*)
Option.iter
(fun tp -> traceparent := Some tp)
Copy link
Member

Choose a reason for hiding this comment

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

The cli argument must take precedence over the environment variable, which usually takes preference over the contents of the configuration file

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is what it does: it sets the values from configuration files, then overwrites them with the values from environment variables and then again with values from the cli argument. process_args calls set_keyword to achieve this.

This line is separate because it reads and process TRACEPARENT env var after it processes XE_EXTRA_ARGS.

ocaml/xe-cli/newcli.ml Outdated Show resolved Hide resolved
ocaml/xe-cli/newcli.ml Outdated Show resolved Hide resolved
Adds the possibility of `xe` commands to pass a `traceparent`.

This can be done through the following ways:

- a command arg: `xe <cmd> --traceparent <traceparent>`;
- a environment variable: `TRACEPARENT=<traceparent>`:
- specifying `traceparent=<traceparent>` in `.xe`.

Priority is given in the same order as above.

This should enable creating a single trace from the `xe-cli` caller
through `xapi`.

Signed-off-by: Gabriel Buica <danutgabriel.buica@cloud.com>
@GabrielBuica
Copy link
Contributor Author

Rebased it on master. Passes BVT+BST 199170

@psafont psafont merged commit 190df63 into xapi-project:master Jun 6, 2024
13 checks passed
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.

None yet

3 participants