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

feat: add logging on ChooChooTrain #288

Merged
merged 19 commits into from
Jan 22, 2025
Merged

Conversation

IgnacioBecerra
Copy link
Contributor

@IgnacioBecerra IgnacioBecerra commented Dec 19, 2024

Closes #

This PR adds logs that are sent out to the collector regarding the duration of the whole ChooChooTrain process. To get the information needed to be more specific in these logs, I had to use the getGitInfo() function that was called within the ibmTelemetry() function, meaning it would be called twice per instrumented package. While this probably wouldn't add a lot of time overhead, this whole logging exercise is mainly being done to troubleshoot packages not reporting data, and since our current working theory is that the process is taking longer than it should, I wouldn't want to add anything that would make it take even longer.

Thus, the part of the code gathering all this git information was refactored to only be ran once at the beginning of the whole ChooChooTrain. It was also properly hashed in order to be passed down to the ibmTelemetry() function, where all needed to be done is add it to the otelContext.

Changelog

New

  • adds function to send logs to collector

Changed

  • refactored way git information is retrieved to be ran only once

Testing / reviewing

{{ Add descriptions, steps or a checklist for how reviewers can verify this PR works or not }}

@mattrosno
Copy link
Collaborator

@IgnacioBecerra to make sure I understand, if 20 instrumented packages run during a scan, currently, these commands would run 20 times?

  • git remote get-url origin
  • git rev-parse HEAD
  • git branch --points-at=${commitHash} --format='%(refname:short)'
  • git tag --points-at=${commitHash} --format='%(refname:short)'

With this refactor, these commands would only run once? And the hypothesis is this change would speed things up?

@IgnacioBecerra
Copy link
Contributor Author

@mattrosno Yeah so currently every instance of the ChooChooTrain calls its own ibmTelemetry() instance, which runs those commands. If 20 instrumented packages are running, then those commands get ran 20 times.

Since we need identifiers for our logs within the ChooChooTrain, we're gonna need to run those commands before calling ibmTelemetry(), so at the moment (in this draft PR) we're calling it twice, so they're getting ran 40 times. My goal is to at least get those commands out of ibmTelemetry and only be ran in the ChooChooTrain.

I'm not totally sure if it'll be indeed possible to run it only once, but at least for the time being this slight refactor is mostly to avoid running those commands in two different functions each. The commands run very fast, so this isn't the bottleneck we think it might be, but it's always good to squeeze out any extra speed if possible, or at least to avoid repetitive code.

@IgnacioBecerra IgnacioBecerra marked this pull request as ready for review December 23, 2024 15:35
@IgnacioBecerra IgnacioBecerra requested a review from a team as a code owner December 23, 2024 15:35
Copy link
Collaborator

@mattrosno mattrosno left a comment

Choose a reason for hiding this comment

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

We need to remove new lines in the template literals so the new line characters and spaces (tabs characters?) aren't included in the logging.

@IgnacioBecerra
Copy link
Contributor Author

@mattrosno I'm now using concatenation instead since we have an eslint rule that a single line can't be over 150 characters.

I'll be working on getting the SonarCloud number up.

Copy link
Contributor

@ariellalgilmore ariellalgilmore left a comment

Choose a reason for hiding this comment

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

LGTM just one small thing commented

IgnacioBecerra and others added 10 commits January 2, 2025 13:53
Co-authored-by: Ariella Gilmore <ariellalgilmore@gmail.com>
* feat: add env and scanID to metrics

* feat: add scanID to metric docs

* fix: use scanId variable

* fix: added scanID to gitinfo

* fix: ensure empty string in case of undefined

Co-authored-by: Matt Rosno <matt.rosno@gmail.com>

---------

Co-authored-by: Matt Rosno <matt.rosno@gmail.com>
@IgnacioBecerra IgnacioBecerra merged commit c272c25 into main Jan 22, 2025
7 checks passed
@IgnacioBecerra IgnacioBecerra deleted the add-logging-on-error branch January 22, 2025 23:25
@telemmy telemmy bot mentioned this pull request Jan 22, 2025
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.

3 participants