Ottomata has submitted this change and it was merged.

Change subject: Added %D and %T formatters (request time)
......................................................................


Added %D and %T formatters (request time)

Change-Id: I8c3a04ac14f1b4ea83a4e74b98d4653835d1662e
---
M varnishkafka.c
M varnishkafka.conf.example
2 files changed, 27 insertions(+), 1 deletion(-)

Approvals:
  Ottomata: Verified; Looks good to me, approved



diff --git a/varnishkafka.c b/varnishkafka.c
index a792334..d83c769 100644
--- a/varnishkafka.c
+++ b/varnishkafka.c
@@ -771,6 +771,22 @@
        return scratch_printf(tag, lp, "%"PRIu64, conf.sequence_number);
 }
 
+static int parse_DT (const struct tag *tag, struct logline *lp,
+                     const char *ptr, int len) {
+        double start, stop;
+
+        if (sscanf(strndupa(ptr, len), "%*d %lf %lf %*d.%*d %*s",
+                   &start, &stop) != 2)
+                return 0;
+        if (tag->fmt->id == (int)'D')
+                return scratch_printf(tag, lp, "%.0f",
+                                      (stop-start) * 1000000.0f);
+        else if (tag->fmt->id == (int)'T')
+                return scratch_printf(tag, lp, "%i", (int)(stop-start));
+        else
+                return 0;
+}
+
 
 
 /**
@@ -887,6 +903,14 @@
                                { VSL_S_BACKEND, SLT_RxHeader,
                                  var: "content-length" }
                        } },
+                ['D'] = { {
+                                { VSL_S_CLIENT, SLT_ReqEnd,
+                                  parser: parse_DT }
+                        } },
+                ['T'] = { {
+                                { VSL_S_CLIENT, SLT_ReqEnd,
+                                  parser: parse_DT }
+                        } },
                ['H'] = { {
                                { VSL_S_CLIENT, SLT_RxProtocol },
                                { VSL_S_BACKEND, SLT_TxProtocol },
diff --git a/varnishkafka.conf.example b/varnishkafka.conf.example
index 5669749..1fd9fab 100644
--- a/varnishkafka.conf.example
+++ b/varnishkafka.conf.example
@@ -27,7 +27,9 @@
 #                                                                     #
 # format - format string                                              #
 #  %X                                                                 #
-#   where 'X' is one of the standard varnishncsa(1) formatters.       #
+#   where 'X' is one of the standard varnishncsa(1) formatters:       #
+#   %b, %D, %T, %H, %h, %{..}i, %l, %m, %q, %{..}o, %s, %t, %U,       #
+#   %u, %{..}x, %n                                                    #
 #   Example: %u                                                       #
 #                                                                     #
 #                                                                     #

-- 
To view, visit https://gerrit.wikimedia.org/r/135441
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I8c3a04ac14f1b4ea83a4e74b98d4653835d1662e
Gerrit-PatchSet: 1
Gerrit-Project: operations/software/varnish/varnishkafka
Gerrit-Branch: master
Gerrit-Owner: Edenhill <mag...@edenhill.se>
Gerrit-Reviewer: Edenhill <mag...@edenhill.se>
Gerrit-Reviewer: Ottomata <o...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to