Request a demo
Docs

Send records in, read them back

Ingest endpoints, authentication, the Python SDK, the read API and the settings that control capture and retention.

OpenTelemetry ingest

InsightLense accepts OTLP over HTTP at POST /v1/traces, in the JSON encoding: set the exporter’s protocol to http/json.

export OTEL_EXPORTER_OTLP_ENDPOINT="https://lense.internal.example" export OTEL_EXPORTER_OTLP_PROTOCOL="http/json" export OTEL_EXPORTER_OTLP_HEADERS="X-Lense-Ingest-Key=$LENSE_INGEST_KEY" export OTEL_SERVICE_NAME="claims-agent" # the exporter appends /v1/traces; GET /v1/traces/health confirms the endpoint is reachable

An OTLP trace becomes a run and each OTLP span becomes a step. A span that is re-sent with the same span id is ignored, so exporter retries do not duplicate.

Attributes that are read

FieldAttributes, first match wins
Input tokensgen_ai.usage.input_tokens gen_ai.usage.prompt_tokens llm.usage.prompt_tokens llm.token_count.prompt
Output tokensgen_ai.usage.output_tokens gen_ai.usage.completion_tokens llm.usage.completion_tokens llm.token_count.completion
Providergen_ai.provider.name gen_ai.system llm.vendor
Modelgen_ai.response.model gen_ai.request.model llm.request.model
Span typegen_ai.operation.name llm.request.type traceloop.span.kind, then the OTLP span kind
Run / sessiongen_ai.conversation.id session.id, then the OTLP trace id
Applicationresource service.name; environment from deployment.environment.name
Business threadinsightlense.correlation_id or correlation_id
Actorinsightlense.actor_code (or gen_ai.agent.id), insightlense.actor_kind, insightlense.capability, insightlense.autonomy
Subjectinsightlense.entity_type, insightlense.entity_ref

To keep fields beyond these, send the span through the trace API or SDK with metadata_json.

Authentication

Reads always need a signed-in user’s token. Writes from emitters are accepted with any of:

  • an ingest key in X-Lense-Ingest-Key or Authorization: Bearer, matched against LENSE_INGEST_KEYS on the server. Use one key per product so each can be revoked alone;
  • a platform user token;
  • nothing, only while LENSE_OPEN_INGEST=1. This is on by default outside production and off in production. Every unauthenticated write is counted.

GET /api/traces/ingest-status and the Ingest & retention page show which keys are configured, how many writes were signed, unsigned or refused since start, and which products are reporting.

Python SDK

The insightlense package needs Python 3.9 or later and depends only on requests. Spans are queued and sent in batches to /api/traces/batch.

import insightlense insightlense.init( endpoint="https://lense.internal.example", application_name="claims-agent", environment="prod", capture_input=False, capture_output=False, # keep prompt and response text out of traces ) # ingest key is read from LENSE_INGEST_KEY insightlense.instrument_anthropic() # also instrument_openai(), instrument_bedrock() @insightlense.trace(name="triage_claim") def triage(claim): with insightlense.span("lookup_policy") as s: policy = lookup(claim) s.set_metadata("policy_found", bool(policy)) ... insightlense.shutdown() # flush the queue on exit

Callback handlers are available for LangChain, LangGraph and LlamaIndex (get_langchain_handler(), get_langgraph_handler(), get_llamaindex_handler()). log_agent_action() posts a tool call to the agent-actions endpoint and inherits the current span’s trace id.

Record APIs

WriteEndpointNotes
SpansPOST /api/traces
POST /api/traces/batch
Required: trace_id, application_name, model_provider, model_name. Optional business fields: correlation_id, actor_code, actor_kind, capability, autonomy, entity_type, entity_ref, prompt_id, prompt_version.
Agent actions (authority)POST /api/security/agent-actionsOne tool call: action_type, tool_name, outcome (allowed, refused, escalated, downgraded), autonomy_held, autonomy_required, escalated_to, refusal_reason.
Business eventsPOST /api/business-events
POST /api/business-events/batch
Required: event_id, source_system, entity_type, action. Idempotent on event_id: a retry is reported as a duplicate, not stored twice. There is no update or delete route.
ScoresPOST /api/scores
POST /api/scores/batch
subject_type (trace, session, business_event, dataset_item), subject_ref, name, value (number, boolean or string), source (human, judge, code, feedback).
curl -X POST https://lense.internal.example/api/business-events \ -H "X-Lense-Ingest-Key: $LENSE_INGEST_KEY" -H "Content-Type: application/json" \ -d '{ "event_id": "cw-evt-000123", "source_system": "claims", "entity_type": "claim", "entity_ref": "CLM-2027-01192", "action": "reserve_posted", "field_name": "reserve", "old_value": "50000", "new_value": "250000", "amount": 250000, "actor_code": "claims-triage-agent", "actor_kind": "agent", "reason": "medical report received", "correlation_id": "CLM-2027-01192", "causation_id": "run-86643922" }'

Read API

ReadEndpoint
Runs, with totals and breakdownsGET /api/traces/runs (filters: application, environment, actor, references, search, status, time range)
One span and its treeGET /api/traces/{trace_id}, GET /api/traces/{trace_id}/tree
Guardrails and evaluations for a run setGET /api/traces/controls
ExportGET /api/traces/export?format=json|csv
Performance by promptGET /api/traces/by-prompt/{prompt_id}
One account’s threadGET /api/business-events/thread/{correlation_id}
Agent share and top actionsGET /api/business-events/summary
ScoresGET /api/scores, GET /api/scores/summary
CostGET /api/costs/summary, /breakdown, /forecast, /budgets, /pricing
Alerts, incidents, SLA/api/alerts/rules, /api/alerts/events, /api/incidents, /api/sla/definitions
RetentionGET /api/traces/retention, POST /api/traces/retention/purge?dry_run=true

Responses are wrapped as {"status": ..., "data": ...}. An instance run in a local or development environment serves its OpenAPI description at /docs.

Settings

VariableWhereWhat it does
LENSE_INGEST_KEYSServerComma-separated ingest keys accepted on write paths.
LENSE_OPEN_INGESTServer1 accepts unsigned writes. Default on outside production, off in production.
LENSE_TRACE_RETENTION_DAYSServerDays a span is kept. Default 365; 0 keeps everything.
LENSE_INGEST_KEYEmitterThe key the SDK sends as X-Lense-Ingest-Key.
LENSE_ENDPOINTEmitter (Insight agent runtime)The InsightLense API root. Unset means nothing is sent.
LENSE_CAPTURE_IOEmitter (Insight agent runtime)1 sends prompt and response text. Default off.

Guard spans

Products that use the platform guard write a span of type GUARD named guard.<stage> under the step that ran the check. Its metadata holds the stage, the overall action, whether it was enforced, and for each decision the rule, action, reason and the offsets and labels of what matched. The matched text is never stored.

VariableWhat it does
INSIGHT_GUARD_MODEobserve records what enforcement would have done and changes nothing; enforce applies redactions and blocks.
INSIGHT_GUARD_POLICYThe guard policy: a path to a JSON file, or inline JSON.
INSIGHT_GUARD_TRACEoff writes no guard spans.
INSIGHT_GUARD_TRACE_CLEAN0 leaves checks that found nothing off the trace. Default 1.
Setting it up in your environment? Tell us about your stack and we’ll walk through the deployment with you.