Reporting Module sw.report

Classes

class sw.report.Report(pool)[source]

Report handles all the reporting events sent from the Pool, currently it exclusively sends these upstream to a Splunk server which then does further handling. The events are sent from the pool via calls to this instance’s functions that in turn call send().

Reporting can be disabled putting None (or a blank field) in the initial settings page. This has the same effect as not including the #report=”url” option within the options header of a script before conversion.

The reporting class also takes in the custom id="", run="", and project="" from kwargs / initial settings. It uses these settings when communicating unstream with the reporting server.

Parameters:pool – Reference to our owning pool. This is primarily to access pool.options and not used much elsewhere.
Returns:Report (self)
endChild(child)[source]

Sends a child process killed notification payload.

Parameters:child – The index of the child reporting in self.children/pool.data.
Returns:None
id()[source]

If self.id was not already set by the user, it generates a deterministic ID based on the user running the script and the machine’s name.

Returns:None
jobFail(error, child, screenshot=None)[source]

Sends a job failed notification payload.

Parameters:
  • error – The error text that was included with the error.
  • child – The index of the child reporting in pool.children/pool.data.
  • screenshot (None) – A image from selenium’s screenshot to be encoded in base64 for sending (optional).
Returns:

None

jobFinish(timetaken, child)[source]

Sends a job finish notification payload.

Parameters:
  • timetaken – The time it took for the job to finish, recorded internally.
  • child – The index of the child reporting in pool.children/pool.data.
Returns:

None

jobStart(child)[source]

Sends a job start notification payload.

Parameters:child – The index of the child reporting in pool.children/pool.data.
Returns:None
newChild(child)[source]

Sends a new child notification payload. This is called even when a child is restarted.

Parameters:child – The index of the child reporting in self.children/pool.data.
Returns:None
send(payload, type)[source]

Send enables a payload to be parsed and added into our local queue for transmission reporting server, where applicable. It is called as a sort of wrapper function from all of the individual reporting functions (such as endchild()) to facilitate standard transmission of the data upstream.

Currently (to be fixed) it encodes repeat information in every single payload including all identifying characteristics about the run, pool, and our id. There’s major issue for this except for further stressing network bandwidth and the JSON parser.

Parameters:
  • payload – A hash of information to send upstream to our reporting server.
  • type – The R_* constant identifier for the type of payload included.
sendSplunk(data)[source]

Sends data to a Splunk sever encoded in JSON.

Parameters:data – JSON of data to send to the splunk server.
Returns:The parsed splunk event on success.
start()[source]

Sends a start notification payload.

Returns:None
stop()[source]

Sends a stop notification payload.

Returns:None
think()[source]
The think function called by our pool periodically. It handles the transmission of

our payload (many individual reports) to the Splunk server.

If our report.queue has content in it, it prepares to send everything upstream. The payload is transmitted in JSON with the following general format:

{ 
   "cid" => #, // Our client ID assigned by the server, nil if we don't have one yet.
   "rid" => #, // Our run ID assined by the server, ^
   "type" => R_START,    // For example, this is the type of payload here.
   "time" => UNIX_EPOCH, // Since sometimes the Queue has a delay in transmission, each
                         // payload contains it own timestamp.
   // Some miscellaneous identifying information goes in here that's deprecated
   // and unused.

   // If the type involves a child:
   "ChildID" => #, // The index of our child in pool.children / pool.data

   // If the type involves a job:
   "timetaken" => UNIX_EPOCH //The time the job took to complete.
}

This module attempts to send the payload upstream 5 times, waiting 5 seconds between reattempts. On the fifth failure it never tries again. It is noted in the log when it gives up.

Returns:None

Table Of Contents

Previous topic

UI Module sw.ui

Next topic

InitialSettings Module sw.initialsettings

This Page