Skip to content

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

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

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.
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

1 participant