lsst.dax.apdb gbeadb96d05+a322446fe6
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
lsst.dax.apdb.monitor.MonService Class Reference
Inheritance diagram for lsst.dax.apdb.monitor.MonService:

Public Member Functions

None set_filters (self, Iterable[str] rules)
 
Iterable[MonHandlerhandlers (self)
 
None add_handler (self, MonHandler handler)
 
None remove_handler (self, MonHandler handler)
 
Iterator[None] context_tags (self, _TagsType tags)
 

Protected Member Functions

None _add_record (self, *str agent_name, str record_name, Mapping[str, Any] values, Mapping[str, str|int]|None tags=None, float|None timestamp=None)
 
_TagsType|None _add_context_tags (self, _TagsType tags)
 

Protected Attributes

 _filters
 
 _context_tags
 

Static Protected Attributes

list _handlers = []
 
_TagsType _context_tags = None
 
list _filters = []
 

Detailed Description

Class implementing monitoring service functionality.

Notes
-----
This is a singleton class which serves all client agents in an application.
It accepts records from agents, filters it based on a set of configured
rules and forwards them to one or more configured handlers. By default
there are no handlers defined which means that all records are discarded.
Default set of filtering rules is empty which accepts all agent names.

To produce a useful output from this service one has to add at least one
handler using `add_handler` method (e.g. `LoggingMonHandler` instance).
The `set_filters` methods can be used to specify the set of filtering
rules.

Member Function Documentation

◆ _add_context_tags()

_TagsType | None lsst.dax.apdb.monitor.MonService._add_context_tags ( self,
_TagsType tags )
protected
Extend the tag context with new tags, overriding any tags that may
already exist in a current context.

◆ _add_record()

None lsst.dax.apdb.monitor.MonService._add_record ( self,
*str agent_name,
str record_name,
Mapping[str, Any] values,
Mapping[str, str | int] | None tags = None,
float | None timestamp = None )
protected
Add one monitoring record, this method is for use by agents only.

◆ add_handler()

None lsst.dax.apdb.monitor.MonService.add_handler ( self,
MonHandler handler )
Add one monitoring handler.

Parameters
----------
handler : `MonHandler`
    Handler instance.

◆ context_tags()

Iterator[None] lsst.dax.apdb.monitor.MonService.context_tags ( self,
_TagsType tags )
Context manager that adds a set of tags to all records created
inside the context.

Typically clients will be using `MonAgent.context_tags`, which forwards
to this method.

◆ handlers()

Iterable[MonHandler] lsst.dax.apdb.monitor.MonService.handlers ( self)
Set of handlers defined currently.

◆ remove_handler()

None lsst.dax.apdb.monitor.MonService.remove_handler ( self,
MonHandler handler )
Add one monitoring handler.

Parameters
----------
handler : `MonHandler`
    Handler instance.

◆ set_filters()

None lsst.dax.apdb.monitor.MonService.set_filters ( self,
Iterable[str] rules )
Define a sequence of rules for filtering of the agent names.

Parameters
----------
rules : `~collections.abc.Iterable` [`str`]
    Ordered collection of rules.  Each string specifies filtering rule
    for a single name, or catch-all rule.  The rule consist of the
    agent name prefixed by minus or optional plus sign. Catch-all rule
    uses name "any". If the rule starts with minus sign then matching
    agent will be rejected. Otherwise matching agent is accepted.

Notes
-----
The catch-all rule (`-any`, `+any`, or `any`) can be specified in any
location in the sequence but it is always applied last. E.g.
`["-any", "+agent1"]` behaves the same as `["+agent1", "-any"]`.
If the set of rues does not include catch-all rule, filtering behaves
as if it is added implicitly as `+any`.

Filtering code evaluates each rule in order. First rule that matches
the agent name wins. Agent names are matched literally, wildcards are
not supported and there are no parent/child relations between agent
names (e.g `lsst.dax.apdb` and `lsst.dax.apdb.sql` are treated as
independent names).

The documentation for this class was generated from the following file: