summaryrefslogtreecommitdiffstats
path: root/git_trace2_event_log.py
Commit message (Collapse)AuthorAgeFilesLines
* Log ErrorEvent for failing GitCommandsJason Chang2023-09-061-352/+9
| | | | | | | | Change-Id: I270af7401cff310349e736bef87e9b381cc4d016 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/385054 Reviewed-by: Gavin Mak <gavinmak@google.com> Commit-Queue: Jason Chang <jasonnc@google.com> Tested-by: Jason Chang <jasonnc@google.com>
* isort: format codebasev2.36Mike Frysinger2023-08-221-1/+2
| | | | | | | | Change-Id: I6f11d123b68fd077f558d3c21349c55c5f251019 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/383715 Reviewed-by: Gavin Mak <gavinmak@google.com> Tested-by: Mike Frysinger <vapier@google.com> Commit-Queue: Mike Frysinger <vapier@google.com>
* Prefix error events with RepoErrorEvent:Jason Chang2023-08-071-2/+2
| | | | | | | | | | | | Prior to this change there is no way to distinguish between git sessions logs generated from repo source v.s. from git. Bug: b/294446468 Change-Id: I309f59e146c30cb08a0637e8d0b9c5d9efd5cada Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/381794 Commit-Queue: Jason Chang <jasonnc@google.com> Reviewed-by: Joanna Wang <jojwang@google.com> Tested-by: Jason Chang <jasonnc@google.com>
* [git_trace2] Add logs for critical cmdsJosip Sokcevic2023-05-171-1/+3
| | | | | | | | | | | | Trace logs emitted from repo are not useful on error for many critical commands. This change adds errors for critical commands to trace logs. Change-Id: Ideb9358bee31e540bd84a94327a09ff9b0246a77 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/373814 Reviewed-by: Joanna Wang <jojwang@google.com> Tested-by: Josip Sokcevic <sokcevic@google.com> Commit-Queue: Josip Sokcevic <sokcevic@google.com> Reviewed-by: Gavin Mak <gavinmak@google.com>
* [trace2] Add absolute time on trace2 exit eventsJosip Sokcevic2023-05-151-2/+4
| | | | | | | | Change-Id: I58aff46bd4ff4ba79286a7f1226e19eb568c34c5 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/373954 Reviewed-by: Gavin Mak <gavinmak@google.com> Tested-by: Josip Sokcevic <sokcevic@google.com> Commit-Queue: Josip Sokcevic <sokcevic@google.com>
* Format codebase with black and check formatting in CQGavin Mak2023-03-221-278/+317
| | | | | | | | | | | | Apply rules set by https://gerrit-review.googlesource.com/c/git-repo/+/362954/ across the codebase and fix any lingering errors caught by flake8. Also check black formatting in run_tests (and CQ). Bug: b/267675342 Change-Id: I972d77649dac351150dcfeb1cd1ad0ea2efc1956 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/363474 Reviewed-by: Mike Frysinger <vapier@google.com> Tested-by: Gavin Mak <gavinmak@google.com> Commit-Queue: Gavin Mak <gavinmak@google.com>
* Resolved DeprecationWarning for currentThread()Daniel Kutik2022-11-251-1/+1
| | | | | | | | | | | | | In Python 3.10 onwards we see a DeprecationWarning: currentThread() is deprecated, use current_thread() instead. Same goes for getName(), replaced by name attribute. Test: tox (python 3.6 - 3.10) Signed-off-by: Daniel Kutik <daniel.kutik@lavawerk.com> Change-Id: I80ec819752a5276cff3b2dadba0ec10cc92d09a4 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/353018 Reviewed-by: Mike Frysinger <vapier@google.com>
* trace: allow writing traces to a socketJosh Steadmon2022-03-161-14/+72
| | | | | | | | | | | | | | | | | | | Git can write trace2 events to a Unix domain socket [1]. This can be specified via Git's `trace2.eventTarget` config option, which we read to determine where to log our own trace2 events. Currently, if the Git config specifies a socket as the trace2 target, we fail to log any traces. Fix this by adding support for writing to a Unix domain socket, following the same specification that Git supports. [1]: https://git-scm.com/docs/api-trace2#_enabling_a_target Change-Id: I928bc22ba04fba603a9132eb055141845fa48ab2 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/332339 Reviewed-by: Raman Tenneti <rtenneti@google.com> Reviewed-by: Mike Frysinger <vapier@google.com> Tested-by: Josh Steadmon <steadmon@google.com>
* superproject: Log syncstate's parameter as data-json it it is an array.Raman Tenneti2021-09-281-4/+4
| | | | | | | | | | | | | | | | | | | All the values of syncstate are strings, check the first byte and last byte to see if it is an array. For syncstate data, there were no false positives. Tested: $ repo_dev sync Verified event logged for argv is "data-json". $./run_tests Bug: [google internal] b/201102002 Change-Id: Id56adb532b80267f08d09147ac663cdd5987ce87 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/319075 Reviewed-by: Mike Frysinger <vapier@google.com> Tested-by: Raman Tenneti <rtenneti@google.com>
* superproject: Log argv parameter of syncstate as 'data-json'.Raman Tenneti2021-09-271-1/+5
| | | | | | | | | | | | | | | | | | | | Fixed: "we need to make a special case for logging the argv; it should probably be a "data-json" event so that we log this directly as an array rather than an encoded string. Tested: $ repo_dev sync Verified event logged for argv is "data-json". $./run_tests Bug: [google internal] b/201102002 Change-Id: I18ccec79c73c8dc931cb8afc472b2361db8aea4c Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/319055 Reviewed-by: Josh Steadmon <steadmon@google.com> Reviewed-by: Xin Li <delphij@google.com> Tested-by: Raman Tenneti <rtenneti@google.com>
* sync: Log repo sync state events as 'data' events.Raman Tenneti2021-09-141-0/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | git_trace2_event_log.py: + Added LogDataConfigEvents method to log 'data' events. Sync's current_sync_state and previous_sync_state are logged as 'data' events in the current log. It logs are key/value in the |config| argument. Each key is prefixed with |prefix| argument. The following are sample events that are logged during repo sync. {"event":"data", "sid":"repo-20210914T181545Z-P000330c0/repo-20210914T181545Z-P000330c0", "thread":"MainThread", "time":"2021-09-14T18:16:19.935846Z", "key":"previous_sync_state/repo.syncstate.main.synctime", "value":"2021-09-14T17:27:11.573717Z"} {"event":"data", "sid":"repo-20210914T181545Z-P000330c0/repo-20210914T181545Z-P000330c0", "thread":"MainThread", "time":"2021-09-14T18:16:19.955546Z", "key":"current_sync_state/repo.syncstate.main.synctime", "value":"2021-09-14T18:16:19.935979Z"} tests/test_git_trace2_event_log.py: + Added unit tests sync.py: + Changed logging calls to LogDataConfigEvents. Tested: $ ./run_tests Tested it by running the following command multiple times. $ repo_dev sync -j 20 repo sync has finished successfully Verified config data is looged in trace2 event logs. Bug: [google internal] b/199758376 Change-Id: I75fd830e90c1811ec28510538c99a2632b104e85 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/317823 Reviewed-by: Josh Steadmon <steadmon@google.com> Reviewed-by: Xin Li <delphij@google.com> Tested-by: Raman Tenneti <rtenneti@google.com>
* sync: Added logging of repo sync state and config options for analysis.Raman Tenneti2021-07-291-6/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | git_config.py: + Added SyncAnalysisState class, which saves the following data into the config object. ++ sys.argv, options, superproject's logging data. ++ repo.*, branch.* and remote.* parameters from config object. ++ current time as synctime. ++ Version number of the object. + All the keys for the above data are prepended with 'repo.syncstate.' + Added GetSyncAnalysisStateData and UpdateSyncAnalysisState methods to GitConfig object to save/get the above data. git_trace2_event_log.py: + Added LogConfigEvents method with code from DefParamRepoEvents to log events. sync.py: + superproject_logging_data is a dictionary that collects all the superproject data that is to be logged as trace2 event. + Sync at the end logs the previously saved syncstate.* parameters as previous_sync_state. Then it calls config's UpdateSyncAnalysisState to save and log all the current options, superproject logged data. docs/internal-fs-layout.md: + Added doc string explaining [repo.syncstate ...] sections of .repo/manifests.git/config file. test_git_config.py: + Added unit test for the new methods of GitConfig object. Tested: $ ./run_tests $ repo_dev init --use-superproject -u https://android.googlesource.com/platform/manifest Tested it by running the following command multiple times. $ repo_dev sync -j 20 repo sync has finished successfully Verified config file has [syncstate ...] data saved. Bug: [google internal] b/188573450 Change-Id: I1f914ce50f3382111b72940ca56de7c41b53d460 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/313123 Tested-by: Raman Tenneti <rtenneti@google.com> Reviewed-by: Mike Frysinger <vapier@google.com> Reviewed-by: Xin Li <delphij@google.com>
* trace2_event_log: Added logging of error events.Raman Tenneti2021-06-091-0/+7
| | | | | | | | | | | | | | | Added error event in preperation for superproject to log errors. Testing: + Unit tests ./run_tests -v Bug: [google internal] b/189371541 Change-Id: Ife1dd28d52d9e9925b7b34ae913f8eb5fa19037c Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/308863 Reviewed-by: Mike Frysinger <vapier@google.com> Reviewed-by: Xin Li <delphij@google.com> Tested-by: Raman Tenneti <rtenneti@google.com>
* repo: Add a new "command" event type to git trace2 logging in repo.Raman Tenneti2021-03-181-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add a new "event": "command", which is emitted at when all command arguments have been processed. Additional fields: "name": Name of the primary command (ex: repo, git) "subcommands"': List of the sub-commands once command-line arguments are processed Examples: Command: repo --version Event: {"event": "command", <common fields>, "name": "repo", "subcommands": ["version"] } Bug: [google internal] b/178507266 Testing: - Unit tests - Verified repo git trace2 logs had expected data Change-Id: I825bd0ecedee45135382461a4ba10f987f09aef3 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/300343 Reviewed-by: Ian Kasprzak <iankaz@google.com> Reviewed-by: Mike Frysinger <vapier@google.com> Tested-by: Raman Tenneti <rtenneti@google.com>
* Log repo.* config variables in git trace2 logger.Ian Kasprzak2021-03-081-0/+15
| | | | | | | | | | | | | Bug: [google internal] b/181758736 Testing: - Unit tests - Verified repo git trace2 logs had expected data Change-Id: I9af8a574377bd91115f085808c1271e9dee16a36 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/299182 Tested-by: Ian Kasprzak <iankaz@google.com> Reviewed-by: Mike Frysinger <vapier@google.com> Reviewed-by: Raman Tenneti <rtenneti@google.com>
* Update "evt" field to be logged as a string type.Ian Kasprzak2021-01-191-1/+1
| | | | | | | | | | | | Testing: - Unit tests - Verified git trace log has "evt": "2" (vs "evt": 2 previously) Bug: https://crbug.com/gerrit/13966 Change-Id: I2e0c98dda0cccdd5cb6328105c11b93cd42676eb Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/294123 Reviewed-by: Jonathan Nieder <jrn@google.com> Tested-by: Ian Kasprzak <iankaz@google.com>
* Fix bug in git trace2 event Write() function when no config present.Ian Kasprzak2021-01-071-15/+29
| | | | | | | | | | | | | | | | | | See https://bugs.chromium.org/p/gerrit/issues/detail?id=13706#c9 Added additional unit tests for Write() for additional test coverage. Testing: - Unit tests - Verified repo works with: - Valid trace2.eventtarget - Invalid trace2.eventtarget Bug: https://crbug.com/gerrit/13706 Tested-by: Ian Kasprzak <iankaz@google.com> Change-Id: I6b027cb2399bd03e453a132ad82e022a1f48476e Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/292762 Reviewed-by: Mike Frysinger <vapier@google.com>
* Enable git trace2 event format logging.Ian Kasprzak2021-01-061-0/+197
Ways to enable logging: 1) Set git's trace2.eventtarget config variable to desired logging path 2) Specify path via --git_trace2_event_log option A unique logfile name is generated per repo execution (based on the repo session-id). Testing: 1) Verified git config 'trace2.eventtarget' and flag enable logging. 2) Verified version/start/end events are expected format: https://git-scm.com/docs/api-trace2#_event_format 3) Unit tests Bug: https://crbug.com/gerrit/13706 Change-Id: I335eba68124055321c4149979bec36ac16ef81eb Tested-by: Ian Kasprzak <iankaz@google.com> Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/292262 Reviewed-by: Mike Frysinger <vapier@google.com> Reviewed-by: Jonathan Nieder <jrn@google.com>