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>
This commit is contained in:

committed by
Junio C Hamano

parent
3130c155df
commit
b8f58c200c
@ -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)
|
||||
|
Reference in New Issue
Block a user