Observability Decorators
Define TypeScript tracing, metrics, structured logging, health checks, SLOs, critical execution paths, and telemetry sampling with AxilJS semantic decorators.
Observability Decorators
Observability decorators declare telemetry behavior at the method level. They reduce instrumentation boilerplate while allowing an observability consumer to handle the underlying telemetry mechanics.
@tTrace
tTrace declares a distributed trace span around a method.
The trace name identifies the operation, while optional tags provide additional metadata for the trace.
@tMetric
tMetric records a metric for each invocation.
AxilJS supports the following metric types:
| Type | Description |
|---|---|
'counter' | Monotonically increasing count |
'gauge' | Point-in-time value |
'histogram' | Distribution of values |
'summary' | Quantile-based distribution |
@tLog
tLog emits structured log entries at method boundaries.
This allows logging intent and relevant context to be declared alongside the operation instead of embedding instrumentation throughout the business logic.
@tHealthCheck
tHealthCheck registers a method as a health-check probe.
The decorator identifies the operation as a health-check probe; the method provides the actual check.
@tSlo
tSlo declares a service-level objective for an operation.
This expresses the expected latency objective and percentile as semantic metadata.
@tCritical
tCritical marks a method as a critical execution path for elevated monitoring.
This is useful for operations where failures or performance degradation require increased monitoring attention.
@tSample
tSample controls telemetry sampling for high-volume operations.
A sampling rate of 0.1 declares a 10% telemetry sampling rate for the operation.
Full Observability Stack
Observability semantics can be composed with HTTP and request metadata:
One method can therefore declare its API contract, distributed tracing, metrics, latency objective, criticality, and structured logging requirements without embedding those concerns directly into the business operation.
Reference
| Decorator | Purpose |
|---|---|
tTrace | Declare distributed tracing |
tMetric | Record operation metrics |
tLog | Emit structured logs |
tHealthCheck | Register a health-check probe |
tSlo | Declare a service-level objective |
tCritical | Mark a critical execution path |
tSample | Control telemetry sampling |
These decorators are semantic declarations. The metadata can be consumed by an observability implementation rather than coupling application code directly to a particular telemetry provider. AxilJS's consumer model separates metadata declaration from runtime behavior.