Spanly Docs
CLI

Flag reference

Every flag accepted by spanly run and spanly proxy.

This page is the authoritative flag reference. spanly run and spanly proxy share most flags; differences are called out below.

Both subcommands

Buffer & retry

FlagDefaultDescription
--buffer-size10000Max packets buffered when ingest is unreachable. Oldest are dropped when full.
--retry-max-attempts3Max POST attempts per packet.
--retry-backoff1sInitial retry backoff (exponential).
--retry-max-backoff30sCap on retry backoff.
--shutdown-grace10sTime to flush in-flight telemetry on shutdown (SIGINT/SIGTERM).

Multi-tenant tagging

FlagDefaultDescription
--context-headernoneHEADER=field mapping. Repeatable. Fields: environmentId, projectId, organisationId.

Example:

spanly run --port 3000 \
  --context-header=X-Tenant=environmentId \
  --context-header=X-Org=organisationId \
  -- ./srv

Inspection scope (HTTP / proxy only)

FlagDefaultDescription
--inspect-prefix/mcp,/sseComma-separated path prefixes to inspect. Empty = inspect all paths.

Admin endpoints

FlagDefaultDescription
--admin-addrdisabledIf set (e.g. :9090), exposes /healthz, /readyz, /metrics.

Endpoints when enabled:

  • GET /healthz – 200 if the listener is up.
  • GET /readyz – 200 if the upstream is reachable (1s cache).
  • GET /metrics – Prometheus text format. Counters: packets collected / sent / dropped / failed, retry attempts, buffer depth, request counts by inspection class.

OTLP co-export

Spanly can ship telemetry to any OTLP/HTTP backend in parallel with shipping to Spanly. Spans follow the official MCP semantic conventions.

FlagDefaultDescription
--otlp-endpointdisabledOTLP/HTTP endpoint (overrides OTEL_EXPORTER_OTLP_ENDPOINT). Only http/protobuf is supported.
--otlp-headernoneKEY=VALUE header on OTLP requests. Repeatable.

For gRPC backends, run an OTel Collector hop and point Spanly at its HTTP receiver.

spanly run only

FlagDefaultDescription
--port0If set, run in HTTP mode (wrapper takes this port; child gets a random one). Default 0 = stdio.
--child-port0Port the child binds in HTTP mode. 0 = pick random unused port.
--child-port-envPORTEnv var passed to child with the chosen port.
--child-startup-timeout30sMax wait for child to listen.

proxy does not accept these – the bind address is positional.

Environment variables

VariableRequiredDescription
SPANLY_API_KEYyesRegion detected from prefix (spanly_us_… / spanly_eu_…).
SPANLY_INGEST_URLnoOverride ingest base URL (self-hosted / local dev).
OTEL_EXPORTER_OTLP_ENDPOINTnoEnable OTLP co-export. Equivalent to --otlp-endpoint.
OTEL_EXPORTER_OTLP_HEADERSnoComma-separated k=v headers added to OTLP requests.
OTEL_SERVICE_NAMEnoOverride service.name on emitted spans. Default spanly-cli.
OTEL_RESOURCE_ATTRIBUTESnoStandard OTel resource attribute overrides (k=v,k=v).

Per-request headers

The CLI recognizes the following inbound headers on every captured request:

HeaderEffect
X-Spanly-Monitor-IdOverride spanlyMonitorId for this request – useful for joining many requests under one logical session.
Any header named in --context-headerMaps to the matching context field on the captured packet.

spanly version

spanly version

Prints the CLI version, git commit, and build date.

On this page