Skip to content

Add first-class per-call metadata for observability (#807) - #825

Closed
goianiense wants to merge 1 commit into
crmne:mainfrom
goianiense:feature/807-per-call-metadata
Closed

Add first-class per-call metadata for observability (#807)#825
goianiense wants to merge 1 commit into
crmne:mainfrom
goianiense:feature/807-per-call-metadata

Conversation

@goianiense

@goianiense goianiense commented Jun 26, 2026

Copy link
Copy Markdown

Summary

  • Adds RubyLLM::Metadata (namespace + tags) and Chat#with_metadata for opt-in caller attribution on instrumentation events
  • Includes metadata in chat.ruby_llm and tool_call.ruby_llm payloads; one-shot APIs (embed, paint, moderate, speak, transcribe) accept metadata:
  • Delegates through Agent and ActiveRecord ChatMethods; documents usage in the instrumentation guide

Closes #807

Test plan

  • bundle exec rspec spec/ruby_llm/instrumentation_spec.rb
  • Confirm subscribers can read payload[:metadata] without reaching into chat ivars
  • Smoke-test with_metadata chaining merges tags and replaces namespace when set

Introduce RubyLLM::Metadata and Chat#with_metadata so apps can attach
namespace/tags that flow into instrumentation payloads without
monkey-patching. One-shot APIs accept a metadata: keyword; Agent and
ActiveRecord chat models delegate the fluent API.
@crmne

crmne commented Jul 3, 2026

Copy link
Copy Markdown
Owner

Thanks for the PR.

We took the core observability idea, but not this API shape. Main now supports simple metadata on the one-shot APIs and includes it directly in the instrumentation payload. That landed in 1bc6fc0.

The smaller shape intentionally avoids a RubyLLM::Metadata value object and does not add chat, agent, or ActiveRecord metadata APIs in this PR's form. Provider request customization stays under params.

Closing this PR as superseded. The linked issue remains open for the separate question of whether chat and tool-call instrumentation should get a minimal metadata API too.

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.

[FEATURE] First-class per-call metadata context for observability attribution

2 participants