Skip to main content

Telemetry

Telemetry

Telemetry explains operational health and cost. PostgreSQL trace, lifecycle, conflict, and audit records establish individual durable outcomes. A metric counter alone cannot prove memory state or delivery.

Observation Surfaces

%%{init: {"flowchart": {"curve": "linear"}}}%%
flowchart LR
  Operation["Authenticated operation"] --> Metrics["Bounded aggregate metrics"]
  Operation --> Logs["Structured console and operation logs"]
  Operation --> Captures["Protected admitted payload captures"]
  Metrics --> Dashboard["Scoped dashboards and optional OTLP"]
  Logs --> Control["Private operator investigation"]
  Captures --> Control

Active Metrics

FamilyCurrent signals
HTTPdensemem_http_requests_total, densemem_http_request_duration_seconds.
Embeddingsdensemem_embedding_requests_total, densemem_embedding_errors_total, densemem_embedding_duration_seconds, densemem_embedding_tokens_total.
Rememberdensemem_remember_acknowledgements_total, densemem_remember_acknowledgement_duration_seconds.
Recalldensemem_recall_requests_total, densemem_recall_duration_seconds, densemem_recall_results.
Feedbackdensemem_recall_feedback_total, densemem_recall_feedback_quality_score.
Assessmentdensemem_assessor_requests_total, densemem_assessor_duration_seconds, densemem_assessor_tokens_total, densemem_assessor_validation_failures_total, densemem_assessor_validation_field_failures_total.
Topic maintenancedensemem_topic_maintenance_batches_total by stage and outcome (ok, failed, interrupted), densemem_topic_maintenance_slow_lock_wait_seconds by lock.
Usage/costdensemem_ai_operation_tokens_total, densemem_ai_operation_cost_usd_total, densemem_ai_operation_items_total, densemem_ai_operation_unpriced_total.

The source collector and ordered dashboard catalog define exact audience, scope, labels, and prerequisites. Queries, source text, operational credentials, result IDs, and comments do not belong in metric labels. System-only assessor and Topic maintenance series have no team/profile labels.

The embedding request and duration families count every attempted chunk or retry, including capacity waits, for Remember, session intake, search reconciliation, Recall, and Topic embedding backfill. The error family counts terminal failures and deadlines. Provider-attempt usage tracks dispatched HTTP calls separately.

The embedding and operation-log behavior described here is introduced by application revision 422d9567 and takes effect when a build containing that revision is deployed.

A Topic maintenance batch stopped because maintenance was paused, disabled, outside its window, or shutting down counts as interrupted, not failed. Lock waits enter the histogram from one second, the same threshold as the topic maintenance lock wait event.

Operation Logs And Protected Captures

Correlation searches use an indexed exact lookup. If pending operation logs cannot be written but saved history remains readable, the Logs panel shows saved results and their exact saved total with a warning that recent events may be missing. Refresh after the writer recovers to clear the warning.

One process logger supplies structured console output and the PostgreSQL operation-log sink. The sink is required for readiness; gaps and recovery remain visible. Startup/pre-attachment output is console-only and is not claimed as persisted history.

%%{init: {"flowchart": {"curve": "linear"}}}%%
flowchart TB
  Correlation["Correlation ID and operation window"] --> Invocation["Admitted invocation<br/>Execution / replay / conflict"]
  Invocation --> Attempt["Canonical attempt<br/>Phase, hash and retry eligibility"]
  Attempt --> Detail["Authorized detail view"]
  Detail --> Capture["Capture availability, manifests,<br/>chunks and truncation"]
  Capture --> Receipt["Preparation / write observation /<br/>disconnect / unknown receipt"]
Private routeInvestigation
/control/api/logsSeverity, correlation, request/attempt, and bounded classification filters.
/control/api/remember-invocationsAdmitted call list.
/control/api/teams/{teamId}/remember-invocations/{invocationId}Selected invocation detail and authorized captures.
/control/api/remember-attemptsCanonical attempt diagnostics.
/control/api/teams/{teamId}/remember-attempts/{attemptId}Selected attempt detail.

Admitted exact fields/text can remain in bounded protected diagnostics. Initial security rejection is content-free. Configured operational credentials and authentication material are protected in supported serialized forms; field names or secret-like user phrases alone do not trigger masking. Public errors, audit, metrics, and exports retain separate exposure contracts.

Remember body captures expire after seven days, subject to applicable holds and erasure. Unavailable, expired, or truncated captures are incomplete evidence. A captured response write does not prove caller delivery. Operation-log retention is configured separately in Configuration.

