Module: Instana::CubaPathTemplateExtractor

Defined in:
lib/instana/frameworks/cuba.rb

Constant Summary collapse

REPLACE_TARGET =
/:(?<term>[^\/]+)/i

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.prepended(base) ⇒ Object



10
11
12
# File 'lib/instana/frameworks/cuba.rb', line 10

def self.prepended(base)
  ::Instana.logger.debug "#{base} prepended #{self}"
end

Instance Method Details

#call!(env) ⇒ Object



26
27
28
29
30
31
32
33
# File 'lib/instana/frameworks/cuba.rb', line 26

def call!(env)
  env['INSTANA_PATH_TEMPLATE_FRAGMENTS'] = []
  response = super(env)
  env['INSTANA_HTTP_PATH_TEMPLATE'] = env['INSTANA_PATH_TEMPLATE_FRAGMENTS']
    .join('/')
    .gsub(REPLACE_TARGET, '{\k<term>}')
  response
end

#on(*args, &blk) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/instana/frameworks/cuba.rb', line 14

def on(*args, &blk)
  wrapper = lambda do |*caputres|
    env['INSTANA_PATH_TEMPLATE_FRAGMENTS'] << args
      .select { |a| a.is_a?(String) }
      .join('/')

    blk.call(*captures)
  end

  super(*args, &wrapper)
end