Stone.jsDocs
Paradigm

Extensions

Telemetry

@stone-js/telemetry observes the app from the same place everything else attaches: a blueprint and a middleware. It records spans and metrics around each event and hands them to an exporter, so observability is configuration, not code scattered through handlers.

#Install & enable

terminalbash
npm i @stone-js/telemetry
app/Application.tsdeclarativeimperative
import { StoneApp } from '@stone-js/core'
import { Telemetry } from '@stone-js/telemetry'

@Telemetry()   // spans and metrics around each event
@StoneApp({ name: 'tasks' })
export class Application {}
import { defineStoneApp } from '@stone-js/core'
import { telemetryBlueprint } from '@stone-js/telemetry'

export const App = defineStoneApp(
  { name: 'tasks' },
  [telemetryBlueprint]
)

#What it records

With telemetry enabled, each event is wrapped in a span and timed; you add your own spans and counters where a domain operation is worth measuring. The Telemetry service is injected like any other.

app/Tasks.tsts
constructor ({ telemetry }) { this.telemetry = telemetry }

create (event: IncomingHttpEvent) {
  return this.telemetry.span('task.create', () => {
    const task = this.tasks.add(event.get('title'))
    this.telemetry.count('task.created')
    return task
  })
}

#The health probe

Telemetry is what you read after the fact; a health probe is the question asked in the moment, by something that cannot read: a load balancer deciding whether to route traffic, a platform deciding whether to replace an instance. Enabling telemetry publishes it at /health, and the answer is a status code first: 200 to route here, 503 to stop. The body is for the person who follows up.

With nothing registered it answers 200, which is the truthful answer to "is this process up and routing". Register a check and the answer starts meaning more:

app/health/DatabaseCheck.tsts
import { HealthCheck } from '@stone-js/telemetry'

@HealthCheck('database')
export class DatabaseCheck {
  constructor ({ db }) { this.db = db }          // resolved, like any service

  async check () {
    return await this.db.ping()                   // true, or { healthy: false, detail: '…' }
  }
}
keyTypeDefaultDescription
stone.telemetry.health.pathstring | false'/health'Where the probe answers. false serves nothing, for a deployment that answers it elsewhere.
stone.telemetry.health.checksMetaHealthCheck[]·The registered checks. A module or an application adds to this list; the decorator does it for you.
stone.telemetry.health.timeoutnumber2000How long a single check may take before it counts as failed.

#Which build is answering

A different question from the probe, and worth keeping separate. A probe is asked by a platform that cannot read and only needs a verdict; this one is asked by a person mid-investigation, and the answer is a fact. Is the deploy live yet. Is that canary the new build. Why does production behave differently. Enabling telemetry publishes it at /version:

terminalbash
curl https://api.example/version
{"name":"my-api","env":"production","platform":"aws_lambda_http","release":"2026.08.21-3"}

platform earns its place: one artefact can carry several adapters, each claiming the runtime it detects, so which one won is not knowable from the outside. The release is declared, never guessed from the environment, because an application already knows it and already has a place to put what it knows:

app/configurations/BuildConfiguration.tsts
@Configuration()
export class BuildConfiguration implements IConfiguration {
  configure (blueprint: IBlueprint): void {
    blueprint.set('stone.telemetry.version.release', myReleaseTag)
  }
}
keyTypeDefaultDescription
stone.telemetry.version.pathstring | false'/version'Where it answers. false serves nothing, when even that is more than you want to say.
stone.telemetry.version.releasestring'unknown'What this build is called: a tag, a commit, a release number.

#Exporters

Where telemetry goes is an exporter, swapped without touching your instrumentation. The console exporter ships for development; point it at your platform in production.

PieceTypeDescription
TelemetryserviceInjected; create spans and metrics from your code.
TelemetryMiddlewaremiddlewareWraps each event in a span automatically.
ConsoleTelemetryExporterexporterWrites telemetry to the console (development default).
telemetryBlueprintblueprintEnables telemetry imperatively.

Stone.js

Your app exists in every runtime. Until you run it.

An open-source project by Stone Foundation
Created by Mr. Stone (Evens Pierre)