Ruby SDK — full reference
Gem: amlexia
Feature parity with Node and Python.
Install
bash
gem install amlexia
# Gemfile:
# gem "amlexia"Environment
env
AMLEXIA_SDK_KEY=am_...
AMLEXIA_INGEST_URL=https://ingest.amlexia.com
AMLEXIA_ENVIRONMENT=productionClient
ruby
require "amlexia"
client = Amlexia::Client.from_env
client.track(
endpoint: "/api/users",
method: "GET",
status_code: 200,
latency_ms: 42,
environment: ENV["AMLEXIA_ENVIRONMENT"]
)
at_exit { client.shutdown }Options
ruby
client = Amlexia::Client.new(
sdk_key: ENV["AMLEXIA_SDK_KEY"],
sample_rate: 0.25,
diagnostic: true,
flush_interval_ms: 5000,
max_batch_size: 50
)OpenAI
ruby
Amlexia::OpenAI.track_openai_completion(
client,
model: "gpt-4o-mini",
status_code: 200,
latency_ms: 500,
usage: { prompt_tokens: 100, completion_tokens: 40 }
)Anthropic
ruby
Amlexia::Anthropic.track_message(client, ...)HTTP wrapper
Use the gem’s HTTP helper to wrap outbound calls — see sdks/ruby/lib/amlexia/http_wrap.rb.
Health
bash
amlexia healthRails
Add initializer:
ruby
# config/initializers/amlexia.rb
AMLEXIA = Amlexia::Client.from_env
at_exit { AMLEXIA.shutdown }Track in middleware or around_action for controllers.
