Sha256: ad3261edf31f602186c4fa29bbb94c54a5ed94a8ff57006aa9214062152e831e

Contents?: true

Size: 1.94 KB

Versions: 40

Compression:

Stored size: 1.94 KB

Contents

# Copyright (c) 2013 AppNeta, Inc.
# All rights reserved.

module TraceView
  module PadrinoInst
    module Rendering
      def self.included(klass)
        ::TraceView::Util.method_alias(klass, :render, ::Padrino::Rendering)
      end

      def render_with_traceview(engine, data = nil, options = {}, locals = {}, &block)
        if TraceView.tracing?
          report_kvs = {}

          if data
            report_kvs[:engine] = engine
            report_kvs[:template] = data
          else
            report_kvs[:template] = engine
          end

          if TraceView.tracing_layer_op?('render')
            # For recursive calls to :render (for sub-partials and layouts),
            # use method profiling.
            begin
              report_kvs[:FunctionName] = :render
              report_kvs[:Class]        = :Rendering
              report_kvs[:Module]       = 'Padrino'
              report_kvs[:File]         = __FILE__
              report_kvs[:LineNumber]   = __LINE__
            rescue StandardError => e
              ::TraceView.logger.debug e.message
              ::TraceView.logger.debug e.backtrace.join(', ')
            end

            TraceView::API.profile(report_kvs[:template], report_kvs, false) do
              render_without_traceview(engine, data, options, locals, &block)
            end
          else
            # Fall back to the raw tracing API so we can pass KVs
            # back on exit (a limitation of the TraceView::API.trace
            # block method) This removes the need for an info
            # event to send additonal KVs
            ::TraceView::API.log_entry('render', {}, 'render')

            begin
              render_without_traceview(engine, data, options, locals, &block)
            ensure
              ::TraceView::API.log_exit('render', report_kvs)
            end
          end
        else
          render_without_traceview(engine, data, options, locals, &block)
        end
      end
    end
  end
end

Version data entries

40 entries across 40 versions & 1 rubygems

Version Path
traceview-3.8.0-java lib/traceview/frameworks/padrino/templates.rb
traceview-3.8.0 lib/traceview/frameworks/padrino/templates.rb
traceview-3.7.1-java lib/traceview/frameworks/padrino/templates.rb
traceview-3.7.1 lib/traceview/frameworks/padrino/templates.rb
traceview-3.7.0-java lib/traceview/frameworks/padrino/templates.rb
traceview-3.7.0 lib/traceview/frameworks/padrino/templates.rb
traceview-3.6.0-java lib/traceview/frameworks/padrino/templates.rb
traceview-3.6.0 lib/traceview/frameworks/padrino/templates.rb
traceview-3.5.1-java lib/traceview/frameworks/padrino/templates.rb
traceview-3.5.1 lib/traceview/frameworks/padrino/templates.rb
traceview-3.5.0-java lib/traceview/frameworks/padrino/templates.rb
traceview-3.5.0 lib/traceview/frameworks/padrino/templates.rb
traceview-3.4.2-java lib/traceview/frameworks/padrino/templates.rb
traceview-3.4.2 lib/traceview/frameworks/padrino/templates.rb
traceview-3.4.1-java lib/traceview/frameworks/padrino/templates.rb
traceview-3.4.1 lib/traceview/frameworks/padrino/templates.rb
traceview-3.4.0-java lib/traceview/frameworks/padrino/templates.rb
traceview-3.4.0 lib/traceview/frameworks/padrino/templates.rb
traceview-3.3.3-java lib/traceview/frameworks/padrino/templates.rb
traceview-3.3.3 lib/traceview/frameworks/padrino/templates.rb