@@ -22,21 +22,41 @@ Targets are defined using a VTable allowing easy extension to other
2222formats in the future. This might be used to define a binary format,
2323for example.
2424
25+ Trace2 is controlled using `trace2.*` config values in the system and
26+ global config files and `GIT_TR2*` environment variables. Trace2 does
27+ not read from repo local or worktree config files or respect `-c`
28+ command line config settings.
29+
2530== Trace2 Targets
2631
2732Trace2 defines the following set of Trace2 Targets.
2833Format details are given in a later section.
2934
30- `GIT_TR2` (NORMAL)::
35+ === The Normal Format Target
36+
37+ The normal format target is a tradition printf format and similar
38+ to GIT_TRACE format. This format is enabled with the `GIT_TR`
39+ environment variable or the `trace2.normalTarget` system or global
40+ config setting.
41+
42+ For example
3143
32- a simple printf format like GIT_TRACE.
33- +
3444------------
3545$ export GIT_TR2=~/log.normal
3646$ git version
3747git version 2.20.1.155.g426c96fcdb
3848------------
39- +
49+
50+ or
51+
52+ ------------
53+ $ git config --global trace2.normalTarget ~/log.normal
54+ $ git version
55+ git version 2.20.1.155.g426c96fcdb
56+ ------------
57+
58+ yields
59+
4060------------
4161$ cat ~/log.normal
426212:28:42.620009 common-main.c:38 version 2.20.1.155.g426c96fcdb
@@ -46,17 +66,32 @@ $ cat ~/log.normal
466612:28:42.621250 trace2/tr2_tgt_normal.c:124 atexit elapsed:0.001265 code:0
4767------------
4868
49- `GIT_TR2_PERF` (PERF)::
69+ === The Performance Format Target
70+
71+ The performance format target (PERF) is a column-based format to
72+ replace GIT_TRACE_PERFORMANCE and is suitable for development and
73+ testing, possibly to complement tools like gprof. This format is
74+ enabled with the `GIT_TR2_PERF` environment variable or the
75+ `trace2.perfTarget` system or global config setting.
76+
77+ For example
5078
51- a column-based format to replace GIT_TRACE_PERFORMANCE suitable for
52- development and testing, possibly to complement tools like gprof.
53- +
5479------------
5580$ export GIT_TR2_PERF=~/log.perf
5681$ git version
5782git version 2.20.1.155.g426c96fcdb
5883------------
59- +
84+
85+ or
86+
87+ ------------
88+ $ git config --global trace2.perfTarget ~/log.perf
89+ $ git version
90+ git version 2.20.1.155.g426c96fcdb
91+ ------------
92+
93+ yields
94+
6095------------
6196$ cat ~/log.perf
629712:28:42.620675 common-main.c:38 | d0 | main | version | | | | | 2.20.1.155.g426c96fcdb
@@ -66,56 +101,46 @@ $ cat ~/log.perf
6610112:28:42.621259 trace2/tr2_tgt_perf.c:211 | d0 | main | atexit | | 0.001265 | | | code:0
67102------------
68103
69- `GIT_TR2_EVENT` (EVENT)::
104+ === The Event Format Target
105+
106+ The event format target is a JSON-based format of event data suitable
107+ for telemetry analysis. This format is enabled with the `GIT_TR2_EVENT`
108+ environment variable or the `trace2.eventTarget` system or global config
109+ setting.
110+
111+ For example
70112
71- a JSON-based format of event data suitable for telemetry analysis.
72- +
73113------------
74114$ export GIT_TR2_EVENT=~/log.event
75115$ git version
76116git version 2.20.1.155.g426c96fcdb
77117------------
78- +
79- ------------
80- $ cat ~/log.event
81- {"event":"version","sid":"sid":"20190408T191610.507018Z-H9b68c35f-P028492","thread":"main","time":"2019-01-16T17:28:42.620713Z","file":"common-main.c","line":38,"evt":"1","exe":"2.20.1.155.g426c96fcdb"}
82- {"event":"start","sid":"20190408T191610.507018Z-H9b68c35f-P028492","thread":"main","time":"2019-01-16T17:28:42.621027Z","file":"common-main.c","line":39,"t_abs":0.001173,"argv":["git","version"]}
83- {"event":"cmd_name","sid":"20190408T191610.507018Z-H9b68c35f-P028492","thread":"main","time":"2019-01-16T17:28:42.621122Z","file":"git.c","line":432,"name":"version","hierarchy":"version"}
84- {"event":"exit","sid":"20190408T191610.507018Z-H9b68c35f-P028492","thread":"main","time":"2019-01-16T17:28:42.621236Z","file":"git.c","line":662,"t_abs":0.001227,"code":0}
85- {"event":"atexit","sid":"20190408T191610.507018Z-H9b68c35f-P028492","thread":"main","time":"2019-01-16T17:28:42.621268Z","file":"trace2/tr2_tgt_event.c","line":163,"t_abs":0.001265,"code":0}
86- ------------
87-
88- == Enabling a Target
89-
90- A Trace2 Target is enabled when the corresponding environment variable
91- (`GIT_TR2`, `GIT_TR2_PERF`, or `GIT_TR2_EVENT`) is set. The following
92- values are recognized.
93-
94- `0`::
95- `false`::
96-
97- Disables the target.
98118
99- `1`::
100- `true`::
119+ or
101120
102- Enables the target and writes stream to `STDERR`.
103-
104- `[2-9]`::
121+ ------------
122+ $ git config --global trace2.eventTarget ~/log.event
123+ $ git version
124+ git version 2.20.1.155.g426c96fcdb
125+ ------------
105126
106- Enables the target and writes to the already opened file descriptor.
127+ yields
107128
108- `<absolute-pathname>`::
129+ ------------
130+ $ cat ~/log.event
131+ {"event":"version","sid":"sid":"20190408T191610.507018Z-H9b68c35f-P000059a8","thread":"main","time":"2019-01-16T17:28:42.620713Z","file":"common-main.c","line":38,"evt":"1","exe":"2.20.1.155.g426c96fcdb"}
132+ {"event":"start","sid":"20190408T191610.507018Z-H9b68c35f-P000059a8","thread":"main","time":"2019-01-16T17:28:42.621027Z","file":"common-main.c","line":39,"t_abs":0.001173,"argv":["git","version"]}
133+ {"event":"cmd_name","sid":"20190408T191610.507018Z-H9b68c35f-P000059a8","thread":"main","time":"2019-01-16T17:28:42.621122Z","file":"git.c","line":432,"name":"version","hierarchy":"version"}
134+ {"event":"exit","sid":"20190408T191610.507018Z-H9b68c35f-P000059a8","thread":"main","time":"2019-01-16T17:28:42.621236Z","file":"git.c","line":662,"t_abs":0.001227,"code":0}
135+ {"event":"atexit","sid":"20190408T191610.507018Z-H9b68c35f-P000059a8","thread":"main","time":"2019-01-16T17:28:42.621268Z","file":"trace2/tr2_tgt_event.c","line":163,"t_abs":0.001265,"code":0}
136+ ------------
109137
110- Enables the target, opens and writes to the file in append mode.
138+ === Enabling a Target
111139
112- `af_unix:[<socket_type>:]<absolute-pathname>`::
140+ To enable a target, set the corresponding environment variable or
141+ system or global config value to one of the following:
113142
114- Enables the target, opens and writes to a Unix Domain Socket
115- (on platforms that support them).
116- +
117- Socket type can be either `stream` or `dgram`. If the socket type is
118- omitted, Git will try both.
143+ include::../trace2-target-values.txt[]
119144
120145== Trace2 API
121146
@@ -243,15 +268,16 @@ significantly affects program performance or behavior, such as
243268 Emits a "def_param" messages for "important" configuration
244269 settings.
245270+
246- The environment variable `GIT_TR2_CONFIG_PARAMS` can be set to a
271+ The environment variable `GIT_TR2_CONFIG_PARAMS` or the `trace2.configParams`
272+ config value can be set to a
247273list of patterns of important configuration settings, for example:
248274`core.*,remote.*.url`. This function will iterate over all config
249275settings and emit a "def_param" message for each match.
250276
251277`void trace2_cmd_set_config(const char *key, const char *value)`::
252278
253- Emits a "def_param" message for a specific configuration
254- setting IFF it matches the `GIT_TR2_CONFIG_PARAMS` pattern .
279+ Emits a "def_param" message for a new or updated key/value
280+ pair IF `key` is considered important .
255281+
256282This is used to hook into `git_config_set()` and catch any
257283configuration changes and update a value previously reported by
@@ -418,9 +444,6 @@ recursive tree walk.
418444
419445=== NORMAL Format
420446
421- NORMAL format is enabled when the `GIT_TR2` environment variable is
422- set.
423-
424447Events are written as lines of the form:
425448
426449------------
@@ -437,18 +460,15 @@ Events are written as lines of the form:
437460Note that this may contain embedded LF or CRLF characters that are
438461not escaped, so the event may spill across multiple lines.
439462
440- If `GIT_TR2_BRIEF` is true, the `time`, `filename`, and `line` fields
441- are omitted.
463+ If `GIT_TR2_BRIEF` or `trace2.normalBrief` is true, the `time`, `filename`,
464+ and `line` fields are omitted.
442465
443466This target is intended to be more of a summary (like GIT_TRACE) and
444467less detailed than the other targets. It ignores thread, region, and
445468data messages, for example.
446469
447470=== PERF Format
448471
449- PERF format is enabled when the `GIT_TR2_PERF` environment variable
450- is set.
451-
452472Events are written as lines of the form:
453473
454474------------
@@ -508,8 +528,8 @@ This field is in anticipation of in-proc submodules in the future.
50852815:33:33.532712 wt-status.c:2331 | d0 | main | region_leave | r1 | 0.127568 | 0.001504 | status | label:print
509529------------
510530
511- If `GIT_TR2_PERF_BRIEF` is true, the `time`, `file`, and `line`
512- fields are omitted.
531+ If `GIT_TR2_PERF_BRIEF` or `trace2.perfBrief` is true, the `time`, `file`,
532+ and `line` fields are omitted.
513533
514534------------
515535d0 | main | region_leave | r1 | 0.011717 | 0.009122 | index | label:preload
@@ -520,9 +540,6 @@ during development and is quite noisy.
520540
521541=== EVENT Format
522542
523- EVENT format is enabled when the `GIT_TR2_EVENT` environment
524- variable is set.
525-
526543Each event is a JSON-object containing multiple key/value pairs
527544written as a single line and followed by a LF.
528545
@@ -540,7 +557,7 @@ The following key/value pairs are common to all events:
540557------------
541558{
542559 "event":"version",
543- "sid":"20190408T191827.272759Z-H9b68c35f-P011764 ",
560+ "sid":"20190408T191827.272759Z-H9b68c35f-P00003510 ",
544561 "thread":"main",
545562 "time":"2019-04-08T19:18:27.282761Z",
546563 "file":"common-main.c",
@@ -576,9 +593,9 @@ The following key/value pairs are common to all events:
576593`"repo":<repo-id>`::
577594 when present, is the integer repo-id as described previously.
578595
579- If `GIT_TR2_EVENT_BRIEF` is true, the `file` and `line` fields are omitted
580- from all events and the `time` field is only present on the "start" and
581- "atexit" events.
596+ If `GIT_TR2_EVENT_BRIEF` or `trace2.eventBrief` is true, the `file`
597+ and `line` fields are omitted from all events and the `time` field is
598+ only present on the "start" and "atexit" events.
582599
583600==== Event-Specific Key/Value Pairs
584601
@@ -889,7 +906,7 @@ visited.
889906The `category` field may be used in a future enhancement to
890907do category-based filtering.
891908+
892- The `GIT_TR2_EVENT_NESTING` environment variable can be used to
909+ `GIT_TR2_EVENT_NESTING` or `trace2.eventNesting` can be used to
893910filter deeply nested regions and data events. It defaults to "2".
894911
895912`"region_leave"`::
0 commit comments