module ElasticAPM

def self.add_filter(key, callback = nil, &block)

Returns:
  • (Bool) - true

Other tags:
    Yield: - A filter. Will be used if provided. Otherwise using `callback`

Parameters:
  • callback (Object, Proc) -- A filter that responds to #call(payload)
  • key (Symbol) -- Unique filter key
def self.add_filter(key, callback = nil, &block)
  if callback.nil? && !block_given?
    raise ArgumentError, '#add_filter needs either `callback\' or a block'
  end
  agent && agent.add_filter(key, block || callback)
end

def self.agent

Returns:
  • (Agent) - Currently running [Agent] if any
def self.agent
  Agent.instance
end

def self.build_context(rack_env)

Returns:
  • (Context) - The built context

Parameters:
  • rack_env (Rack::Env) -- A Rack env
def self.build_context(rack_env)
  agent && agent.build_context(rack_env)
end

def self.current_transaction

Returns:
  • (Transaction) - if any
def self.current_transaction
  agent && agent.current_transaction
end

def self.report(exception, handled: true)

Returns:
  • (Error) - The generated [Error]

Parameters:
  • handled (Boolean) -- Whether the exception was rescued
  • exception (Exception) -- The exception
def self.report(exception, handled: true)
  agent && agent.report(exception, handled: handled)
end

def self.report_message(message, **attrs)

Returns:
  • (Error) - The generated [Error]

Parameters:
  • message (String) -- The message
def self.report_message(message, **attrs)
  agent && agent.report_message(message, backtrace: caller, **attrs)
end

def self.running?

Returns:
  • (Boolean) - Whether there's an [Agent] running
def self.running?
  Agent.running?
end

def self.set_custom_context(custom)

Returns:
  • (Hash) - The current custom context

Parameters:
  • custom (Hash) -- A hash with custom information. Can be nested.
def self.set_custom_context(custom)
  agent && agent.set_custom_context(custom)
end

def self.set_tag(key, value)

Returns:
  • (Object) - The given value

Parameters:
  • value (Object) -- A value (will be converted to string)
  • key (String, Symbol) -- A key
def self.set_tag(key, value)
  agent && agent.set_tag(key, value)
end

def self.set_user(user)

Returns:
  • (Object) - Given user

Parameters:
  • user (Object) -- An object representing a user
def self.set_user(user)
  agent && agent.set_user(user)
end

def self.span(name, type = nil, context: nil, include_stacktrace: true,

Returns:
  • (Span) - Unless block given

Other tags:
    Yield: - Optional block encapsulating span

Parameters:
  • context (Span::Context) -- Context information about the span
  • type (String) -- The kind of span, eq `db.mysql2.query`
  • name (String) -- A description of the span, eq `SELECT FROM "users"`
def self.span(name, type = nil, context: nil, include_stacktrace: true,
  &block)
  return (block_given? ? yield : nil) unless agent
  agent.span(
    name,
    type,
    context: context,
    backtrace: include_stacktrace ? caller : nil,
    &block
  )
end

def self.start(config = {})

Returns:
  • (Agent) - The resulting [Agent]

Parameters:
  • config (Config) -- An instance of Config
def self.start(config = {})
  Agent.start config
end

def self.stop

Stops the ElasticAPM Agent
def self.stop
  Agent.stop
end

def self.transaction(name = nil, type = nil, context: nil, &block)

Returns:
  • (Transaction) - Unless block given

Other tags:
    Yield: - Optional block encapsulating transaction

Parameters:
  • context (Context) -- An optional [Context]
  • type (String) -- The kind of the transaction, eg `app.request.get` or
  • name (String) -- A description of the transaction, eg
def self.transaction(name = nil, type = nil, context: nil, &block)
  return (block_given? ? yield : nil) unless agent
  agent.transaction(name, type, context: context, &block)
end