Inherits: 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’s (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
BeginTrace
Begins recording an operation trace.
publicTraceTiming BeginTrace(string correlationId, string component, string operation)
- correlationId: string - (optional) transaction id used to trace execution through the call chain.
- component: string - name of a called component
- operation: string - name of the executed operation.
- return: TraceTiming - trace timing object.
Clear
Clears (removes) all cached log messages.
publicvoid Clear()
Configure
Configures a component by passing its configuration parameters.
public voidConfigure(ConfigParams config)
- config: ConfigParams - configuration parameters to be set.
Dump
Dumps (writes) the currently cached log messages.
publicvoid Dump()
Failure
Records an operation failure with its name, duration and error.
publicvoid Failure(string correlationId, string component, string operation, Exception error, long duration)
- correlationId: string - (optional) transaction id used to trace execution through the call chain.
- component: string - name of the called component
- operation: string - name of the executed operation.
- error: Exception - error object associated with this trace.
- duration: long - execution duration in milliseconds.
SetReferences
Sets references to dependent components.
publicvoid SetReferences(IReferences references)
- references: IReferences - references to locate the component’s dependencies.
Trace
Records an operation trace with its name and duration.
publicvoid Trace(string correlationId, string component, string operation, long duration)
- correlationId: string - (optional) transaction id used to trace execution through the call chain.
- component: string - name of the called component
- operation: string - name of the executed operation.
- duration: long - execution duration in milliseconds.
Update
Sets trace cache as updated and dumps it when timeout expires.
protectedvoid Update()
Write
Writes a log message to the logger destination.
protectedvoid Write(string correlationId, string component, string operation, Exception error, long duration)
- correlationId: string - (optional) transaction id used to trace execution through the call chain.
- component: string - name of the called component
- operation: string - name of the executed operation.
- error: Exception - error object associated with this trace.
- duration: long - execution duration in milliseconds.
Abstract methods
Save
Saves log messages from the cache. Throws error if not done.
protected abstractvoid Save(IList<OperationTrace> messages)
- messages: IList<OperationTrace> - list with log messages