[openstack-dev] [oslo][oslo.log] JSON logs are missing the request ID
Saverio Proto
saverio.proto at switch.ch
Tue Jan 23 09:21:37 UTC 2018
Hello Doug,
I have run the script:
here is my output:
http://paste.openstack.org/show/650913/
At this point I have some questions. Can I upgrade just oslo.log library
keeping the rest of the stuff in Newton ?
The versions of oslo.log have a different numbering scheme than other
openstack projects, so I cannot understand the versions compatibility.
As far as I understand 3.34.0 should be enough for me ? :
git tag --contains 1b012d0fc6811f00e032e52ed586fe37e157584d
3.34.0
3.35.0
3.36.0
thank you
Saverio
On 22.01.18 23:20, Doug Hellmann wrote:
> Excerpts from Saverio Proto's message of 2018-01-22 18:45:15 +0100:
>> Hello Doug,
>>
>> in the extra session I see just {"project": "unknown", "version": "unknown"}
>>
>> here a full line from nova-api:
>>
>> {"thread_name": "MainThread", "extra": {"project": "unknown", "version":
>> "unknown"}, "process": 31142, "relative_created": 3459415335.4091644,
>> "module": "wsgi", "message":
>> "2001:xxx:xxxx:8100::80,2001:xxx:xxxx:81ff::b0 \"GET
>> /v2/64b5b50eb21d4efe9783eb1d81a9ec65/os-services HTTP/1.1\" status: 200
>> len: 1812 time: 0.1813300", "hostname": "nova-0", "filename": "wsgi.py",
>> "levelno": 20, "lineno": 555, "asctime": "2018-01-22 18:37:02,312",
>> "msg": "2001:xxx:xxxx:8100::80,2001:xxx:xxxx:81ff::b0 \"GET
>> /v2/64b5b50eb21d4efe9783eb1d81a9ec65/os-services HTTP/1.1\" status: 200
>> len: 1812 time: 0.1813300", "args": [], "process_name": "MainProcess",
>> "name": "nova.osapi_compute.wsgi.server", "thread": 140414249163824,
>> "created": 1516642622.312235, "traceback": null, "msecs":
>> 312.23511695861816, "funcname": "handle_one_response", "pathname":
>> "/usr/lib/python2.7/dist-packages/eventlet/wsgi.py", "levelname": "INFO"}
>
> It looks like you're running into a limitation of the older version of
> the library where the context was only logged from openstack source
> code. This particular log message is coming from the eventlet library.
>
> Try running the script below and saving the output to a pastebin.
>
> Under the newton version of oslo.log, I get
> http://paste.openstack.org/show/650566/ and under the queens version I
> get http://paste.openstack.org/show/650569/ which shows me that the
> "extra" handling is working more or less the same way but the "context"
> handling is improved in the newer version (lots of the values are null
> because I don't fully set up the context, but the request_id field has a
> valid value).
>
> Doug
>
>
> #!/usr/bin/env python
>
> from __future__ import print_function
>
> import logging
>
> from oslo_context import context
> from oslo_log import formatters, log
>
>
> ch = logging.StreamHandler()
> ch.setLevel(logging.DEBUG)
>
> formatter = formatters.JSONFormatter()
> ch.setFormatter(formatter)
>
> LOG = logging.getLogger()
> LOG.setLevel(logging.DEBUG)
> LOG.addHandler(ch)
>
> ctx = context.RequestContext(request_id='the-request-id')
>
> LOG.debug('without extra')
> print()
>
> LOG.debug('with extra', extra={'context': ctx})
> print()
>
> log.getLogger().debug('via KeywordArgumentAdapter', context=ctx)
>
> __________________________________________________________________________
> OpenStack Development Mailing List (not for usage questions)
> Unsubscribe: OpenStack-dev-request at lists.openstack.org?subject:unsubscribe
> http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev
>
--
SWITCH
Saverio Proto, Peta Solutions
Werdstrasse 2, P.O. Box, 8021 Zurich, Switzerland
phone +41 44 268 15 15, direct +41 44 268 1573
saverio.proto at switch.ch, http://www.switch.ch
http://www.switch.ch/stories
More information about the OpenStack-dev
mailing list