Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2022-08-30 00:55:13 +0300
committerJunio C Hamano <gitster@pobox.com>2022-08-30 00:55:13 +0300
commit10ccb50b163d7a204495fe8ba11fe7c54c335163 (patch)
treefb1db8d5a9ac3a473cd5543c565c5f028cf85d0c
parent25402204fe00004b6acc1a7ca88b990ccd0e5d52 (diff)
parent35ae40ead34f29c827abf101ba4e5412c2e67ab0 (diff)
Merge branch 'tl/trace2-config-scope'
Tweak trace2 output about configuration variables. * tl/trace2-config-scope: tr2: shows scope unconditionally in addition to key-value pair api-trace2.txt: print config key-value pair
-rw-r--r--Documentation/technical/api-trace2.txt40
-rw-r--r--trace2/tr2_tgt_event.c3
-rw-r--r--trace2/tr2_tgt_normal.c5
-rw-r--r--trace2/tr2_tgt_perf.c9
4 files changed, 54 insertions, 3 deletions
diff --git a/Documentation/technical/api-trace2.txt b/Documentation/technical/api-trace2.txt
index 77a150b30e..2afa28bb5a 100644
--- a/Documentation/technical/api-trace2.txt
+++ b/Documentation/technical/api-trace2.txt
@@ -717,6 +717,7 @@ The "exec_id" field is a command-unique id and is only useful if the
{
"event":"def_param",
...
+ "scope":"global",
"param":"core.abbrev",
"value":"7"
}
@@ -1207,6 +1208,45 @@ at offset 508.
This example also shows that thread names are assigned in a racy manner
as each thread starts and allocates TLS storage.
+Config (def param) Events::
+
+ Dump "interesting" config values to trace2 log.
++
+We can optionally emit configuration events, see
+`trace2.configparams` in linkgit:git-config[1] for how to enable
+it.
++
+----------------
+$ git config --system color.ui never
+$ git config --global color.ui always
+$ git config --local color.ui auto
+$ git config --list --show-scope | grep 'color.ui'
+system color.ui=never
+global color.ui=always
+local color.ui=auto
+----------------
++
+Then, mark the config `color.ui` as "interesting" config with
+`GIT_TRACE2_CONFIG_PARAMS`:
++
+----------------
+$ export GIT_TRACE2_PERF_BRIEF=1
+$ export GIT_TRACE2_PERF=~/log.perf
+$ export GIT_TRACE2_CONFIG_PARAMS=color.ui
+$ git version
+...
+$ cat ~/log.perf
+d0 | main | version | | | | | ...
+d0 | main | start | | 0.001642 | | | /usr/local/bin/git version
+d0 | main | cmd_name | | | | | version (version)
+d0 | main | def_param | | | | scope:system | color.ui:never
+d0 | main | def_param | | | | scope:global | color.ui:always
+d0 | main | def_param | | | | scope:local | color.ui:auto
+d0 | main | data | r0 | 0.002100 | 0.002100 | fsync | fsync/writeout-only:0
+d0 | main | data | r0 | 0.002126 | 0.002126 | fsync | fsync/hardware-flush:0
+d0 | main | exit | | 0.000470 | | | code:0
+d0 | main | atexit | | 0.000477 | | | code:0
+----------------
== Future Work
=== Relationship to the Existing Trace Api (api-trace.txt)
diff --git a/trace2/tr2_tgt_event.c b/trace2/tr2_tgt_event.c
index c5c8cfbbaa..37a3163be1 100644
--- a/trace2/tr2_tgt_event.c
+++ b/trace2/tr2_tgt_event.c
@@ -479,9 +479,12 @@ static void fn_param_fl(const char *file, int line, const char *param,
{
const char *event_name = "def_param";
struct json_writer jw = JSON_WRITER_INIT;
+ enum config_scope scope = current_config_scope();
+ const char *scope_name = config_scope_name(scope);
jw_object_begin(&jw, 0);
event_fmt_prepare(event_name, file, line, NULL, &jw);
+ jw_object_string(&jw, "scope", scope_name);
jw_object_string(&jw, "param", param);
jw_object_string(&jw, "value", value);
jw_end(&jw);
diff --git a/trace2/tr2_tgt_normal.c b/trace2/tr2_tgt_normal.c
index c42fbade7f..69f8033077 100644
--- a/trace2/tr2_tgt_normal.c
+++ b/trace2/tr2_tgt_normal.c
@@ -298,8 +298,11 @@ static void fn_param_fl(const char *file, int line, const char *param,
const char *value)
{
struct strbuf buf_payload = STRBUF_INIT;
+ enum config_scope scope = current_config_scope();
+ const char *scope_name = config_scope_name(scope);
- strbuf_addf(&buf_payload, "def_param %s=%s", param, value);
+ strbuf_addf(&buf_payload, "def_param scope:%s %s=%s", scope_name, param,
+ value);
normal_io_write_fl(file, line, &buf_payload);
strbuf_release(&buf_payload);
}
diff --git a/trace2/tr2_tgt_perf.c b/trace2/tr2_tgt_perf.c
index a1eff8bea3..8cb792488c 100644
--- a/trace2/tr2_tgt_perf.c
+++ b/trace2/tr2_tgt_perf.c
@@ -441,12 +441,17 @@ static void fn_param_fl(const char *file, int line, const char *param,
{
const char *event_name = "def_param";
struct strbuf buf_payload = STRBUF_INIT;
+ struct strbuf scope_payload = STRBUF_INIT;
+ enum config_scope scope = current_config_scope();
+ const char *scope_name = config_scope_name(scope);
strbuf_addf(&buf_payload, "%s:%s", param, value);
+ strbuf_addf(&scope_payload, "%s:%s", "scope", scope_name);
- perf_io_write_fl(file, line, event_name, NULL, NULL, NULL, NULL,
- &buf_payload);
+ perf_io_write_fl(file, line, event_name, NULL, NULL, NULL,
+ scope_payload.buf, &buf_payload);
strbuf_release(&buf_payload);
+ strbuf_release(&scope_payload);
}
static void fn_repo_fl(const char *file, int line,