Type to search.

Getting started with Rack

Serverless Observability

Elastic Cloud Serverless projects are autoscaled environments, fully managed by Elastic and available on Elastic Cloud.

Availability

  • Generally available

    This functionality is generally available and ready for production usage.

Stack

The Elastic Stack includes Elastic's core products such as Elasticsearch, Kibana, Logstash, and Beats.

Availability

  • Generally available

    This functionality is generally available and ready for production usage.

Unless stated otherwise on the page, this functionality is available when your Elastic Stack is deployed on Elastic Cloud Hosted, Elastic Cloud Enterprise, Elastic Cloud on Kubernetes, and self-managed environments.

This documentation corresponds to the latest patch available for each minor version. If you're not using the latest patch, check the release notes for changes.

APM Agent Ruby

The Elastic APM Ruby agent enables you to trace the execution of operations in your Ruby applications, sending performance metrics and errors to the Elastic APM Server.

Availability

  • Generally available

    This functionality is generally available and ready for production usage.

This documentation corresponds to the latest patch available for each minor version. If you're not using the latest patch, check the release notes for changes.

Add the gem to your Gemfile:

Ruby
gem 'elastic-apm'

Create a file config/elastic_apm.yml:

YAML
server_url: http://localhost:8200
secret_token: ''

Include the middleware, start (and stop) Elastic APM when booting your app:

Ruby
# config.ru

app = lambda do |env|
  [200, {'Content-Type' => 'text/plain'}, ['ok']]
end

# Wraps all requests in transactions and reports exceptions
use ElasticAPM::Middleware

# Start an instance of the Agent
ElasticAPM.start(service_name: 'NothingButRack')

run app

# Gracefully stop the agent when process exits.
# Makes sure any pending transactions are sent.
at_exit { ElasticAPM.stop }
Ruby
# Example config.ru

require 'sinatra/base'

class MySinatraApp < Sinatra::Base
  use ElasticAPM::Middleware

  # ...
end

# Takes optional ElasticAPM::Config values
ElasticAPM.start(app: MySinatraApp, ...)

# You can also do the following, which is equivalent to the above:
# ElasticAPM::Sinatra.start(MySinatraApp, ...)

run MySinatraApp

at_exit { ElasticAPM.stop }
Ruby
# Example config.ru

require 'grape'

module Twitter
  class API < Grape::API
    use ElasticAPM::Middleware

  # ...
  end
end

# Start the agent and hook in your app
ElasticAPM::Grape.start(Twitter::API, config)

run Twitter::API