feat(agent-memory): Phase 9 — observability#257
Open
jamby77 wants to merge 1 commit into
Open
Conversation
eea7699 to
ee647cc
Compare
339567e to
312772a
Compare
14b6e7c to
9412e5a
Compare
312772a to
22b6f78
Compare
9412e5a to
37c7a4b
Compare
22b6f78 to
b160dd0
Compare
37c7a4b to
06b56f6
Compare
b160dd0 to
b29dd7e
Compare
- Add createMemoryTelemetry: prom-client metrics (items gauge, recall total/hits/empty, recall latency histogram, embedding calls, evictions, consolidations) with a configurable prefix, plus an OTel tracer - Emit spans for remember/recall/consolidate via a traced() helper with OK/ERROR status, recording k/candidate-count/result-count and candidate/created/deleted attributes - Wire metrics through remember/recall/consolidate/forget/forgetByScope/ embed and the capacity-eviction path - Telemetry option (tracerName/metricsPrefix/registry); no-op tracer and default registry when unset, mirroring agent-cache - Add @opentelemetry/api + prom-client deps and the OTel SDK dev dep
b29dd7e to
4ea754e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #256 (Phase 8 — self-optimization config reads).
What
Phase 9 of
@betterdb/agent-memory: OpenTelemetry spans + Prometheus metrics, mirroring the agent-cache/semantic-cache telemetry pattern.createMemoryTelemetry({ tracerName?, metricsPrefix?, registry? })builds a prom-client metric set + an OTel tracer. Metrics (prefix configurable, defaultagent_memory):agent_memory_items(gauge)agent_memory_recall_total/agent_memory_recall_hits_total/agent_memory_recall_empty_totalagent_memory_recall_latency_seconds(histogram)agent_memory_embedding_calls_totalagent_memory_evictions_totalagent_memory_consolidations_totalSpans via a
traced()helper (OK/ERROR status, alwaysend()):agent_memory.remember—memory.importance,memory.ttlagent_memory.recall—recall.k,recall.candidate_count,recall.result_countagent_memory.consolidate—consolidate.candidates,consolidate.created,consolidate.deletedMetrics are wired through remember/recall/consolidate/forget/forgetByScope/embed and the capacity-eviction path. All
store_name-labelled.Design / review notes
.call-sequence unit tests are unaffected.itemsgauge is an in-process net delta (documented as approximate). Eviction/forget/consolidate decrement it; remember increments it.Deps
Adds
@opentelemetry/api,prom-client(deps, matching agent-cache) and@opentelemetry/sdk-trace-base(devDep, for the in-memory span exporter used in tests). Lockfile updated.Tests
MemoryStore.telemetry.test.ts(6): embedding+items on remember · recall hit (+latency count) · empty recall · evictions · consolidations · configurable prefix — all read a real promRegistry.MemoryStore.spans.test.ts(3): remember/recall/consolidate spans + attributes, asserted via anInMemorySpanExporter.86/86 package tests green ·
tscclean · prettier clean.Note
Low Risk
Observability is additive and no-op until a tracer provider or custom registry is configured; core memory logic behavior is unchanged aside from metric side effects.
Overview
Adds Phase 9 observability to
@betterdb/agent-memory: a newtelemetry.tswithcreateMemoryTelemetry()(configurable tracer name, metrics prefix, and promRegistry), exported from the package public API.MemoryStoreaccepts optionaltelemetryoptions and wires OpenTelemetry spans aroundremember,recall, andconsolidatevia atraced()helper (OK/ERROR status, operation-specific attributes). Prometheus metrics are updated on the main paths: recall totals/hits/empty/latency, embedding calls, an in-processitemsgauge (inc/dec on remember, forget, eviction, consolidate), plus evictions and consolidation counters—all labeled bystore_name.Dependencies add
@opentelemetry/apiandprom-client; tests cover metrics against a realRegistryand spans via an in-memory OTel exporter.Reviewed by Cursor Bugbot for commit 4ea754e. Bugbot is set up for automated code reviews on this repo. Configure here.