Logging
Pass any pino-compatible logger, or anything satisfyingGatewayLogger. Every gateway log goes to it: request logs, hook failures, and warnings about request content it can’t translate. Without one, the gateway creates its own console logger. FrogBot passes its own logger, so an embedded gateway’s output lands in FrogBot’s logs.
LOG_LEVEL environment variable, or info:
logger values.
Tracing
The gateway records spans throughtrace.getTracer() by default — a no-op unless something has registered a global tracer provider. Pass a host-provided Tracer to use one explicitly.
Bootstrap tracing yourself
The Node-only@frogbotai/gateway/setup export registers a NodeTracerProvider and an OTLP exporter — use it in a standalone deployment that doesn’t already have OpenTelemetry wired up. It’s a separate entry point specifically so the core gateway path never eagerly imports the OTel SDK (which pulls in node:async_hooks and friends).
endpoint to fall back to the exporter’s own env handling: OTEL_EXPORTER_OTLP_ENDPOINT (with /v1/traces appended) or OTEL_EXPORTER_OTLP_TRACES_ENDPOINT verbatim.
setupTracing accepts:
It also registers a global async context manager and labels exports with
service.name @frogbotai/gateway, the package version, a per-process instance ID, and NODE_ENV as the environment; OTEL_SERVICE_NAME and OTEL_RESOURCE_ATTRIBUTES override them. Only the first call in a process takes effect; later calls log a warning and return a no-op flush.
The CLI calls setupTracing automatically when tracing.endpoint, OTEL_EXPORTER_OTLP_ENDPOINT, or OTEL_EXPORTER_OTLP_TRACES_ENDPOINT is set — no extra setup needed for the standalone server. Only the CLI reads tracing.endpoint: createGateway ignores it, so an embedded gateway exports nothing until you call setupTracing or register your own tracer provider.
Metrics
setupTracing’s metrics option also registers a MeterProvider with a periodic OTLP exporter, sharing the same service resource as traces. Pass metrics: false to skip it.
The gateway records
gen_ai.client.token.usage (tokens) and gen_ai.server.request.duration (seconds) for each operation when the gen_ai signal level is recommended or higher.
What gets traced
Hooks contribute low-cardinalityotel attributes that get flushed to spans and metrics — every entry becomes a metric dimension, so avoid user or session IDs there.
Signal levels
signalLevel (or tracing.signalLevel, which takes precedence) sets how much telemetry the gateway records. Pass one level for every namespace, or an object with a level per namespace. A namespace you leave out of the object stays at recommended.
off, required, recommended, and full. Each namespace acts at these thresholds: