The reblocks-prometheus Reference Manual

This is the reblocks-prometheus Reference Manual, version 0.2.0, generated automatically by Declt version 4.0 beta 2 "William Riker" on Tue Jul 15 06:32:23 2025 GMT+0.

Table of Contents


1 Introduction


2 Systems

The main system appears first, followed by any subsystem dependency.


2.1 reblocks-prometheus

This is an addon for Reblocks Common Lisp framework which allows to gather metrics in Prometheus format.

Author

Alexander Artemenko

Home Page

https://40ants.com/reblocks-prometheus

Source Control

(GIT https://github.com/40ants/reblocks-prometheus)

Bug Tracker

https://github.com/40ants/reblocks-prometheus/issues

License

Unlicense

Long Description

<a id="x-28REBLOCKS-PROMETHEUS-DOCS-2FINDEX-3A-40README-2040ANTS-DOC-2FLOCATIVES-3ASECTION-29"></a>

# reblocks-prometheus - This is an addon for Reblocks Common Lisp framework which allows to gather metrics in Prometheus format.

<a id="reblocks-prometheus-asdf-system-details"></a>

## REBLOCKS-PROMETHEUS ASDF System Details

* Description: This is an addon for Reblocks Common Lisp framework which allows to gather metrics in Prometheus format.
* Licence: Unlicense
* Author: Alexander Artemenko
* Homepage: [https://40ants.com/reblocks-prometheus][0a5b]
* Bug tracker: [https://github.com/40ants/reblocks-prometheus/issues][8225]
* Source control: [GIT][d447]
* Depends on: [40ants-routes][25b9], [prometheus][14fa], [prometheus-gc][8b12], [prometheus.collectors.process][563a], [prometheus.collectors.sbcl][a01b], [prometheus.formats.text][b66b], [reblocks][184b]

[![](https://github-actions.40ants.com/40ants/reblocks-prometheus/matrix.svg?only=ci.run-tests)][1638]

![](http://quickdocs.org/badge/reblocks-prometheus.svg)

This is an addon for Reblocks Common Lisp framework which allows to gather
metrics in [Prometheus][df56] format.

<a id="x-28REBLOCKS-PROMETHEUS-DOCS-2FINDEX-3A-3A-40INSTALLATION-2040ANTS-DOC-2FLOCATIVES-3ASECTION-29"></a>

## Installation

You can install this library from Quicklisp, but you want to receive updates quickly, then install it from Ultralisp.org:

“‘
(ql-dist:install-dist "http://dist.ultralisp.org/"
:prompt nil)
(ql:quickload :reblocks-prometheus)
“‘
<a id="x-28REBLOCKS-PROMETHEUS-DOCS-2FINDEX-3A-3A-40USAGE-2040ANTS-DOC-2FLOCATIVES-3ASECTION-29"></a>

## Usage

Add a special metrics route into you’re app’s route list. Use [‘reblocks-prometheus:metrics‘][7ea2] macro to define this route.

“‘
(defapp app
:prefix "/"
:routes
((reblocks-prometheus:metrics (\"/metrics\" :user-metrics *user-metrics*)))
)
“‘
A new route ‘/metrics‘ will be added to serve metrics in Prometheus format.

<a id="adding-custom-metrics"></a>

### Adding custom metrics

To add business specific metrics, define them as global variables
and then the pass to the [‘reblocks-prometheus:metrics‘][7ea2] macro like this:

“‘
(defparameter *load-average*
(prometheus:make-gauge :name \"test_load_average\"
:help \"Test load average\"
:registry nil))

(defparameter *num-users*
(prometheus:make-counter :name \"test_num_users_created\"
:help \"Test num users created after the last metrics collection\"
:registry nil))

(defparameter *user-metrics*
(list *load-average*
*num-users*))

(defapp app
:prefix "/"
:routes
((reblocks-prometheus:metrics (\"/metrics\" :user-metrics *user-metrics*)))
)
“‘
After this, you can change this counter and gauge using methods from prometheus.cl library:

“‘
(prometheus:gauge.set *load-average* 2)

(prometheus:counter.inc *num-users* :value 1)
(prometheus:counter.inc *num-users* :value 3)
“‘
and their values will change during subsequent get queries for /metrics page.

<a id="x-28REBLOCKS-PROMETHEUS-DOCS-2FINDEX-3A-3A-40API-2040ANTS-DOC-2FLOCATIVES-3ASECTION-29"></a>

## API

<a id="x-28REBLOCKS-PROMETHEUS-DOCS-2FINDEX-3A-3A-40REBLOCKS-PROMETHEUS-3FPACKAGE-2040ANTS-DOC-2FLOCATIVES-3ASECTION-29"></a>

### REBLOCKS-PROMETHEUS

<a id="x-28-23A-28-2819-29-20BASE-CHAR-20-2E-20-22REBLOCKS-PROMETHEUS-22-29-20PACKAGE-29"></a>

#### [package](482f) ‘reblocks-prometheus‘

<a id="x-28REBLOCKS-PROMETHEUS-DOCS-2FINDEX-3A-3A-7C-40REBLOCKS-PROMETHEUS-3FClasses-SECTION-7C-2040ANTS-DOC-2FLOCATIVES-3ASECTION-29"></a>

#### Classes

<a id="x-28REBLOCKS-PROMETHEUS-DOCS-2FINDEX-3A-3A-40REBLOCKS-PROMETHEUS-24METRICS-ROUTE-3FCLASS-2040ANTS-DOC-2FLOCATIVES-3ASECTION-29"></a>

##### METRICS-ROUTE

<a id="x-28REBLOCKS-PROMETHEUS-3AMETRICS-ROUTE-20CLASS-29"></a>

###### [class](8f47) ‘reblocks-prometheus:metrics-route‘ (route)

**Readers**

<a id="x-28REBLOCKS-PROMETHEUS-3ASTATS-REGISTRY-20-2840ANTS-DOC-2FLOCATIVES-3AREADER-20REBLOCKS-PROMETHEUS-3AMETRICS-ROUTE-29-29"></a>

###### [reader](0156) ‘reblocks-prometheus:stats-registry‘ (metrics-route) (= (reblocks-prometheus/app::make-reblocks-metrics-registry))

<a id="x-28REBLOCKS-PROMETHEUS-DOCS-2FINDEX-3A-3A-40REBLOCKS-PROMETHEUS-24PROMETHEUS-APP-MIXIN-3FCLASS-2040ANTS-DOC-2FLOCATIVES-3ASECTION-29"></a>

##### PROMETHEUS-APP-MIXIN

<a id="x-28REBLOCKS-PROMETHEUS-3APROMETHEUS-APP-MIXIN-20CLASS-29"></a>

###### [class](6f7f) ‘reblocks-prometheus:prometheus-app-mixin‘ ()

A mixin which gathers some stats to report in Prometheus format.

Also, this mixin adds a /metrics slot to the app.

Use [‘stats-registry‘][b2a2] to access the registry slot.

<a id="x-28REBLOCKS-PROMETHEUS-DOCS-2FINDEX-3A-3A-7C-40REBLOCKS-PROMETHEUS-3FFunctions-SECTION-7C-2040ANTS-DOC-2FLOCATIVES-3ASECTION-29"></a>

#### Functions

<a id="x-28REBLOCKS-PROMETHEUS-3AMETRICS-REGISTRY-20FUNCTION-29"></a>

##### [function](3240) ‘reblocks-prometheus:metrics-registry‘

Call this function during handler’s body to update gauges before metrics will be collected.

<a id="x-28REBLOCKS-PROMETHEUS-DOCS-2FINDEX-3A-3A-7C-40REBLOCKS-PROMETHEUS-3FMacros-SECTION-7C-2040ANTS-DOC-2FLOCATIVES-3ASECTION-29"></a>

#### Macros

<a id="x-28REBLOCKS-PROMETHEUS-3AMETRICS-20-2840ANTS-DOC-2FLOCATIVES-3AMACRO-29-29"></a>

##### [macro](a770) ‘reblocks-prometheus:metrics‘ (path &key name user-metrics) &body handler-body

This macro creates a route of [‘metrics-route‘][863c] class.

The body passed as ‘HANDLER-BODY‘ will be executed each time when metrics are collected.
You can use [‘metrics-registry‘][e21f] function to access the prometheus metrics registry
from the handler body code.

[7ea2]: #x-28REBLOCKS-PROMETHEUS-3AMETRICS-20-2840ANTS-DOC-2FLOCATIVES-3AMACRO-29-29
[e21f]: #x-28REBLOCKS-PROMETHEUS-3AMETRICS-REGISTRY-20FUNCTION-29
[863c]: #x-28REBLOCKS-PROMETHEUS-3AMETRICS-ROUTE-20CLASS-29
[b2a2]: #x-28REBLOCKS-PROMETHEUS-3ASTATS-REGISTRY-20-2840ANTS-DOC-2FLOCATIVES-3AREADER-20REBLOCKS-PROMETHEUS-3AMETRICS-ROUTE-29-29
[0a5b]: https://40ants.com/reblocks-prometheus
[d447]: https://github.com/40ants/reblocks-prometheus
[1638]: https://github.com/40ants/reblocks-prometheus/actions
[6f7f]: https://github.com/40ants/reblocks-prometheus/blob/fe1b4387940bb4648f5854e61ce329334288e8a8/src/app.lisp#L38
[8f47]: https://github.com/40ants/reblocks-prometheus/blob/fe1b4387940bb4648f5854e61ce329334288e8a8/src/app.lisp#L78
[0156]: https://github.com/40ants/reblocks-prometheus/blob/fe1b4387940bb4648f5854e61ce329334288e8a8/src/app.lisp#L79
[3240]: https://github.com/40ants/reblocks-prometheus/blob/fe1b4387940bb4648f5854e61ce329334288e8a8/src/app.lisp#L87
[a770]: https://github.com/40ants/reblocks-prometheus/blob/fe1b4387940bb4648f5854e61ce329334288e8a8/src/app.lisp#L94
[482f]: https://github.com/40ants/reblocks-prometheus/blob/fe1b4387940bb4648f5854e61ce329334288e8a8/src/core.lisp#L1
[8225]: https://github.com/40ants/reblocks-prometheus/issues
[df56]: https://prometheus.io/
[25b9]: https://quickdocs.org/40ants-routes
[14fa]: https://quickdocs.org/prometheus
[8b12]: https://quickdocs.org/prometheus-gc
[563a]: https://quickdocs.org/prometheus.collectors.process
[a01b]: https://quickdocs.org/prometheus.collectors.sbcl
[b66b]: https://quickdocs.org/prometheus.formats.text
[184b]: https://quickdocs.org/reblocks

* * *
###### [generated by [40ANTS-DOC](https://40ants.com/doc/)]

Version

0.2.0

Defsystem Dependencies
  • 40ants-asdf-system (system).
  • cffi-grovel (system).
Dependency

reblocks-prometheus/app (system).

Source

reblocks-prometheus.asd.


2.2 reblocks-prometheus/app

Author

Alexander Artemenko

Home Page

https://40ants.com/reblocks-prometheus

Source Control

(GIT https://github.com/40ants/reblocks-prometheus)

Bug Tracker

https://github.com/40ants/reblocks-prometheus/issues

License

Unlicense

Dependencies
Source

reblocks-prometheus.asd.


2.3 reblocks-prometheus/core

Author

Alexander Artemenko

Home Page

https://40ants.com/reblocks-prometheus

Source Control

(GIT https://github.com/40ants/reblocks-prometheus)

Bug Tracker

https://github.com/40ants/reblocks-prometheus/issues

License

Unlicense

Source

reblocks-prometheus.asd.


2.4 reblocks-prometheus/gauges/number-of-pages

Author

Alexander Artemenko

Home Page

https://40ants.com/reblocks-prometheus

Source Control

(GIT https://github.com/40ants/reblocks-prometheus)

Bug Tracker

https://github.com/40ants/reblocks-prometheus/issues

License

Unlicense

Dependencies
  • prometheus (system).
  • reblocks/session (system).
  • reblocks/page (system).
Source

reblocks-prometheus.asd.


2.5 reblocks-prometheus/gauges/number-of-sessions

Author

Alexander Artemenko

Home Page

https://40ants.com/reblocks-prometheus

Source Control

(GIT https://github.com/40ants/reblocks-prometheus)

Bug Tracker

https://github.com/40ants/reblocks-prometheus/issues

License

Unlicense

Dependencies
  • prometheus (system).
  • reblocks/session (system).
Source

reblocks-prometheus.asd.


3 Files

Files are sorted by type and then listed depth-first from the systems components trees.


3.1 Lisp


3.1.2 reblocks-prometheus/app/file-type.lisp

Source

reblocks-prometheus.asd.

Parent Component

reblocks-prometheus/app (system).

Packages

reblocks-prometheus/app.

Public Interface
Internals

3.1.3 reblocks-prometheus/core/file-type.lisp

Source

reblocks-prometheus.asd.

Parent Component

reblocks-prometheus/core (system).

Packages

reblocks-prometheus.


3.1.4 reblocks-prometheus/gauges/number-of-pages/file-type.lisp

Source

reblocks-prometheus.asd.

Parent Component

reblocks-prometheus/gauges/number-of-pages (system).

Packages

reblocks-prometheus/gauges/number-of-pages.

Public Interface

collect (method).

Internals

number-of-pages-gauge (class).


3.1.5 reblocks-prometheus/gauges/number-of-sessions/file-type.lisp

Source

reblocks-prometheus.asd.

Parent Component

reblocks-prometheus/gauges/number-of-sessions (system).

Packages

reblocks-prometheus/gauges/number-of-sessions.

Public Interface
Internals

4 Packages

Packages are listed by definition order.


4.1 reblocks-prometheus/gauges/number-of-pages

Source

file-type.lisp.

Use List

common-lisp.

Internals

number-of-pages-gauge (class).


4.2 reblocks-prometheus/app

Source

file-type.lisp.

Use List

common-lisp.

Internals

4.3 reblocks-prometheus/gauges/number-of-sessions

Source

file-type.lisp.

Use List

common-lisp.

Internals

4.4 reblocks-prometheus

Source

file-type.lisp.

Nickname

reblocks-prometheus/core

Use List

common-lisp.

Public Interface

5 Definitions

Definitions are sorted by export status, category, package, and then by lexicographic order.


5.1 Public Interface


5.1.1 Macros

Macro: metrics ((path &key name user-metrics) &body handler-body)

This macro creates a route of METRICS-ROUTE class.

The body passed as HANDLER-BODY will be executed each time when metrics are collected. You can use METRICS-REGISTRY function to access the prometheus metrics registry from the handler body code.

Package

reblocks-prometheus.

Source

file-type.lisp.


5.1.2 Ordinary functions

Function: metrics-registry ()

Call this function during handler’s body to update gauges before metrics will be collected.

Package

reblocks-prometheus.

Source

file-type.lisp.


5.1.3 Generic functions

Generic Reader: stats-registry (object)
Package

reblocks-prometheus.

Methods
Reader Method: stats-registry ((metrics-route metrics-route))

automatically generated reader method

Source

file-type.lisp.

Target Slot

registry.


5.1.4 Standalone methods

Method: collect ((gauge number-of-pages-gauge) cb)
Package

prometheus.

Source

file-type.lisp.

Method: collect ((gauge number-of-sessions-gauge) cb)
Package

prometheus.

Source

file-type.lisp.

Method: collect ((gauge number-of-anonymous-sessions-gauge) cb)
Package

prometheus.

Source

file-type.lisp.

Method: initialize-instance :after ((app prometheus-app-mixin) &rest args)
Source

file-type.lisp.

Method: serve :after ((route metrics-route) env)
Package

reblocks/routes.

Source

file-type.lisp.

Method: serve ((route metrics-route) env)

Returns a text document with metrics in Prometheus format.

To add your own metrics, add a :BEFORE method to this method. In this :BEFORE method you can update gauge metrics.

Package

reblocks/routes.

Source

file-type.lisp.


5.1.5 Classes

Class: metrics-route
Package

reblocks-prometheus.

Source

file-type.lisp.

Direct superclasses

route.

Direct methods
Direct slots
Slot: registry
Package

reblocks-prometheus/app.

Initform

(reblocks-prometheus/app::make-reblocks-metrics-registry)

Readers

stats-registry.

Writers

This slot is read-only.

Class: prometheus-app-mixin

A mixin which gathers some stats to report in Prometheus format.

Also, this mixin adds a /metrics slot to the app.

Use STATS-REGISTRY to access the registry slot.

Package

reblocks-prometheus.

Source

file-type.lisp.

Direct methods

initialize-instance.


5.2 Internals


5.2.1 Special variables

Special Variable: *current-registry*

This var will be bound to the current prometheus registry during the REBLOCKS/ROUTES:SERVE generic-function call.

Package

reblocks-prometheus/app.

Source

file-type.lisp.


5.2.2 Ordinary functions

Function: make-reblocks-metrics-registry ()
Package

reblocks-prometheus/app.

Source

file-type.lisp.


5.2.3 Classes

Class: number-of-anonymous-sessions-gauge
Package

reblocks-prometheus/gauges/number-of-sessions.

Source

file-type.lisp.

Direct superclasses

gauge.

Direct methods

collect.

Direct Default Initargs
InitargValue
:namereblocks_anonymous_sessions_count
:value0
:helpa number of anonymous session pages (where :user key is absent).
Class: number-of-pages-gauge
Package

reblocks-prometheus/gauges/number-of-pages.

Source

file-type.lisp.

Direct superclasses

gauge.

Direct methods

collect.

Direct Default Initargs
InitargValue
:namereblocks_pages_count
:value0
:helpa number of nonexpired session pages.
Class: number-of-sessions-gauge
Package

reblocks-prometheus/gauges/number-of-sessions.

Source

file-type.lisp.

Direct superclasses

gauge.

Direct methods

collect.

Direct Default Initargs
InitargValue
:namereblocks_sessions_count
:value0
:helpa number of non-anonymous session pages (where :user key is present).

Appendix A Indexes


A.1 Concepts


A.3 Variables


A.4 Data types

Jump to:   C   F   M   N   P   R   S  
Index Entry  Section

C
Class, metrics-route: Public classes
Class, number-of-anonymous-sessions-gauge: Private classes
Class, number-of-pages-gauge: Private classes
Class, number-of-sessions-gauge: Private classes
Class, prometheus-app-mixin: Public classes

F
File, file-type.lisp: The reblocks-prometheus/app/file-type․lisp file
File, file-type.lisp: The reblocks-prometheus/core/file-type․lisp file
File, file-type.lisp: The reblocks-prometheus/gauges/number-of-pages/file-type․lisp file
File, file-type.lisp: The reblocks-prometheus/gauges/number-of-sessions/file-type․lisp file
File, reblocks-prometheus.asd: The reblocks-prometheus/reblocks-prometheus․asd file
file-type.lisp: The reblocks-prometheus/app/file-type․lisp file
file-type.lisp: The reblocks-prometheus/core/file-type․lisp file
file-type.lisp: The reblocks-prometheus/gauges/number-of-pages/file-type․lisp file
file-type.lisp: The reblocks-prometheus/gauges/number-of-sessions/file-type․lisp file

M
metrics-route: Public classes

N
number-of-anonymous-sessions-gauge: Private classes
number-of-pages-gauge: Private classes
number-of-sessions-gauge: Private classes

P
Package, reblocks-prometheus: The reblocks-prometheus package
Package, reblocks-prometheus/app: The reblocks-prometheus/app package
Package, reblocks-prometheus/gauges/number-of-pages: The reblocks-prometheus/gauges/number-of-pages package
Package, reblocks-prometheus/gauges/number-of-sessions: The reblocks-prometheus/gauges/number-of-sessions package
prometheus-app-mixin: Public classes

R
reblocks-prometheus: The reblocks-prometheus system
reblocks-prometheus: The reblocks-prometheus package
reblocks-prometheus.asd: The reblocks-prometheus/reblocks-prometheus․asd file
reblocks-prometheus/app: The reblocks-prometheus/app system
reblocks-prometheus/app: The reblocks-prometheus/app package
reblocks-prometheus/core: The reblocks-prometheus/core system
reblocks-prometheus/gauges/number-of-pages: The reblocks-prometheus/gauges/number-of-pages system
reblocks-prometheus/gauges/number-of-pages: The reblocks-prometheus/gauges/number-of-pages package
reblocks-prometheus/gauges/number-of-sessions: The reblocks-prometheus/gauges/number-of-sessions system
reblocks-prometheus/gauges/number-of-sessions: The reblocks-prometheus/gauges/number-of-sessions package

S
System, reblocks-prometheus: The reblocks-prometheus system
System, reblocks-prometheus/app: The reblocks-prometheus/app system
System, reblocks-prometheus/core: The reblocks-prometheus/core system
System, reblocks-prometheus/gauges/number-of-pages: The reblocks-prometheus/gauges/number-of-pages system
System, reblocks-prometheus/gauges/number-of-sessions: The reblocks-prometheus/gauges/number-of-sessions system