Sha256: 73394209b77a2ced769013c9839ccf0071ba387e55a1fb358023e2cf79bc3a58

Contents?: true

Size: 779 Bytes

Versions: 10

Compression:

Stored size: 779 Bytes

Contents

# encoding: utf-8

require 'ting_yun/agent/datastore/metric_helper'
require 'ting_yun/agent/method_tracer'


module TingYun
  module Agent
    module Datastore


      def self.wrap(product, operation, collection = nil, callback = nil)
        return yield unless operation

        metrics = TingYun::Agent::Datastore::MetricHelper.metrics_for(product, operation, collection)

        scoped_metric = metrics.last

        TingYun::Agent::MethodTracer.trace_execution_scoped(metrics) do
          t0 = Time.now
          begin
            result = yield
          ensure
            elapsed_time = (Time.now - t0).to_f
            if callback
              callback.call(result, scoped_metric, elapsed_time)
            end
          end
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
tingyun_rpm-1.2.0 lib/ting_yun/agent/datastore.rb
tingyun_rpm-1.1.4.2 lib/ting_yun/agent/datastore.rb
tingyun_rpm-1.1.4.1 lib/ting_yun/agent/datastore.rb
tingyun_rpm-1.1.4 lib/ting_yun/agent/datastore.rb
tingyun_rpm-1.1.3 lib/ting_yun/agent/datastore.rb
tingyun_rpm-1.1.2 lib/ting_yun/agent/datastore.rb
tingyun_rpm-1.1.1 lib/ting_yun/agent/datastore.rb
tingyun_rpm-1.1.0 lib/ting_yun/agent/datastore.rb
tingyun_rpm-1.0.7 lib/ting_yun/agent/datastore.rb
tingyun_rpm-1.0.6 lib/ting_yun/agent/datastore.rb