createSmithersObservabilityLayer installs the logger, the metrics registry,
the tracing service, and (when enabled) an OTLP exporter. Metrics are always
collected in-process and read back as a Prometheus exposition string; traces and
logs are exported over OTLP only when enabled is set.
Metric collection is global.
renderPrometheusMetrics() and trackSmithersEvent
read and write the process-wide Effect registry, so they work whether or not you
have built a layer. Building a layer adds logging, tracing, and OTLP export on
top.SmithersObservability
An EffectContext.Tag for the resolved observability service. Provided by
createSmithersObservabilityLayer; depend on it to read the resolved options or
to open a span without importing withSmithersSpan directly.
The shape behind the tag.
SmithersObservability.js · SmithersObservabilityService.ts · Tests observability.test.js · See also Server integration
Layers
createSmithersObservabilityLayer
Builds the full observability layer: logger,MetricsService, TracingService,
the SmithersObservability service, and BunContext. The OTLP exporter is
folded in only when the resolved options have enabled: true.
Partial options, resolved through
resolveSmithersObservabilityOptions. See
resolveSmithersObservabilityOptions
for fields and defaults.createSmithersRuntimeLayer
Alias ofcreateSmithersObservabilityLayer, exported under the name used by the
runtime. Same signature, same return type. Prefer it in runtime/server wiring so
the intent reads clearly.
createSmithersOtelLayer
The OTLP-export slice on its own. ReturnsLayer.empty unless enabled resolves
to true, so it is safe to merge unconditionally. Use it when you already have a
metrics/logging layer and only want to add OpenTelemetry traces.
Same options object. Only
enabled, endpoint, headers, and serviceName
affect this layer.createSmithersObservabilityLayer.js · createSmithersOtelLayer.js · createSmithersRuntimeLayer.js · Tests observability.test.js · See also Agent trace OTel verification
resolveSmithersObservabilityOptions
Merge partial options with environment variables and defaults. The layer factories call this for you; call it directly to inspect what a deployment resolves to.Every field is optional. Unset fields fall back to env vars, then defaults.
OTEL_EXPORTER_OTLP_HEADERS:
Every field is present after resolution.
headers is undefined when no
headers are configured.resolveSmithersObservabilityOptions.js · ResolvedSmithersObservabilityOptions.ts · Tests observability-options.test.js
trackSmithersEvent
Map aSmithersEvent onto the metric registry. Returns
an Effect<void> that increments the relevant counters, updates gauges, and
records durations for that event type. Every event also bumps the
smithers_events_emitted_total counter. The runtime calls this on each emitted
event; call it yourself only when feeding events from outside the engine.
A discriminated union keyed by
type. See Event types.trackEvent.js · SmithersEvent.ts · Tests effect-metrics-track.test.js · See also Event types
Prometheus
renderPrometheusMetrics
Render the entire metric registry as a Prometheus exposition string, with# HELP/# TYPE headers and every catalog metric present at zero even before it
fires. Refreshes the process gauges (uptime, RSS, heap) on each call. This is
what the server’s GET /metrics route returns.
prometheusContentType
The exactContent-Type for a Prometheus response:
text/plain; version=0.0.4; charset=utf-8. Pair it with the rendered body.
The built-in server already exposes this at
GET /metrics. See
Server integration. Use these directly only when wiring
metrics into your own HTTP layer.renderPrometheusMetrics.js · prometheusContentType.js · Tests observability-prometheus.test.js · See also Server integration
Metrics catalog
smithersMetrics is the registry of every metric, an object keyed by the
camelCase names below whose values are the underlying Effect Metrics. Each
metric renders under its Prometheus name; histograms also emit _bucket,
_sum, and _count series. The table groups the core metrics by area; the
registry holds more (gateway, devtools, agent, alert, supervisor families).
Runs and nodes
Approvals and timers
Cache and tokens
Database
HTTP and hot reload
Tools
Sandbox
Memory
OpenAPI tools
VCS and process
Source
smithersMetrics.js · metrics · Tests effect-metrics-definitions.test.js · See also Server integration, Event types