Core Event Inventory

On this page

Core Event Inventory

This page is for module authors. It lists the BoxLang core 1.19 events that Lens uses, with the payload keys core actually sends. The data comes from the design spec, which read them from the core source. Lens does not use every event listed here. See the spec status section for what v1 implements.

Request lifecycle

Core announces these globally and per application.

EventPayloadUse
onRequestStartcontext, args, application, listenerCreate the Lens request and check access.
onRequestsameTemplate or class entry.
onRequestEndsameFinalize, store and inject. Core skips it on unhandled exceptions and aborts.
onErrorsame, args holds the exceptionCapture the exception, finalize and inject on error pages.
onAbortsameFinalize and inject on abort.
onMissingTemplatesame404 issue.
onSessionStart, onSessionEndsameSession panel.
onRequestFlushBuffercontext, output (mutable)Alternative injection point. It fires on every flush, so only the last flush may be modified.
onApplicationStart/End/Restart/Defined, beforeApplicationListenerLoad, afterApplicationListenerLoadapp dataApplication data.
onWebExecutorRequest (web-support)context, appListener, requestString, exchange, updatedRequestRoute rewrites and request identity.

Execution

EventPayloadUse
preTemplateInvoke, postTemplateInvokecontext, template, templatePathTemplate tree. No executionTime, so Lens times it.
preFunctionInvoke, postFunctionInvokecontext, arguments, function, name (+ result on post)Functions panel (opt in, hot path).
onFunctionExceptionsame + exceptionExceptions.
onBIFInvocationcontext, arguments, bif, nameAnnounced before a BIF runs. Lens does not use it.
postBIFInvocationname, elapsedNanos (the keys Lens reads)Time per built-in function. Used by the opt-in bifs collector. Core announces it only when a listener exists.
onBIFExceptionname, elapsedNanos (the keys Lens reads)Counts failed BIF calls in the bifs collector.
onPreSourceInvoke, onPostSourceInvokescript or source executionEval and script timing.
afterBoxClassCreation, afterBoxClassInit, afterDynamicObjectCreation, onCreateObjectRequestobject createdObjects (opt in).
onComponentInstance, onBIFInstancedescriptorStartup only.
onComponentInvocationdeclared, never announcedUnusable today.

Data

EventPayloadUse
onQueryBuildquery build dataBuilder usage.
preQueryExecutesql, bindings, pendingQuery, contextStart time and SQL text.
postQueryExecutesql, bindings, executionTime, data, result (meta), pendingQuery, executedQuery, contextQueries panel. Row count comes from data, datasource from pendingQuery.
queryAddRowquery rowIgnored.
onTransactionBegin/Acquire/Commit/Rollback/SetSavepoint/Release/Endconnection, transaction, contextSpans on the waterfall.
onDatasourceConfigLoad, onDatasourceStartup, onDatasourceInitialized, service start and stopdatasourceJVM and runtime panel.
afterCacheElementInsert/Updated/Removed, beforeCacheElementRemoved, afterCacheClearAllcache elementCache writes only. No read, hit or miss event.
onCacheComponentActioncache component actionOutput cache usage.

I/O and misc

EventPayloadUse
onHTTPRequestresult, httpClient, httpRequestHTTP call start.
onHTTPRawResponse, onHTTPResponseresult, response, httpClient, httpRequestStatus, size and time.
onHTTPErrorerror dataIssue.

The HTTP collector pairs the start and the end of a call by the result object both events carry, because the end events do not carry the request. Core does not announce retries, redirects or the connect phase, so the HTTP page shows the total time of a call only. A streamed or server sent events call ends with an event that has no request and no client, so it is not counted. | onFileComponentAction | file action | Files (opt in). | | logMessage | text, log, type | Logs panel. | | onBXDump, onMissingDumpOutput | dump data | Route bx:dump output to Messages. | | beforeObjectMarshallSerialize and similar | serialization | Ignored. |

Global events

These are not per request. Lens uses two of them, and only when the console is on, to remember how the last run of each scheduled task ended:

EventUse
schedulerOnAnyTaskSuccessRemember a successful run.
schedulerOnAnyTaskErrorRemember the error message and stack of a failed run.

