Observability¶
xcoreSDK provides declarative observability: tracing, metrics, and health checks — all via decorators.
get_logger¶
Returns a structured logger namespaced under plugin.<name>.
Inside a plugin, self.logger is pre-wired via ObservabilityMixin:
@traced¶
Wraps a handler in a distributed tracing span. No-ops gracefully when self.ctx.tracer is None.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
span_name |
str \| None |
function name | Name for the tracing span |
On exception, the span is marked with status="error" before re-raising.
@counted¶
Increments a counter metric after every successful call.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
metric_name |
str |
— | Counter name in self.ctx.metrics |
labels |
dict \| None |
None |
Optional label dimensions |
No-ops when self.ctx.metrics is unavailable.
@timed¶
Records handler duration as a histogram observation.
Parameters
| Name | Type | Description |
|---|---|---|
metric_name |
str |
Histogram name in self.ctx.metrics |
Duration is measured from call entry to return, including any awaited I/O.
@health_check¶
Registers a method as a health check with the kernel's health registry.
Parameters
| Name | Type | Description |
|---|---|---|
check_name |
str |
Identifier exposed in /health endpoint |
Return value: tuple[bool, str] — (healthy, message).
Health checks are registered during on_load by ObservabilityMixin and unregistered during on_unload.
ObservabilityMixin¶
Composed by AutoMixin. Provides:
self.loggerproperty — pre-namespaced logger- Auto-registration of all
@health_check-decorated methods duringon_load - Auto-cleanup during
on_unload
No manual wiring needed when using AutoMixin.
Direct metrics access¶
For custom metric operations beyond the decorator API:
Available when self.ctx.metrics is not None (i.e., the metrics service is registered).