module AppPerfRpm::Instruments::Redis

Public Instance Methods

call_pipeline_with_trace(*pipeline) click to toggle source
# File lib/app_perf_rpm/instruments/redis.rb, line 34
def call_pipeline_with_trace(*pipeline)
  if ::AppPerfRpm::Tracer.tracing?
    span = ::AppPerfRpm.tracer.start_span("redis", tags: {
      "component" => "Redis",
      "span.kind" => "client",
      "peer.address" => self.host,
      "peer.port" => self.port,
      "db.type" => "redis",
      "db.vendor" => "redis",
      "db.instance" => self.db,
      "db.statement" => pipeline[0].commands.map { |c| format_redis_command(c) }.join("\n")
    })
    AppPerfRpm::Utils.log_source_and_backtrace(span, :redis)
  end

  call_pipeline_without_trace(*pipeline)
rescue Exception => e
  if span
    span.set_tag('error', true)
    span.log_error(e)
  end
  raise
ensure
  span.finish if span
end
call_with_trace(*command, &block) click to toggle source
# File lib/app_perf_rpm/instruments/redis.rb, line 8
def call_with_trace(*command, &block)
  if ::AppPerfRpm::Tracer.tracing?
    span = ::AppPerfRpm.tracer.start_span("redis", tags: {
      "component" => "Redis",
      "span.kind" => "client",
      "peer.address" => self.host,
      "peer.port" => self.port,
      "db.type" => "redis",
      "db.vendor" => "redis",
      "db.instance" => self.db,
      "db.statement" => format_redis_command(*command)
    })
    AppPerfRpm::Utils.log_source_and_backtrace(span, :redis)
  end

  call_without_trace(*command, &block)
rescue Exception => e
  if span
    span.set_tag('error', true)
    span.log_error(e)
  end
  raise
ensure
  span.finish if span
end