Core keeps run counts for a task but not the error of its last run, so the Tasks page keeps it in memory since Lens started. Everything else on the console Executors, Tasks, System and Threads pages is read on demand from core's async and scheduler services and the JDK management beans, not from events.

ORM events (bx-orm)

These come from the bx-orm module (1.7.2 or later), not from core. Lens listens to them only when the ORM integration is on and bx-orm is installed. They carry no context, so Lens finds the request that is current on the thread that announced them.

EventPayloadUse
onORMQuerysql, kind, elapsedNanos, rows (-1 unknown), datasource, appName, hql, entityName, error, params (only when the app sets announceQueryParams)A query span and a query entry on the request, and the ORM totals. A select fires when its result set closes, so the span is elapsedNanos long and ends when the event arrives. Startup DDL and failed statements are announced too.
onORMFlushinserts, updates, deletes (statements, not entities), elapsedNanos, datasource, appNameFlush counts per datasource.
onORMExceptionerror, sql, datasource, appNameThe recent failures list.

The statistics use two service calls instead of events: ORMService.getStatistics( appName ) and ORMService.setStatisticsEnabled( appName, enabled ). See ORM.

Module events

Lens listens to postModuleLoad and postModuleUnload (payload moduleRecord, moduleName) so an integration whose module is installed or removed while Lens runs starts or stops listening without a restart.

Spans that never close

A span opens on a pre event and closes on the matching post event. Core does not always fire the post event. This is what the harness pages in harness/app/spans showed on core 1.19, checked by the end to end tests in e2e/tests/interrupted.spec.ts:

CaseWhat core firesWhat Lens does
Exception thrown in a function (caught by the page or not)onFunctionException. No postFunctionInvoke.The function span is closed at the time of the exception event, marked interrupted and drawn striped. Its parent keeps its own end.
Exception thrown through an include and caught by a try/catchpostTemplateInvoke still fires. No exception event.The include span closes normally. The exception is not recorded (use lensException()).
Uncaught exceptiononFunctionException for the functions it passed, then onError and no onRequestEnd.The request is finished from onError: open spans are closed and marked. Core renders its own error page, so there is no bar.
abortonAbort, templates close normally.The request is finished from onAbort. No bar.
Request timeout (requestTimeout)Nothing. The web runtime did not interrupt the request in the harness.The request is long, not interrupted.
Client disconnectNothing. The request runs to its end.The request ends normally and keeps its full time.
Work in a thread that outlives the requestNothing is attached to the request after it ended.The thread adds no span, query or error to the finished request.
A request that never ends (a hung or killed thread, a lost event)Nothing.After request.maxMinutes (default 10) the watchdog finishes it as unfinished: spans closed and marked, kept in the history, removed from In flight, with the issue "Request never finished".

Rules Lens follows:

  • A span left open by a skipped post event ends at the time of the last exception event on its thread when that came after the span started, else at the last activity Lens saw in the request. It never gets the end time of the span around it.
  • When a request finishes, closeAll marks every span that is still open as interrupted, with the same estimate.
  • An interrupted span has interrupted: true in the payload. The bar and the console draw it striped with a marker, and its end is an estimate, not a measurement.

Not in core

onException, onSOAPRequest and onSOAPResponse do not exist in core 1.19.

Core gaps

Lens needs these core changes. Until they land, the matching features are limited. postBIFInvocation used to be on this list. It now exists in core with elapsedNanos and onBIFException (core pull request 657), and Lens uses it for the BIFs panel. You need a BoxLang snapshot or release that has the change.

  1. onComponentInvocation is declared but never announced.
  2. There are no cache hit or miss events. Lens computes per-request cache numbers from the difference of cache statistics instead.
  3. There are no SOAP events.
  4. The web context does not announce onRequestFlushBuffer, so Lens cannot inject a bar into core's error pages.
  5. Template events lack execution time. This is optional and cheap to add. Lens times templates itself.

Lens interception points

Lens adds its own points for extension: onLensRegister, onLensRequestStart, onLensCollect and onLensRequestFinish. See Extending Lens.