On this page

Telemetry

Rebask does not collect or export telemetry itself. It emits OpenTelemetry traces and metrics through @opentelemetry/api, which are no-ops until your app registers an SDK.

Instrumentation

Rebask calls the register() export from an auto-detected instrumentation.{ts,mts,mjs,js} file in the project root before the server starts. Register an SDK, context manager, and propagator there:

// instrumentation.ts
import { context, metrics, propagation, trace } from "@opentelemetry/api"
import { AsyncLocalStorageContextManager } from "@opentelemetry/context-async-hooks"
import { W3CTraceContextPropagator } from "@opentelemetry/core"
import { OTLPMetricExporter } from "@opentelemetry/exporter-metrics-otlp-http"
import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-http"
import { MeterProvider, PeriodicExportingMetricReader } from "@opentelemetry/sdk-metrics"
import { BasicTracerProvider, BatchSpanProcessor } from "@opentelemetry/sdk-trace-base"

export function register() {
  trace.setGlobalTracerProvider(
    new BasicTracerProvider({
      spanProcessors: [new BatchSpanProcessor(new OTLPTraceExporter())],
    }),
  )
  context.setGlobalContextManager(new AsyncLocalStorageContextManager())
  propagation.setGlobalPropagator(new W3CTraceContextPropagator())
  metrics.setGlobalMeterProvider(
    new MeterProvider({
      readers: [
        new PeriodicExportingMetricReader({
          exporter: new OTLPMetricExporter(),
        }),
      ],
    }),
  )
}

The example uses OTLP/HTTP exporters for traces and metrics. Install the OpenTelemetry packages used by your exporters.

Server-side, Rebask continues traces across services: incoming propagation headers become the parent of rebask.request, and outgoing fetch requests send the active trace context to downstream services.

Client traces

Set clientTraceMetadata to expose propagation headers to the browser:

rebask({ clientTraceMetadata: ["traceparent"] })

The browser sends those headers on navigations, prefetch, and Server Function requests, so they join the same trace.

Spans

SpanCovers
rebask.requestIncoming requests
rebask.cache.lookupPage and segment cache lookups
rebask.renderPage and segment rendering
rebask.fetchOutgoing fetch requests
rebask.use_cache"use cache" calls
rebask.durable_cachedurableCache() calls
rebask.revalidationBackground revalidations

Metrics

Rebask emits these metrics when a MeterProvider is registered, as in the instrumentation example above:

MetricTypeMeasures
rebask.fetch.durationHistogramFetch latency
rebask.render.durationHistogramRender latency
rebask.cache.lookup.durationHistogramCache lookup latency
rebask.revalidation.durationHistogramBackground revalidation latency
rebask.cache.hitsCounterCache hits
rebask.cache.missesCounterCache misses

Durations are in milliseconds.