The oslo_reports.guru_meditation_report Module

Provides Guru Meditation Report

This module defines the actual OpenStack Guru Meditation Report class.

This can be used in the OpenStack command definition files. For example, in a nova command module (under nova/cmd):

from oslo_config import cfg
from oslo_log import log as oslo_logging
from oslo_reports import opts as gmr_opts
from oslo_reports import guru_meditation_report as gmr

CONF = cfg.CONF
# maybe import some options here...

def main():
    oslo_logging.register_options(CONF)
    gmr_opts.set_defaults(CONF)

    CONF(sys.argv[1:], default_config_files=['myapp.conf'])
    oslo_logging.setup(CONF, 'myapp')

    gmr.TextGuruMeditation.register_section('Some Special Section',
                                        special_section_generator)
    gmr.TextGuruMeditation.setup_autorun(version_object, conf=CONF)

    server = service.Service.create(binary='some-service',
                                    topic=CONF.some_service_topic)
    service.serve(server)
    service.wait()

Then, you can do

$ kill -USR2 $SERVICE_PID

and get a Guru Meditation Report in the file or terminal where stderr is logged for that given service.

class oslo_reports.guru_meditation_report.GuruMeditation(version_obj, sig_handler_tb=None, *args, **kwargs)

Bases: object

A Guru Meditation Report Mixin/Base Class

This class is a base class for Guru Meditation Reports. It provides facilities for registering sections and setting up functionality to auto-run the report on a certain signal or use file modification events.

This class should always be used in conjunction with a Report class via multiple inheritance. It should always come first in the class list to ensure the MRO is correct.

classmethod handle_signal(version, service_name, log_dir, frame)

The Signal Handler

This method (indirectly) handles receiving a registered signal and dumping the Guru Meditation Report to stderr or a file in a given dir. If service name and log dir are not None, the report will be dumped to a file named $service_name_gurumeditation_$current_time in the log_dir directory. This method is designed to be curried into a proper signal handler by currying out the version parameter.

Parameters:
  • version – the version object for the current product
  • service_name – this program name used to construct logfile name
  • logdir – path to a log directory where to create a file
  • frame – the frame object provided to the signal handler
classmethod register_section(section_title, generator)

Register a New Section

This method registers a persistent section for the current class.

Parameters:
  • section_title (str) – the title of the section
  • generator – the generator for the section
run()
classmethod setup_autorun(version, service_name=None, log_dir=None, signum=None, conf=None)

Set Up Auto-Run

This method sets up the Guru Meditation Report to automatically get dumped to stderr or a file in a given dir when the given signal is received. It can also use file modification events instead of signals.

Parameters:
  • version – the version object for the current product
  • service_name – this program name used to construct logfile name
  • logdir – path to a log directory where to create a file
  • signum – the signal to associate with running the report
  • conf – Configuration object, managed by the caller.
timestamp_fmt = '%Y%m%d%H%M%S'
class oslo_reports.guru_meditation_report.TextGuruMeditation(version_obj, traceback=None)

Bases: oslo_reports.guru_meditation_report.GuruMeditation, oslo_reports.report.TextReport

A Text Guru Meditation Report

This report is the basic human-readable Guru Meditation Report

It contains the following sections by default (in addition to any registered persistent sections):

  • Package Information
  • Threads List
  • Green Threads List
  • Process List
  • Configuration Options
Parameters:
  • version_obj – the version object for the current product
  • traceback – an (optional) frame object providing the actual traceback for the current thread