Skip to content

Optimisation to shrink the agent's footprint: don't require disabled or absent gem based instrumentation code #2844

Open
@fallwith

Description

Most every gem instrumentation's detection code has some top-level lines like so:

require_relative 'widget/instrumentation'
require_relative 'widget/chain'
require_relative 'widget/prepend'

These lines are evaluated by Ruby and cause all of instrumentation logic for the gem to be loaded into the Ruby VM even if the gem does not exist in the customer's tech stack and even if the customer's configuration has explicitly disabled the instrumentation. Essentially some Ruby methods will sit defined but orphaned in the customer's Ruby VM instance.

We can shrink the relevant footprint by moving these require_relative lines either into the existing executes do block within each instrumentation file, or within their own dedicated executes do block. By having the lines live within a block, they will only being executed by Ruby conditionally, based on the instrumentation's depends_on block(s).

We did this recently with the rdkafka gem instrumentation and we should consider doing the same for all gems.

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions