Error and performance monitoring for Ruby backends. Report errors out of Rack
or Rails with original-source context per stack frame, time every request and any
sub-span you open into a waterfall, and join each server error to the client SDK
error for the same request through the W3C traceparent header. In the
dashboard you see the full client and server stack under one trace.
Octri turns an OpenAPI spec into a documentation site, client SDKs for ten languages, an MCP server your AI assistant can call, and monitoring for the API behind them. This gem is the Ruby monitoring runtime, and it works on its own: a generated Octri API SDK is not required. See octri.dev/monitoring.
Ruby 2.7 or newer. Standard library only. The Ruby sibling of
@octri/node.
gem install octrirequire "octri"
require "octri/rack"
Octri.init(
url: "https://monitoring.example.com",
token: ENV["OCTRI_TOKEN"],
environment: "<your project id>",
release: ENV["GIT_SHA"] # optional
)
# config.ru / Rails middleware stack:
use Octri::RackHosted users can copy the project-scoped URL, token, and environment from the
Monitoring connection settings (or its API). Omit token: only when pointing
at an open self-hosted ingest endpoint. Every request carries an idempotency key.
No generated API SDK is required to send your own events:
Octri.capture_event(
"checkout.completed",
user: { id: customer.id },
tags: { region: "eu-west", plan: "growth" },
context: { order_id: order.id, total: order.total }
)Delivery is best-effort and runs on a background thread. Pass event_id: to
make a retried delivery idempotent.
Octri::Rack captures any exception raised by the app (linked to the request's
trace) and re-raises, and times the request as a server span.
Octri.auto_instrument # traces outbound Net::HTTP calls
Octri.instrument(PG::Connection, [:exec], op: "db") # your DB client / util class, once
Octri.instrument(cache, [:get, :set], op: "cache")Every instrumented call (and every outbound HTTP request) becomes a sub-span under the current request, with no per-call code. Calls to your monitoring backend are never traced (no feedback loop).
Octri.span("orders.list", op: "db") do
Order.where(status: "open").to_a
end
# or manual control:
s = Octri.start_span("cache.get", op: "cache")
value = cache.read(key)
s.finishop ("db", "cache", "http", and so on) color-codes the waterfall; nested Octri.span
calls nest correctly.
begin
risky!
rescue => e
Octri.capture_error(e)
raise
endPayloads are scrubbed on the way out, so a credential that ended up in a log line or a context object never reaches the dashboard.
Any key whose name looks like a credential (password, secret, token,
apiKey, authorization, cookie, ssn and the rest of the usual list) has
its value replaced with [redacted], at any depth. Matching ignores case and
separators, so api_key, apiKey and X-API-KEY are all the same key.
Free text is swept too: the message, an error message and its stack, and
anything else you send as a string. Bearer tokens, JWTs, card numbers and email
addresses come out as [redacted]. A card number has to pass the Luhn check
first, so an order number or a timestamp survives.
user is the exception. It is the field you fill with an identity on purpose,
so user.email is reported exactly as you set it. Credential-shaped keys inside
it are still redacted.
Add your own key names:
Octri.add_scrub_fields("account_number", "otp")Or take the payload yourself, and return nil to drop the event:
Octri.set_before_send { |payload| payload[:path] == "/health" ? nil : payload }Redaction runs after your hook, so a hook cannot leak a credential by accident.
| Product | What it does |
|---|---|
| API Studio | Your OpenAPI spec becomes a hosted documentation site with a live request playground, editable page by page. |
| SDK Studio | The same spec becomes client libraries for ten languages, versioned and released together. |
| MCP | Your endpoints and docs become tools an AI assistant can call, generated from the same spec. |
| Monitoring | Errors, traces, uptime and releases for the API, joined to the SDK calls that reached it. |
MIT licensed.