Implements: ITracer, IReconfigurable, IReferenceable
Description
The CachedTracer class allows you to create a tracer that caches the recorded traces in memory and periodically dumps them.
Important points
- Child classes implement saving cached traces to their specified destinations.
Configuration parameters
- source: source (context) name
- options:
- interval: interval in milliseconds to save log messages (default: 10 seconds)
- max_cache_size: maximum number of messages stored in this cache (default: 100)
References
- *:context-info:*:*:1.0 - (optional) ContextInfo to detect the context id and specify counters source
Fields
Instance methods
begin_trace
Begins recording an operation trace.
begin_trace(context: Optional[IContext], component: str, operation: str): TraceTiming
- context: IContext - (optional) a context to trace execution through a call chain.
- component: str - name of a called component
- operation: str - name of the executed operation.
- return: TraceTiming - a trace timing object.
clear
Clears (removes) all cached log messages.
clear()
configure
Configures component by passing configuration parameters.
configure(config: ConfigParams)
- config: ConfigParams - configuration parameters to be set.
dump
Dumps (writes) the currently cached log messages.
dump()
failure
Records an operation failure with its name, duration and error.
failure(context: Optional[IContext], component: str, operation: str, error: Exception, duration: float)
- context: IContext - (optional) a context to trace execution through a call chain.
- component: str - name of the called component
- operation: str - name of the executed operation.
- error: Exception - an error object associated with this trace.
- duration: float - execution duration in milliseconds.
_save
Saves log messages from the cache. Throws error if not done.
abstractmethod
_save(messages: List[OperationTrace])
- messages: List[OperationTrace] - a list with log messages
set_references
Sets references to dependent components.
set_references(references: IReferences)
- references: IReferences - references to locate the component dependencies.
trace
Records an operation trace with its name and duration.
trace(context: Optional[IContext], component: str, operation: str, duration: float)
- context: IContext - (optional) a context to trace execution through a call chain.
- component: str - name of the called component
- operation: str - name of the executed operation.
- duration: float - execution duration in milliseconds.
_update
Sets trace cache as updated and dumps it when timeout expires.
_update()
_write
Writes a log message to the logger destination.
_write(context: Optional[IContext], component: str, operation: str, error: Optional[Exception], duration: float)
- context: IContext - (optional) a context to trace execution through a call chain.
- component: str - name of the called component
- operation: str - name of the executed operation.
- error: Optional[Exception] - an error object associated with this trace.
- duration: float - execution duration in milliseconds.