Observability SDK¶
The SDK provides declarative decorators and direct properties on TrustedBase to instrument your plugins without boilerplate.
Direct Properties¶
Any plugin inheriting from TrustedBase has access to these properties without any configuration:
| Property | Type | Description |
|---|---|---|
self.logger |
XcoreLogger |
Structured logger bound to the plugin namespace |
self.metrics |
MetricsRegistry |
Metrics registry |
self.tracer |
Tracer |
Tracer for spans |
self.health |
HealthChecker |
Health checks registry |
1. Structured Logging¶
Structured logger — accepts arbitrary kwargs as contextual fields.
Outside of a plugin, use get_logger directly:
2. Tracing Decorator¶
Wraps a method in a tracing span. No-op if self.tracer is None.
If an exception occurs, the span is marked as status="error" before the exception is re-raised.
| Parameter | Type | Default | Description |
|---|---|---|---|
span_name |
str \| None |
function name | Name of the span in the tracer |
3. Metrics Decorators¶
@counted¶
Increments a counter after each successful call. No-op if self.metrics is None.
| Parameter | Type | Default | Description |
|---|---|---|---|
metric_name |
str |
— | Name of the counter in self.metrics |
@timed¶
Records the execution duration in a histogram. No-op if self.metrics is None.
The duration is measured from method entry to exit, including any awaited I/O.
| Parameter | Type | Default | Description |
|---|---|---|---|
metric_name |
str |
— | Name of the histogram in self.metrics |
4. Health Checks Decorator¶
Marks a method as a health check. The method must return (bool, str).
Checks are registered automatically in self.ctx.health during on_load() via ObservabilityMixin.
| Parameter | Type | Default | Description |
|---|---|---|---|
check_name |
str |
— | Identifier exposed in GET /ipc/health |
ObservabilityMixin¶
Provides:
- Automatic registration of all
@health_checkmethods duringon_load() - Injection of
self.logger,self.metrics,self.tracer, andself.health
Decorator Combination¶
Decorators can be combined. Recommended order: @traced → @counted → @timed (from outside to inside).
Advanced Usage¶
For operations not covered by decorators: