Skip to content

feat: introduce span cache that allows lookup by traceId, sessionId and OC sessionKey - #15

Merged
91pavan merged 9 commits into
mainfrom
feat/in-plugin-cache
Apr 24, 2026
Merged

feat: introduce span cache that allows lookup by traceId, sessionId and OC sessionKey#15
91pavan merged 9 commits into
mainfrom
feat/in-plugin-cache

Conversation

@91pavan

@91pavan 91pavan commented Apr 17, 2026

Copy link
Copy Markdown
Collaborator

This PR does two related things:

  1. Adds an opt-in in-memory span cache so recently ended spans can be inspected by trace, session UUID, or runtime session key.

Cache lifecycle management:

  • periodic stale sweep - a 60 s background interval removes any record older than 30 min. Handles cases where an agent crashes without emitting a clean session end.
  • explicit flush on session end - each session key is capped at 500 records; oldest are evicted from the front if the limit is hit mid-session.
  • flush on idle timeout
  • full stop/clear on watcher shutdown
  1. Fixes span ordering and request-completion behavior so traces reflect the real OpenClaw lifecycle, especially when outbound delivery signals are delayed or missing.

…nd OC sessionKey

Signed-off-by: Pavan Sudheendra <pavan0591@gmail.com>
@91pavan
91pavan requested a review from a team as a code owner April 17, 2026 14:48
91pavan added 7 commits April 20, 2026 08:37
Signed-off-by: Pavan Sudheendra <pavan0591@gmail.com>
…_output closes

Signed-off-by: Pavan Sudheendra <pavan0591@gmail.com>
Signed-off-by: Pavan Sudheendra <pavan0591@gmail.com>
…lity plugin when OpenClaw does not emit a reliable outbound delivery signal

This PR makes request completion more robust by:

deferring root span completion until an outbound completion signal is observed
using diagnostic message.processed as an additional completion source
inferring outbound completion from agent_end for webchat when no stronger signal exists
recording explicit completion reasons on the request span for easier trace analysis

Signed-off-by: Pavan Sudheendra <pavan0591@gmail.com>
Signed-off-by: Pavan Sudheendra <pavan0591@gmail.com>
Signed-off-by: Pavan Sudheendra <pavan0591@gmail.com>

@Castorche Castorche left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

overall lgtm, a few comments related to semantic convention.

Comment thread observability-plugin/src/hooks.ts Outdated
Comment thread observability-plugin/src/hooks.ts Outdated
Comment thread observability-plugin/src/hooks.ts Outdated
Comment thread observability-plugin/src/hooks.ts
Comment thread observability-plugin/src/hooks.ts
Signed-off-by: Pavan Sudheendra <pavan0591@gmail.com>

@Castorche Castorche left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@91pavan
91pavan merged commit c245319 into main Apr 24, 2026
4 of 5 checks passed
@91pavan
91pavan deleted the feat/in-plugin-cache branch April 24, 2026 07:10
91pavan added a commit that referenced this pull request May 20, 2026
…nd OC sessionKey (#15)

* feat: introduce span cache that allows lookup by traceId, sessionId and OC sessionKey

Signed-off-by: Pavan Sudheendra <pavan0591@gmail.com>

* feat: add debug logs

Signed-off-by: Pavan Sudheendra <pavan0591@gmail.com>

* feat: fix sequencing order: finalize agent/request after the last llm_output closes

Signed-off-by: Pavan Sudheendra <pavan0591@gmail.com>

* fix: duplicate agent span being created for the same runtime session

Signed-off-by: Pavan Sudheendra <pavan0591@gmail.com>

* feat: This change fixes request lifecycle completion in the observability plugin when OpenClaw does not emit a reliable outbound delivery signal

This PR makes request completion more robust by:

deferring root span completion until an outbound completion signal is observed
using diagnostic message.processed as an additional completion source
inferring outbound completion from agent_end for webchat when no stronger signal exists
recording explicit completion reasons on the request span for easier trace analysis

Signed-off-by: Pavan Sudheendra <pavan0591@gmail.com>

* fix: tests

Signed-off-by: Pavan Sudheendra <pavan0591@gmail.com>

* feat: add memory_failure_rate metric that uses the cache spans

Signed-off-by: Pavan Sudheendra <pavan0591@gmail.com>

* feat: address review comments

Signed-off-by: Pavan Sudheendra <pavan0591@gmail.com>

---------

Signed-off-by: Pavan Sudheendra <pavan0591@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants