Add structured API request debug logging
authorErik Bernhardson <ebernhardson@wikimedia.org>
Wed, 23 Sep 2015 23:37:06 +0000 (16:37 -0700)
committerAnomie <bjorsch@wikimedia.org>
Tue, 17 Nov 2015 18:21:35 +0000 (18:21 +0000)
commit0d7385a87ced5cbf5f9e1c2909d66e29f873cd19
tree93ba37d0dae7e9b79c0182640d43626331010061
parent49bd4ed1e23b42fe7e952e869a7d91f45811040d
Add structured API request debug logging

Add a new "ApiRequest" PSR-3 logging channel for messages that describe
an Action API request as structured data. This logging channel can be
routed to a storage service to facilitate analysis of the requests.

The logging context is designed to match the following avro schema:

  {
      "type": "record",
      "name": "ApiRequest",
      "namespace": "org.wikimedia.mediawiki.api",
      "doc": "Describes an API request made via mediawiki ApiMain",
      "fields": [
          { "name": "dt",              "type": "string" },
          { "name": "client_ip",       "type": "string" },
          { "name": "user_agent",      "type": "string" },
          { "name": "wiki",            "type": "string" },
          { "name": "time_backend_ms", "type": "int" },
          { "name": "params",          "type": {
              "type": "map", "values": "string"
          } }
      ]
  }

Co-Author: Bryan Davis <bd808@wikimedia.org>
Bug: T108618
Change-Id: I38f5cdb288f332f75adca8a2d03fbe0fc36ab936
includes/api/ApiMain.php