Skip to main content

Lens

Lens is the gateway's observability service for agents. It stores the traces your agents send, flags runs that look wrong, groups problems into findings, and turns real runs into datasets and evals. Lens is generally available. Its datasets and evals are still in beta. To run it, see deploying Lens.

A real-world scenario​

A support agent built on the gateway sometimes gives up halfway through refunds, and nobody can say which step fails. The team turns on Lens, connects the agent with a tracing key, and after a day the Findings tab groups the failed runs under one tool that times out. They open a failed run, see the span where the tool call hung, and add the run to a dataset to test the fix.

Steps​

  1. Deploy Lens next to the gateway, see Lens with Docker Compose or Lens on Kubernetes.

  2. Check that the gateway reaches Lens.

    curl http://localhost:4000/lens/service -H "Authorization: Bearer $SPANWAY_MASTER_KEY"
  3. In the Admin UI open Lens under Observability. On Home click Copy instructions with new key and give the instructions to your agent, or use Set up manually to copy the tracing key and the project environment.

  4. Run one task with the agent and open the trace when Trace received appears.

  5. After about 10 traces, open Findings to read what Lens grouped.

Expected result​

/lens/service reports the connection as configured and the worker as reachable, the run shows on Traces with its span tree, and Findings lists grouped problems once analysis has run.

What works on Starter and what needs a license​

ScreenTier
Home, Agents, Traces, Search, Sessions, Findings, SettingsStarter
Datasets and EvalsEnterprise, with a license that includes evals

Without the evals feature, every request the Admin UI makes for datasets or evals answers 403, and the Datasets and Evals screens show "Couldn't load" with a message that names the missing feature.

Screens​

Traces lists agent runs with their user feedback and any signals flagged in red. Opening a run shows its span tree, and the Content tab of a span shows its input and output. Proxy admins and admin viewers see every team. Everyone else sees the runs of their own user and of the teams whose logs they may read.

Search, Sessions, Graph and Comments find runs by the words in them, read a conversation as one thread, draw which agents, tools and models a run used, and let your team leave notes on runs. They come with the gateway, see search, sessions, agent graph and comments.

Findings groups problems Lens found across many runs, such as a tool that keeps failing. Proxy admins and admin viewers can read them, and only proxy admins can configure or run the analysis. A finding can be resolved or dismissed.

Signals, under Settings, checks each run with a small model you pick, the System 1 model, and flags runs that match your questions, such as "Did the agent give up?". Only proxy admins can change signals, and admin viewers can read them.

Feedback shows ratings people gave a run in the User feedback panel of a trace. Proxy admins and admin viewers can read it.

Datasets keep chosen runs as cases. Open a trace or a finding and choose Add to dataset, pick a dataset or New dataset, and save. Each save is a new revision, and Export JSONL downloads one. Proxy admins and admin viewers can read datasets, and only proxy admins can change them.

Evals replay dataset cases against your agent and score them. New eval defines one, and a run shows each case as passed or failed with Run again. In the Admin UI the Evals tab is open to proxy admins and admin viewers only, and viewers can only read. The Lens API itself accepts evals from any signed-in user, stored for their own team or for themselves without a team, so an SDK or script can run them outside the Admin UI.

Tracing keys, under Settings, Manage tracing keys, are the keys agents send traces with. Only proxy admins can create or revoke them.

Slack, set up with LENS_SLACK_WEBHOOK_URL on the Lens worker, posts each new open finding to one channel with its title, how many runs support it and a link. Prompts, responses and trace excerpts stay in Lens.

Teams, organizations and Cloud tenants​

Lens keeps its data in its own ClickHouse store and checks every request against the caller the gateway signs into the request. Traces are filtered to the caller's user and the teams whose logs they may read, and evals are stored per team, or per user for a caller without a team. Datasets, findings, signals and tracing keys are open only to proxy admins and admin viewers, so on a gateway shared by several organizations or Cloud tenants, organization admins and tenants never see them.

