← Back to team overview

yahoo-eng-team team mailing list archive

[Bug 1604306] [NEW] [RFE] Log request_id for each api call

 

Public bug reported:

Blueprint [1] is up for review in the last Mitaka release cycle which
returns request_id back to the caller as per design proposed in the
cross-project specs [2]. Now, in step 2, we would like to log x
-openstack-request-id returned in the response header using the python
logging module.

Following log message will be logged in debug logging level.

_logger.debug('%(method)s call to neutron for '
                          '%(url)s used request id '
                          '%(response_request_id)s',
                          {'method': resp.request.method,
                           'url': resp.url,
                           'response_request_id': request_id})

method: HTTP request method (GET/POST/PUT/DELETE etc.)
my_url: Request URL with endpoint
response_request_id: request_id extracted from response header

The log messages logged by the log handlers would be dependant on how
the root loggers are configured.

1. python-neutronclient used as a shell command:

In this case, the root loggers will be configured in the client itself.
So if --debug flag is passed in the command, then following log message
will be shown on console:-

DEBUG: neutronclient.v2_0.client GET call to neutron for
http://127.0.0.1:9696/v2.0/networks.json used request id req-
bbf8ce60-19d0-44d8-b868-cd39e86d7211

Nothing will be logged on console if --debug flag is not set.

2. python-neutronclient is used in applications (e.g. Nova)

In this case, when Nova calls apis of neutron service using python-
neutronclient, then following log message for get port-create api will
be logged in nova log file:-

DEBUG neutronclient.v2_0.client [req-35c6216e-53f1-4cb9-965a-
5c1e5f532921 demo demo] POST call to neutron for
http://127.0.0.1:9696/v2.0/ports.json used request id req-
b7d44a15-137c-4760-bb77-3042d18ef0a5

In the above log message, you will see both nova (callee) and neutron
(caller) request_ids are logged in the same log message. This is
because, the root loggers are configured in Nova and the same will be
used by the client as well. Since nova uses oslo.log library, it
internally logs request_id using ContextFormatter configured in the
"formatter_context" section of the nova configuration file.

This feature already have been in novaclient, cinderclient and
glanceclient[3, 4, 5].

References:
[1] https://blueprints.launchpad.net/python-neutronclient/+spec/return-request-id-to-caller
[2] http://specs.openstack.org/openstack/openstack-specs/specs/return-request-id.html
[3] https://review.openstack.org/322664
[4] https://review.openstack.org/315925
[5] https://review.openstack.org/331981

Mailing List discussion:
http://lists.openstack.org/pipermail/openstack-dev/2016-March/088001.html

** Affects: neutron
     Importance: Undecided
     Assignee: Hirofumi Ichihara (ichihara-hirofumi)
         Status: New


** Tags: rfe

** Changed in: neutron
     Assignee: (unassigned) => Hirofumi Ichihara (ichihara-hirofumi)

** Tags added: rfe

-- 
You received this bug notification because you are a member of Yahoo!
Engineering Team, which is subscribed to neutron.
https://bugs.launchpad.net/bugs/1604306

Title:
  [RFE] Log request_id for each api call

Status in neutron:
  New

Bug description:
  Blueprint [1] is up for review in the last Mitaka release cycle which
  returns request_id back to the caller as per design proposed in the
  cross-project specs [2]. Now, in step 2, we would like to log x
  -openstack-request-id returned in the response header using the python
  logging module.

  Following log message will be logged in debug logging level.

  _logger.debug('%(method)s call to neutron for '
                            '%(url)s used request id '
                            '%(response_request_id)s',
                            {'method': resp.request.method,
                             'url': resp.url,
                             'response_request_id': request_id})

  method: HTTP request method (GET/POST/PUT/DELETE etc.)
  my_url: Request URL with endpoint
  response_request_id: request_id extracted from response header

  The log messages logged by the log handlers would be dependant on how
  the root loggers are configured.

  1. python-neutronclient used as a shell command:

  In this case, the root loggers will be configured in the client
  itself. So if --debug flag is passed in the command, then following
  log message will be shown on console:-

  DEBUG: neutronclient.v2_0.client GET call to neutron for
  http://127.0.0.1:9696/v2.0/networks.json used request id req-
  bbf8ce60-19d0-44d8-b868-cd39e86d7211

  Nothing will be logged on console if --debug flag is not set.

  2. python-neutronclient is used in applications (e.g. Nova)

  In this case, when Nova calls apis of neutron service using python-
  neutronclient, then following log message for get port-create api will
  be logged in nova log file:-

  DEBUG neutronclient.v2_0.client [req-35c6216e-53f1-4cb9-965a-
  5c1e5f532921 demo demo] POST call to neutron for
  http://127.0.0.1:9696/v2.0/ports.json used request id req-
  b7d44a15-137c-4760-bb77-3042d18ef0a5

  In the above log message, you will see both nova (callee) and neutron
  (caller) request_ids are logged in the same log message. This is
  because, the root loggers are configured in Nova and the same will be
  used by the client as well. Since nova uses oslo.log library, it
  internally logs request_id using ContextFormatter configured in the
  "formatter_context" section of the nova configuration file.

  This feature already have been in novaclient, cinderclient and
  glanceclient[3, 4, 5].

  References:
  [1] https://blueprints.launchpad.net/python-neutronclient/+spec/return-request-id-to-caller
  [2] http://specs.openstack.org/openstack/openstack-specs/specs/return-request-id.html
  [3] https://review.openstack.org/322664
  [4] https://review.openstack.org/315925
  [5] https://review.openstack.org/331981

  Mailing List discussion:
  http://lists.openstack.org/pipermail/openstack-dev/2016-March/088001.html

To manage notifications about this bug go to:
https://bugs.launchpad.net/neutron/+bug/1604306/+subscriptions


Follow ups