diff options
author | Robert Coup <robert@coup.net.nz> | 2023-10-17 23:12:47 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2023-10-30 13:43:21 +0100 |
commit | b8f58c200cd3493ccf3c1669aa3c34927c884018 (patch) | |
tree | 50e61415019a9d4a57ca08d1007acd1211b91c6f /upload-pack.c | |
parent | The twenty-second batch (diff) | |
download | git-b8f58c200cd3493ccf3c1669aa3c34927c884018.tar.xz git-b8f58c200cd3493ccf3c1669aa3c34927c884018.zip |
upload-pack: add tracing for fetches
Information on how users are accessing hosted repositories can be
helpful to server operators. For example, being able to broadly
differentiate between fetches and initial clones; the use of shallow
repository features; or partial clone filters.
a29263c (fetch-pack: add tracing for negotiation rounds, 2022-08-02)
added some information on have counts to fetch-pack itself to help
diagnose negotiation; but from a git-upload-pack (server) perspective,
there's no means of accessing such information without using
GIT_TRACE_PACKET to examine the protocol packets.
Improve this by emitting a Trace2 JSON event from upload-pack with
summary information on the contents of a fetch request.
* haves, wants, and want-ref counts can help determine (broadly) between
fetches and clones, and the use of single-branch, etc.
* shallow clone depth, tip counts, and deepening options.
* any partial clone filter type.
Signed-off-by: Robert Coup <robert@coup.net.nz>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'upload-pack.c')
-rw-r--r-- | upload-pack.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/upload-pack.c b/upload-pack.c index 83f3d2651a..ea234ab6a4 100644 --- a/upload-pack.c +++ b/upload-pack.c @@ -33,6 +33,7 @@ #include "commit-reach.h" #include "shallow.h" #include "write-or-die.h" +#include "json-writer.h" /* Remember to update object flag allocation in object.h */ #define THEY_HAVE (1u << 11) @@ -1552,6 +1553,30 @@ static int parse_have(const char *line, struct oid_array *haves) return 0; } +static void trace2_fetch_info(struct upload_pack_data *data) +{ + struct json_writer jw = JSON_WRITER_INIT; + + jw_object_begin(&jw, 0); + jw_object_intmax(&jw, "haves", data->haves.nr); + jw_object_intmax(&jw, "wants", data->want_obj.nr); + jw_object_intmax(&jw, "want-refs", data->wanted_refs.nr); + jw_object_intmax(&jw, "depth", data->depth); + jw_object_intmax(&jw, "shallows", data->shallows.nr); + jw_object_bool(&jw, "deepen-since", data->deepen_since); + jw_object_intmax(&jw, "deepen-not", data->deepen_not.nr); + jw_object_bool(&jw, "deepen-relative", data->deepen_relative); + if (data->filter_options.choice) + jw_object_string(&jw, "filter", list_object_filter_config_name(data->filter_options.choice)); + else + jw_object_null(&jw, "filter"); + jw_end(&jw); + + trace2_data_json("upload-pack", the_repository, "fetch-info", &jw); + + jw_release(&jw); +} + static void process_args(struct packet_reader *request, struct upload_pack_data *data) { @@ -1640,6 +1665,9 @@ static void process_args(struct packet_reader *request, if (request->status != PACKET_READ_FLUSH) die(_("expected flush after fetch arguments")); + + if (trace2_is_enabled()) + trace2_fetch_info(data); } static int process_haves(struct upload_pack_data *data, struct oid_array *common) |