Senders

Development

class metlog.senders.dev.DebugCaptureSender(**kwargs)[source]

Capture up to 100 metlog messages in a circular buffer for inspection later. This is only for DEBUGGING. Do not use this for anything except development.

__weakref__

list of weak references to the object (if defined)

send_message(msg)[source]

JSONify and append to the circular buffer.

class metlog.senders.dev.FileSender(filepath, *args, **kwargs)[source]

Emits messages to a filesystem file.

class metlog.senders.dev.StdOutSender(*args, **kwargs)[source]

Emits metlog messages to stdout.

class metlog.senders.dev.StreamSender(stream, formatter=None)[source]

Emits messages to a provided stream object.

__init__(stream, formatter=None)[source]
Parameters:
  • stream – Stream object to which the messages should be written.
  • formatter – Optional callable (or dotted name identifier) that accepts a msg dictionary and returns a formatted string to be written to the stream.
__weakref__

list of weak references to the object (if defined)

default_formatter(msg)[source]

Default formatter, just converts the message to 4-space-indented JSON.

send_message(msg)[source]

Deliver message to the stream object.

ZeroMQ

class metlog.senders.zmq.Pool(client_factory, size=10, livecheck=10)[source]

This is a threadsafe pool of 0mq clients.

Parameters:
  • client_factory – a factory function that creates Client instances
  • size – The number of clients to create in the pool
  • livecheck – The time in seconds to wait to ping the server from each client
__weakref__

list of weak references to the object (if defined)

send(msg)[source]

Threadsafely send a single text message over a 0mq socket

start_reconnecting()[source]

Start the background thread that handles pings to the server to synchronize the initial pub/sub

stop()[source]

Shutdown the background reconnection thread

class metlog.senders.zmq.ZmqHandshakePubSender(handshake_bind, connect_bind, handshake_timeout, pool_size=10, hwm=200, livecheck=10, debug_stderr=False)[source]

Sends metlog messages out via a ZeroMQ publisher socket.

Redirect all dropped messages to stderr

__init__(handshake_bind, connect_bind, handshake_timeout, pool_size=10, hwm=200, livecheck=10, debug_stderr=False)[source]
Parameters:
  • handshake_bind – A single 0mq recognized endpoint URL. This should point to the endpoint for handshaking of connections
  • connect_bind – A single 0mq recognized endpoint URL. This should point ot the endpoint for sending actual Metlog messages.
  • handshake_timeout – Timeout in ms to wait for responses from the 0mq server on handshake
  • pool_size – The number of connections we maintain to the 0mq backend
  • hwm – High water mark. Set the maximum number of messages to queue before dropping messages in case of a slow reading 0mq server.
  • livecheck – Polling interval in seconds between client.connect() calls
  • debug_stderr – Boolean flag to send messages to stderr in addition to the actual 0mq socket
class metlog.senders.zmq.ZmqPubSender(bindstrs, pool_size=10, queue_length=1000, livecheck=10, debug_stderr=False)[source]

Sends metlog messages out via a ZeroMQ publisher socket.

__init__(bindstrs, pool_size=10, queue_length=1000, livecheck=10, debug_stderr=False)[source]
Parameters:
  • bindstrs – One or more URL strings which 0mq recognizes as an endpoint URL. Either a string or a list of strings is accepted.
  • pool_size – The number of connections we maintain to the 0mq backend
  • livecheck – Polling interval in seconds between client.connect() calls
  • debug_stderr – Boolean flag to send messages to stderr in addition to the actual 0mq socket
class metlog.senders.zmq.ZmqSender[source]

Base class for ZmqPubSender and ZmqHandshakePubSender

static __new__(*args, **kwargs)[source]

Just check that we have pyzmq installed

__weakref__

list of weak references to the object (if defined)

send_message(msg)[source]

Serialize and send a message off to the metlog listener.

Parameters:msg – Dictionary representing the message.

UDP

class metlog.senders.udp.UdpSender(host, port)[source]

Sends metlog messages out via a UDP socket.

__init__(host, port)[source]

Create UdpSender object.

Parameters:
  • host – A string or sequence of strings representing the hosts to which messages should be delivered.
  • port – An integer or sequence of integers representing the ports to which the messages should be delivered. Will be zipped w/ the provided hosts to generate host/port pairs. If there are extra hosts, the last port in the sequence will be repeated for each extra host. If there are extra ports they will be truncated and ignored.
__weakref__

list of weak references to the object (if defined)

send_message(msg)[source]

Serialize and send a message off to the metlog listener(s).

Parameters:msg – Dictionary representing the message.
Read the Docs v: latest
Versions
latest
Downloads
PDF
HTML
Epub
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.