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
  })
}

#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)