Module: TCellAgent::Instrumentation::RouteId

Defined in:
lib/tcell_agent/rails/routes/route_id.rb

Class Method Summary collapse

Class Method Details

.update_context(env, parameters, route) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/tcell_agent/rails/routes/route_id.rb', line 4

def self.update_context(env, parameters, route)
  tcell_context = env[TCellAgent::Instrumentation::TCELL_ID]

  return unless route && tcell_context

  tcell_context.path_parameters = parameters
  route_path = route.path.spec.to_s
  grape_mount_endpoint = nil

  grape_mount_endpoint = route_path if TCellAgent::Instrumentation.grape_route?(route)

  if grape_mount_endpoint
    tcell_context.grape_mount_endpoint = grape_mount_endpoint

  else
    tcell_context.route_id = TCellAgent::SensorEvents::Util.calculate_route_id(
      tcell_context.request_method, route_path
    )
  end
end