Eval judges and privacy​

An eval scored by an LLM judge sends the case input, the rubric, the expected outcome, the agent's output and the run's spans to a judge model through the gateway, tagged so the call is recognisable in the logs. A Lens connected to the gateway never judges a run whose team requires zero data retention or has any other restricting data policy, such as allowed regions, no training or restricted code traffic, directly or through its organization. Such a run fails with a message that says why, and so does every run while Lens holds no current content policy from the gateway. A standalone Lens has no data policies to follow and judges every run.

Retention​

Traces, and the copies of request logs Lens keeps, are deleted after AGENT_TRACING_RETENTION_DAYS on the Lens worker, 14 days by default. They hold prompts and outputs. Datasets, eval results, feedback and findings have no expiry and stay until someone deletes them. A data subject erasure deletes the person's traces, request log copies, feedback and eval traces, but not dataset cases, so a proxy admin deletes the datasets that copied their conversations by hand, see What Spanway stores.

Errors​

What you seeWhat it meansFix
503 with "Set LENS_GATEWAY_SECRET to a shared secret of 32 to 512 bytes, the same on Spanway and Lens"LENS_GATEWAY_SECRET is missing, shorter than 32 bytes or longer than 512.Set the same secret on the gateway and the worker and restart.
503 with "Set SPANWAY_LENS_URL to the Lens service URL"SPANWAY_LENS_URL is missing or is not an http or https URL.Set it to the worker's address and restart.
503 with "Set SPANWAY_LENS_SERVICE_TOKEN to the same secret of at least 32 characters on Spanway and Lens"SPANWAY_LENS_SERVICE_TOKEN is missing or shorter than 32 characters.Set the same token on both and restart.
503 "Lens service is unavailable"The gateway cannot reach the Lens worker.Check SPANWAY_LENS_URL and the worker's health.
503 "Lens forwarding capacity is busy; retry shortly" with Retry-After: 1The gateway is already buffering as many Lens requests and answers as its memory budget allows.Retry after the number of seconds in Retry-After.
413 "Lens request is too large"The request or the worker's answer is larger than 64 MiB.Send a smaller request, for example a shorter time range or a smaller page.
307 with a Location headerThe path ended with a slash.Follow the redirect, or drop the trailing slash.
403 "Lens requires an authenticated user or key"The request carried neither a user nor a key identity.Sign in again or send a key.
403 "Your Spanway license does not include the 'evals' feature. Contact sales@spanway.ai to add it."A datasets or evals path was called with a license that lacks evals. Without any license the text starts "The 'evals' feature needs a Spanway enterprise license."Add the feature, the other screens stay free.
"Couldn't load" on Datasets or Evals naming a featureThe license lacks evals.Add the feature, the other screens stay free.
"No trace received yet" after 5 minutesThe agent does not send traces with the tracing key.Check the key and the endpoint in the agent's environment.
A judged eval fails with a data policy messageThe run's team requires zero data retention or another restricting policy.Judge runs of another team, or score without a judge.

Logs​

LevelLineMeaning
WARNINGLens content policy not sent, Lens keeps no span content: <error>The gateway could not send Lens the current content policy, so new spans are stored without their inputs and outputs and judged evals fail until it is sent. Check that the gateway reaches the worker. It retries on its own.
WARNINGLens content policy not built, Lens keeps no span content: <error>The gateway could not read the data policies it sends, usually because the database is down. Same effect. Check the database.

Audit​

Every change made through the gateway's /lens routes, such as creating or revoking a tracing key, saving signals or findings settings, building a dataset, starting or finishing an eval, resolving or dismissing a finding, and connecting or disconnecting the code host, writes an audit row on the Lens table with the caller, the method and the Lens path as object_id, never the request body. Searches that use POST (feedback summaries, previews, findings and signals queries) write none. In the Admin UI open Logs, then Audit Logs, and pick Lens in the Table filter.