Collector

Collector will convert data_t to Tracking and store them in a somewhere.

class duetector.collectors.base.Collector(config: dict[str, Any] | None = None, *args, **kwargs)[source]

Base class for all collectors, provide a ThreadPoolExecutor each instance for async emit.

By default, the config scope of Collector is collector.{class_name}.

Implementations should override _emit and summary method, see DequeCollector as an example.

_backend_imp

Default backend implementation for Collector

alias of ThreadPoolExecutor

_emit(t: Tracking)[source]

Emit a tracking to collector, should be implemented by subclasses

property backend_args

Arguments for backend self._backend_imp

property config_scope

Config scope for current collector

default_config = {'backend_args': {'max_workers': 10}, 'disabled': False, 'statis_id': ''}

Default config for Collector

property disabled

If current collector is disabled

emit(tracer, data: namedtuple)[source]

Wrapper for self._emit, submit to backend executor

property id: str

ID for current collector, used to identify current collector in database

If not set, use hostname

shutdown()[source]

Shutdown backend executor

summary() dict[source]

Get summary of current collector, should be implemented by subclasses

class duetector.collectors.base.DequeCollector(config: dict[str, Any] | None = None, *args, **kwargs)[source]

Bases: Collector

A simple collector using deque, disabled by default

Config:
  • maxlen: Max length of deque

_emit(t: Tracking)[source]

Emit a tracking to collector, should be implemented by subclasses

default_config = {'backend_args': {'max_workers': 10}, 'disabled': True, 'maxlen': 1024, 'statis_id': ''}

Default config for DequeCollector

property maxlen

Max length of deque

summary() dict[source]

Get summary of current collector, should be implemented by subclasses

Avaliable Collector

Data Models