opsis
2026-11-29
Condition-based observability for Common Lisp
Opsis (ὄψις)
Condition-based observability for Common Lisp. Libraries signal structured events. Applications decide what to do with them.
;; In your library — zero dependencies (opsis/c:emit :tool-exec-completed :level :info :source "my-tool" :data '(:duration-ms 42 :result-size 1024)) ;; In your application — plug in what you need (opsis:with-observability ((opsis:default-sinks)) (opsis/c:with-correlation () (run-my-application)))
Output:
2026-02-25T14:30:02 [INFO] [ax7f3b2c] my-tool/tool-exec-completed (:DURATION-MS 42 :RESULT-SIZE 1024)
Comes with 2 SKILLS for development or integration. Point your agent to the project and it will figure out how to use it.
Why
Most CL observability tools bind the library author to a format, a destination, or a performance cost. Opsis inverts this. Libraries call emit — a thin wrapper around cl:signal — and pay nothing if no handlers are installed. Applications install sinks that decide how to format, filter, and route events.
This is the CL condition system used as an observability bus:
- Near-zero overhead when unused — unhandled
signalreturns immediately - No format coupling — the event carries a keyword kind and a raw data plist; sinks render it
- Structural composability —
with-observabilitynests naturally viahandler-bind - Rich payloads —
datacarries arbitrary CL objects, not pre-formatted strings - Automatic correlation — events capture
*correlation-id*from dynamic scope
Install
Clone to your Quicklisp local-projects directory and load:
(ql:quickload "opsis/conditions") ; signaling only — zero deps (ql:quickload "opsis") ; full system: sinks + with-observability (ql:quickload "opsis/vigil") ; optional vigil metrics sink
The Two Roles
Library author: signal, don't decide
Depend only on opsis/conditions (zero external dependencies):
(ql:quickload "opsis/conditions") ;; Emit at key lifecycle points (opsis/c:emit :request-received :source "my-lib" :level :info :data (list :method method)) (opsis/c:emit :request-failed :source "my-lib" :level :error :message (princ-to-string condition) :data (list :method method))
Calls to emit are silent no-ops if no application has installed a sink. Near-zero overhead (one function call, no I/O).
Application: install sinks, own the output
;; One-liner sensible default — stderr at :warn (opsis:with-observability ((opsis:default-sinks)) (run-server)) ;; Custom configuration (vigil-sink requires opsis/vigil loaded) (opsis:with-observability ((make-instance 'opsis:stderr-sink :name "console" :min-level :debug) (make-instance 'opsis:vigil-sink :name "metrics" :store my-vigil-store)) (run-server))
Correlation IDs
Wrap request boundaries in with-correlation. All events inside automatically carry the same ID:
(opsis/c:with-correlation () ;; All emit calls here share one correlation ID (handle-request req)) ;; Propagate to sub-processes (opsis/c:with-correlation (opsis/c:*correlation-id*) (delegate-to-worker task))
The stderr-sink includes the ID in every output line. Post-mortem: grep by correlation ID to trace a complete interaction.
Custom Sinks
Subclass sink using telos:defclass/i (plain defclass will fail — sink uses the telos:intentful-class metaclass), then implement sink-handle:
(telos:defclass/i my-sink (opsis:sink) () (:role "alert forwarder") (:purpose "send errors to external alerting")) (defmethod opsis:sink-handle ((sink my-sink) event) (when (eq :error (opsis/c:event-level event)) (alert-pagerduty (opsis/c:event-message event))))
Override sink-accepts-p for custom filtering beyond level:
(defmethod opsis:sink-accepts-p ((sink my-sink) event) (and (call-next-method) (string= "my-lib" (opsis/c:event-source event))))
Event Slots
| Slot | Reader | Type | Default |
|---|---|---|---|
| kind | event-kind | keyword | required |
| level | event-level | :debug :info :warn :error | :info |
| message | event-message | string or nil | nil |
| data | event-data | any | nil |
| source | event-source | string or nil | nil |
| correlation | event-correlation | string or nil | *correlation-id* |
| timestamp | event-timestamp | universal-time | (get-universal-time) |
Systems
| System | Purpose | Dependencies |
|---|---|---|
opsis/conditions | emit, event condition, correlation | none |
opsis | Sink protocol, with-observability, stderr/null sinks | opsis/conditions, bordeaux-threads, local-time, telos |
opsis/vigil | Vigil metrics sink | opsis, vigil |
Tests
(asdf:test-system "opsis/conditions") ; conditions tests (asdf:test-system "opsis") ; sinks + integration tests (asdf:test-system "opsis/vigil") ; vigil sink tests
Documentation
| Document | Purpose |
|---|---|
| Design doc | Architecture decisions, system design |
| Dev skill | Working on opsis (contributors) |
| Integration skill | Using opsis in another project (agent-oriented) |
Status
Under active development. API is stabilising. Not yet in Quicklisp.
License
MIT. Copyright 2026 Abhijit Rao (quasi / quasiLabs).