Skip to content

fix: Observability Resources tab always empty — span name mismatch and session isolation#3977

Open
ecthelion77 wants to merge 1 commit intoIBM:mainfrom
forterro:fix/observability-resource-tab-empty
Open

fix: Observability Resources tab always empty — span name mismatch and session isolation#3977
ecthelion77 wants to merge 1 commit intoIBM:mainfrom
forterro:fix/observability-resource-tab-empty

Conversation

@ecthelion77
Copy link
Copy Markdown
Contributor

🐛 Bug-fix PR

📌 Summary

The admin Observability dashboard's Resources and Prompts tabs always show "No data" despite resources being fetched and prompts being rendered. This is caused by two independent bugs.

Supersedes #3970 (which only addressed the span name, not the session issue).

Fixes #3969

🐞 Root Cause

Bug 1 — Span name mismatch in invoke_resource():

  • invoke_resource() creates spans named "invoke.resource"
  • The dashboard queries filter for ["resource.read", "resources.read", "resource.fetch"]
  • "invoke.resource" matches none of these
  • The debug log even says "Created resource.read span" — the correct name was intended

Bug 2 — DB session conflict in start_span():

  • Both prompt_service.py and resource_service.py use the handler's db session for start_span()
  • The session may be released before the network call completes, causing the span write to silently fail
  • resource_service.py already uses fresh_db_session() for end_span(), but start_span() was missed
  • prompt_service.py uses db for both start_span() and end_span()

💡 Fix Description

  1. Rename "invoke.resource""resource.read" in 5 places within invoke_resource(): database span, OpenTelemetry span, input/output capture checks, debug log

  2. Wrap all start_span() and end_span() calls with fresh_db_session() context manager in both resource_service.py and prompt_service.py, matching the pattern already established in invoke_resource()'s end_span block

🧪 Verification

Check Command Result
Lint suite make lint ✅ Only string literal + session wrapper changes
Unit tests make test ✅ No test references "invoke.resource"
Manual test Deployed and verified ✅ Resources + Prompts tabs show data

📐 MCP Compliance

  • Matches current MCP spec
  • No breaking change to MCP clients

✅ Checklist

  • Code formatted (make black isort pre-commit)
  • No secrets/credentials committed
  • DCO Signed-off-by included

@vishu-bh
Copy link
Copy Markdown
Collaborator

Thanks @ecthelion77 identifying the span name mismatch issue!.

PR #4050 (merged April 8) refactored the observability API and already fixed the session isolation issue you addressed.
Your span name fix is still needed! ✅

Please rebase and simplify to only rename "invoke.resource" → "resource.read" in these 5 places:

  • resource_service.py lines 1668, 1690, 1995, 2000 - Debug log message

Remove all session management changes - the new API handles this automatically:
db_span_id = observability_service.start_span( trace_id=trace_id, name="resource.read", attributes={...} )

Once resolved, this can be reviewed.

@ecthelion77 ecthelion77 force-pushed the fix/observability-resource-tab-empty branch from a48a816 to 36194d4 Compare April 13, 2026 08:49
@ecthelion77
Copy link
Copy Markdown
Contributor Author

Thanks @vishu-bh for the detailed review!

Done — rebased on main and simplified as requested:

  • Removed all session management changes (PR fix: observability data incorrectly rolled back with failed transactions #4050 handles this now)
  • Kept the span name rename "invoke.resource""resource.read" in all 5 places:
    • start_span(name=...)
    • is_input_capture_enabled(...)
    • create_span(...)
    • is_output_capture_enabled(...) ← was missing in original PR, now included
    • logger.debug("✓ Ended ... span:")

Single commit, single file, 5 line changes. Ready for review.

@ecthelion77
Copy link
Copy Markdown
Contributor Author

Suggested labels: bug, SHOULD, python, observability, ui

@vishu-bh vishu-bh force-pushed the fix/observability-resource-tab-empty branch from 36194d4 to 9d1a354 Compare April 14, 2026 10:55
@vishu-bh vishu-bh requested a review from brian-hussey as a code owner April 14, 2026 10:55
@vishu-bh vishu-bh added python Python / backend development (FastAPI) observability Observability, logging, monitoring SHOULD P2: Important but not vital; high-value items that are not crucial for the immediate release bug Something isn't working labels Apr 14, 2026
@vishu-bh vishu-bh added this to the Release 1.0.0 milestone Apr 14, 2026
vishu-bh
vishu-bh previously approved these changes Apr 14, 2026
Copy link
Copy Markdown
Collaborator

@vishu-bh vishu-bh left a comment

Choose a reason for hiding this comment

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

Changes are clean. Thanks @ecthelion77 for addressing the bug. LGTM

@ecthelion77 ecthelion77 force-pushed the fix/observability-resource-tab-empty branch from 9d1a354 to 6217a1a Compare April 14, 2026 12:17
@ecthelion77 ecthelion77 force-pushed the fix/observability-resource-tab-empty branch 2 times, most recently from 37792e9 to 402bb6c Compare April 14, 2026 15:34
…urce.read

Signed-off-by: Olivier Gintrand <olivier.gintrand@forterro.com>
@ecthelion77 ecthelion77 force-pushed the fix/observability-resource-tab-empty branch from 402bb6c to 07da8d6 Compare April 14, 2026 15:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working observability Observability, logging, monitoring python Python / backend development (FastAPI) SHOULD P2: Important but not vital; high-value items that are not crucial for the immediate release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: Observability Resources tab always empty — span name mismatch ("invoke.resource" vs "resource.read")

3 participants