Topic maintenance diagnostics join trusted team/actor, correlation, operation, run, batch, assessment, and provider-exchange identities. Complete protected DEBUG chunks are stdout-only and independent of optional telemetry. Preserve the full operation window and validate manifest hashes and chunk counts; missing required chunks cannot establish a diagnosis. Successful publication observations occur after transaction/audit success. Rejected assessment receipts can include bounded server-owned validation identifiers; absence does not imply success.

Remember Progress Diagnostics

Remember progress uses the process logger and configured level policy. MCP Clients describes user-visible status.

EventLevel and evidence
mcp_progress_eligibilityDEBUG: response mode, protocol and eligibility reason; no token value before admission.
mcp_progress_sending / mcp_progress_deliveredDEBUG: trusted team/profile and correlation, request/invocation identity, protected token, stage, sequence, write budget and delivery duration.
mcp_progress_delivery_failedWARN: causal error, elapsed time, reason and disabled state; correlate with the terminal MCP and HTTP delivery events.

Collect the complete server console operation window, including remember_request_payload and ai_exchange_payload at DEBUG. Reconstruct protected chunks by exchange/direction and verify counts/hashes. Required provider bodies are console-only and remain available with optional telemetry disabled; the control log summary alone cannot prove complete capture. Use existing phase, processing-failure and invocation events for cause, retry eligibility, canonical attempt, request hash and final outcome. Initial security rejection remains content-free.

MCP OAuth Diagnostics

Release v2.9.2 introduces these records; see implementation status. Each built-in OAuth step logs correlation_id, stage, and reason_code, with team_id, grant_id, and oauth_client_id when known. INFO is enough to identify every failure; DEBUG and TRACE add timings and decision details. Logs never contain raw team keys, codes, verifiers, dmoa_/dmor_ tokens, client secrets, or browser cookies.

