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 --> ControlActive Metrics
| Family | Current signals |
|---|---|
| HTTP | densemem_http_requests_total, densemem_http_request_duration_seconds. |
| Embeddings | densemem_embedding_requests_total, densemem_embedding_errors_total, densemem_embedding_duration_seconds, densemem_embedding_tokens_total. |
| Remember | densemem_remember_acknowledgements_total, densemem_remember_acknowledgement_duration_seconds. |
| Recall | densemem_recall_requests_total, densemem_recall_duration_seconds, densemem_recall_results. |
| Feedback | densemem_recall_feedback_total, densemem_recall_feedback_quality_score. |
| Assessment | densemem_assessor_requests_total, densemem_assessor_duration_seconds, densemem_assessor_tokens_total, densemem_assessor_validation_failures_total, densemem_assessor_validation_field_failures_total. |
| Topic maintenance | densemem_topic_maintenance_batches_total by stage and outcome (ok, failed, interrupted), densemem_topic_maintenance_slow_lock_wait_seconds by lock. |
| Usage/cost | densemem_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 route | Investigation |
|---|---|
/control/api/logs | Severity, correlation, request/attempt, and bounded classification filters. |
/control/api/remember-invocations | Admitted call list. |
/control/api/teams/{teamId}/remember-invocations/{invocationId} | Selected invocation detail and authorized captures. |
/control/api/remember-attempts | Canonical 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.
| Event | Level and evidence |
|---|---|
mcp_progress_eligibility | DEBUG: response mode, protocol and eligibility reason; no token value before admission. |
mcp_progress_sending / mcp_progress_delivered | DEBUG: trusted team/profile and correlation, request/invocation identity, protected token, stage, sequence, write budget and delivery duration. |
mcp_progress_delivery_failed | WARN: 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.
stage | Level | Common reason_code values |
|---|---|---|
oauth_discovery | WARN | external_provider_unavailable, public_base_url_invalid, provider_list_unavailable |
oauth_dcr | INFO / WARN | invalid_redirect_uri, invalid_client_metadata, body_too_large, client_limit_reached, rate_limited |
oauth_cimd | INFO / WARN | ssrf_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_init | DEBUG / WARN | client_unverified, invalid_redirect_uri, pkce_required, pkce_plain_rejected, invalid_target, invalid_scope, duplicate_parameter, malformed_query (#885), rate_limited |
oauth_consent_auth | WARN | key_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_deny | INFO | None; records team, profile, method, scopes, and resource. |
oauth_token_exchange, oauth_token_refresh | INFO / WARN | pkce_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_protocol | WARN / ERROR | rate_limited on /oauth/token, internal_error |
oauth_revoke | INFO | No 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_auth | WARN | token_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_prune | DEBUG / INFO / WARN | store_unavailable |
Entries marked #885 come from the pending application change #885. With it:
malformed_queryreports an authorize request whose query has an invalid percent escape or a literal;. The response is a non-redirectinginvalid_request, and the record carries no parameter value.sso_provider_disabledreports 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_completedaddsclients_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:
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.
| Event | Where and level | Fields |
|---|---|---|
slow postgres query | Console WARN, one per statement over POSTGRES_SLOW_QUERY_THRESHOLD_MS | sql, rows, duration_ms, sql_fingerprint, correlation |
slow_postgres_query_summary | Operation 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_recovered | Console WARN / INFO, once per sink failure episode | error, batch_size, retained_rows, queued, retry_after_ms / failure_duration_ms |
operation_log_events_dropped | Console WARN, once per drop episode | reason, dropped_events, dropped_total, queued |
operation_log_gap_recovered | Operation log marker operation log gap recovered, mirrored to the console | dropped_events |
operational_ledger_collection_failed / _recovered | Console WARN / INFO on a change; a result, failure or success, answers scrapes for 15 seconds | error, cached_until |
private_memory_erasure_table_purged, _hold_check, _lease_renewed | Console and operation log INFO; content-free | operation_id, attempt, fence, table, phase, rows, elapsed_ms, destination_count |
private_memory_erasure_lock_timeout, _renewal_failed, _claim_lost | Console and operation log WARN | the fields above plus error_code |
topic maintenance lock wait | INFO from 1 second, WARN from 10 seconds | lock (state, run, team, catalog, batch_fence), phase, wait_ms, run_id, batch_id, team_id, stage |
topic maintenance preparation | INFO, one per turn | adds admission (admitted, run_unavailable, team_locked, no_work, stale) and stage |
topic maintenance tick | INFO, one per scheduler pass, also when no turn is claimed | turns, 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 suffix | Meaning |
|---|---|
started, progress | Current phase/work unit, elapsed time, metric/unit, completed/total/remaining counts, and last meaningful progress time. |
heartbeat | Liveness every ten seconds; does not advance last_progress_at. |
wait | Current wait type/event and blocker count, without query text. |
completed, skipped | The 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_incomplete | Bounded 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.
| Metric | Count meaning |
|---|---|
counted | Exact counted rows. |
affected | PostgreSQL command row count; it does not measure rows scanned or values changed. |
matched | Matching legal holds. |
verified | Retained fingerprints whose equality check passed. |
completed with unit tables | Completed 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:
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
| State | Meaning |
|---|---|
ready | Verified available value, including a supported zero. |
inactive | No activity or a disabled feature under the catalog's rules. |
unavailable | Failed/missing source, usage, or pricing. |
unsupported | That 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.
| Export | Content and limits |
|---|---|
| OTLP | Allowlisted 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 NDJSON | Control-admin download; default page 100, maximum 1000 events and 1 MiB. |
| Diagnostic JSON | Control-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.