stageLevelCommon reason_code values
oauth_discoveryWARNexternal_provider_unavailable, public_base_url_invalid, provider_list_unavailable
oauth_dcrINFO / WARNinvalid_redirect_uri, invalid_client_metadata, body_too_large, client_limit_reached, rate_limited
oauth_cimdINFO / WARNssrf_blocked (IP literal, localhost, or a non-global address at connect time), redirect_blocked, invalid_client_id_url, fetch_failed, body_too_large, content_type_invalid, client_id_mismatch
oauth_authorize_initDEBUG / WARNclient_unverified, invalid_redirect_uri, pkce_required, pkce_plain_rejected, invalid_target, invalid_scope, duplicate_parameter, malformed_query (#885), rate_limited
oauth_consent_authWARNkey_invalid, key_revoked, key_expired, sso_key_entitlement_denied, team_mismatch, team_not_entitled, sso_session_invalid, sso_csrf_invalid, sso_identity_inactive, csrf_invalid, cross_site_blocked, request_unknown, request_expired, request_consumed, browser_mismatch, scope_unsatisfiable, rate_limited
oauth_consent_approve, oauth_consent_denyINFONone; records team, profile, method, scopes, and resource.
oauth_token_exchange, oauth_token_refreshINFO / WARNpkce_mismatch, pkce_verifier_invalid, code_invalid, code_expired, code_replayed, refresh_invalid, refresh_expired, refresh_replayed, client_mismatch, resource_mismatch, redirect_mismatch, invalid_scope, grant_revoked, key_rotated, underlying_auth_revoked, sso_entitlement_lost, sso_entitlement_stale, sso_entitlement_refresh_failed, sso_provider_disabled (#885); revoked_family=true marks a replay revocation.
oauth_protocolWARN / ERRORrate_limited on /oauth/token, internal_error
oauth_revokeINFONo reason_code; revocation_reason is client_revocation, user_revocation, operator_revocation, key_rotated, key_revoked, key_retired, team_deleted, or sso_provider_disabled. A rate-limited /oauth/revoke logs WARN rate_limited.
mcp_oauth_authWARNtoken_expired, token_unknown, grant_revoked, resource_mismatch, team_path_mismatch, key_rotated, subject_mismatch, scope_lost, sso_entitlement_lost, refresh_token_as_bearer, surface_forbidden
oauth_pruneDEBUG / INFO / WARNstore_unavailable

Entries marked #885 come from the pending application change #885. With it:

  • malformed_query reports an authorize request whose query has an invalid percent escape or a literal ;. The response is a non-redirecting invalid_request, and the record carries no parameter value.
  • sso_provider_disabled reports a code exchange whose SSO provider was disabled or retired before the grant was stored. The code is not consumed.
  • Records that describe an SSO grant add provider_id_hash, the same key SSO records use: the first 16 hex characters of the SHA-256 of the provider ID.
  • oauth_prune_completed adds clients_retained_for_history. This counts clients old enough to prune that are kept only because a revoked or expired grant still references them. The record is INFO when a pass deletes something and DEBUG otherwise.

Start from the failed request's X-Correlation-ID response header when the host exposes it. Otherwise, /control/api/logs filters by team, event, severity, and correlation. Filter stage and reason_code in the console JSON:

bash
docker compose -f examples/docker-compose.base.yml logs --no-color --no-log-prefix server |
  jq -Rc --arg id "$CORRELATION_ID" \
    'fromjson? | select(.correlation_id == $id and ((.stage // "") | test("oauth")))'

Replay and operator revocations also write audit events. Interpretation and response steps are in Operations Runbook.

PostgreSQL Load Diagnostics

These events arrive with release v2.9.2; see implementation status. Each survives LOG_LEVEL=info.

EventWhere and levelFields
slow postgres queryConsole WARN, one per statement over POSTGRES_SLOW_QUERY_THRESHOLD_MSsql, rows, duration_ms, sql_fingerprint, correlation
slow_postgres_query_summaryOperation log and console WARN, one per fingerprint per 60-second window (at most 256 fingerprints, then untracked)sql_fingerprint, sql (bounded prefix), sql_bytes, sql_truncated, count, total_duration_ms, max_duration_ms, window_start, window_seconds
operation_log_persist_failed / operation_log_persist_recoveredConsole WARN / INFO, once per sink failure episodeerror, batch_size, retained_rows, queued, retry_after_ms / failure_duration_ms
operation_log_events_droppedConsole WARN, once per drop episodereason, dropped_events, dropped_total, queued
operation_log_gap_recoveredOperation log marker operation log gap recovered, mirrored to the consoledropped_events
operational_ledger_collection_failed / _recoveredConsole WARN / INFO on a change; a result, failure or success, answers scrapes for 15 secondserror, cached_until
private_memory_erasure_table_purged, _hold_check, _lease_renewedConsole and operation log INFO; content-freeoperation_id, attempt, fence, table, phase, rows, elapsed_ms, destination_count
private_memory_erasure_lock_timeout, _renewal_failed, _claim_lostConsole and operation log WARNthe fields above plus error_code
topic maintenance lock waitINFO from 1 second, WARN from 10 secondslock (state, run, team, catalog, batch_fence), phase, wait_ms, run_id, batch_id, team_id, stage
topic maintenance preparationINFO, one per turnadds admission (admitted, run_unavailable, team_locked, no_work, stale) and stage
topic maintenance tickINFO, one per scheduler pass, also when no turn is claimedturns, admitted, blocked, duration_ms

Sink health events never queue back into the failing sink, so read them from the server console. Reconstruct a Topic failure payload from its topic_failure_payload records: consecutive chunks are packed into records of at most 16 KiB, so join the bodies in index order up to count and compare the result with the unchanged sha256 and original_bytes.

A Recall failure caused by a cancelled request context is not persisted as an ERROR row; the operation-log service rejects the already-cancelled record and counts an admission_canceled gap. A PostgreSQL failure such as a SQLSTATE error is persisted as ERROR postgres query.

Migration Observations

Capture startup migration events with the console logger at INFO or more verbose. Before the operation-log sink attaches, they are console-only. See logging configuration for LOG_LEVEL and PostgreSQL settings for migration deadlines.

All event names below start with evidence_only_migration_. Group an execution by migration_execution_id.

Event suffixMeaning
started, progressCurrent phase/work unit, elapsed time, metric/unit, completed/total/remaining counts, and last meaningful progress time.
heartbeatLiveness every ten seconds; does not advance last_progress_at.
waitCurrent wait type/event and blocker count, without query text.
completed, skippedThe final completed record carries the verified outcome and receipt. skipped identifies no newly attempted migration work; receipt verification still follows.
blocked, failed, cancellation_requested, capture_incompleteBounded failure or cancellation information and diagnostic-capture state. Cancellation request alone does not establish rollback.
%%{init: {"flowchart": {"curve": "linear"}}}%%
flowchart TB
  Observe["Phase + count observations<br/>Attempted transaction-local work"] --> Verify["Verify this execution's outcome"]
  Verify -->|"committed"| Commit["Committed receipt<br/>Durable result"]
  Verify -->|"rolled_back"| Rollback["Transaction aborted<br/>No durable cutover"]
  Verify -->|"not_started"| Absent["No cutover<br/>transaction started"]
  Verify -->|"unconfirmed"| Unknown["Inspect retained state<br/>Outcome unknown"]

Only completed with transaction_outcome=committed and a verified receipt establishes the durable result. committed_work identifies new committed work; previous_commit_verified identifies an already-applied or concurrent winner's receipt. rolled_back requires PostgreSQL to report this attempt's transaction aborted. Missing or unreconciled outcome evidence remains unconfirmed.

MetricCount meaning
countedExact counted rows.
affectedPostgreSQL command row count; it does not measure rows scanned or values changed.
matchedMatching legal holds.
verifiedRetained fingerprints whose equality check passed.
completed with unit tablesCompleted table work units, including checked absent tables.

Unknown totals and remaining work stay unknown. Long SQL statements can have no intermediate row count. Repeated observations are coalesced to at most once per second; phase/table boundaries and final counts are retained. ETA is unavailable.

A committed migration can have incomplete capture. capture_reason records notice-capture problems; wait_observation_unavailable separately records wait-probe degradation and remains set if sampling later recovers. The first failed wait sample reports wait_observation_failure_reason; it does not overwrite an existing notice-capture reason. Preserve the complete console window and investigate each reported cause. collection_queries counts additional client round trips, while sql_notices counts captured database notices.

Collect one startup execution from the bundled stack:

bash
docker compose -f examples/docker-compose.base.yml logs --no-color --no-log-prefix server |
  jq -Rc --arg run "$MIGRATION_EXECUTION_ID" \
    'fromjson? | select(.migration_execution_id == $run)'

Set MIGRATION_EXECUTION_ID to the observed execution ID. WARN-level filtering hides INFO progress. Wait observations do not authorize terminating blockers. Follow Operations Runbook for cutover, recovery, and subsequent organization rebuilding.

Dashboard States

StateMeaning
readyVerified available value, including a supported zero.
inactiveNo activity or a disabled feature under the catalog's rules.
unavailableFailed/missing source, usage, or pricing.
unsupportedThat audience/scope does not support the measurement.

Partial failures retain successful items and mark degradation. Missing Prometheus series, unknown usage, failed ledger reads, and unpriced work must not become invented zeroes. Operator-only diagnostics/cost/assessor items are not exposed as user cards.

Cost Rate Card

The control telemetry pricing panel configures optional verifier input/output, embedding input, and per-model rates. Configuration owns the setting keys. Prices are USD per million tokens and are estimates, not provider invoices.

The server snapshots rates through the normal configuration cache. Missing/invalid rates or unavailable usage leave affected work unpriced. Provider-reported usage and tokenizer estimates retain their source labels. Mixed-owner background accounting remains at supported team scope; do not fabricate per-profile allocations. Report unavailable usage explicitly.

Query Examples

sum by (outcome) (
  rate(densemem_recall_requests_total{team_id="<team-uuid>"}[5m])
)
histogram_quantile(0.95,
  sum by (le) (rate(densemem_recall_duration_seconds_bucket{team_id="<team-uuid>"}[5m]))
)

Use bounded windows and supported scope labels. TELEMETRY_PROMETHEUS_JOB adds the configured job selector to dashboard queries. Diagnose changes with activity, latency, errors, and source readiness together.

Enterprise Exports

OTLP is opt-in and requires telemetry. Traces and metrics use independent OTLP/HTTP protobuf destinations. LangSmith can receive traces; use a compatible metrics destination for metrics. Destination/header configuration is owned by Configuration.

ExportContent and limits
OTLPAllowlisted content-free operation metadata. No queries, Evidence bodies, raw result IDs, or credentials. Trace queue 2048, batches 512; export/shutdown bounds five seconds; metrics every 60 seconds.
Audit NDJSONControl-admin download; default page 100, maximum 1000 events and 1 MiB.
Diagnostic JSONControl-admin sanitized operational bundle, capped at 1 MiB.

Downloads have five-second execution/write bounds and explicit truncation where applicable. Audit pages use a captured high-water mark and continuation cursor so concurrent appends cannot change a page sequence. These exports are not database backups. Keep administrative ingress private.

Diagnose Without Inventing State

Follow Operations Runbook for incidents. Use authorized trace/conflict views for individual Evidence, and use Evaluation for retrieval-quality comparisons. A healthy scrape does not prove the PostgreSQL diagnostic sink or every derived projection is healthy.