Module: Datadog::Tracing::Contrib::Patchable::ClassMethods

Defined in:
lib/datadog/tracing/contrib/patchable.rb

Overview

Class methods for integrations

Instance Method Summary collapse

Instance Method Details

#available?Boolean

Is the target available to be instrumented? (e.g. gem installed?)

The target doesn't have to be loaded (e.g. require) yet, but needs to be able to be loaded before instrumentation can commence.

By default, #available? checks if #version returned a non-nil object.

If the target for instrumentation has concept of versioning, override #version, otherwise override #available? and implement a custom target presence check.

Returns:

  • (Boolean)

    is the target available for instrumentation in this Ruby environment?



37
38
39
# File 'lib/datadog/tracing/contrib/patchable.rb', line 37

def available?
  !version.nil?
end

#compatible?Boolean

Is this instrumentation compatible with the available target? (e.g. minimum version met?)

Returns:

  • (Boolean)

    is the available target compatible with this instrumentation?



53
54
55
# File 'lib/datadog/tracing/contrib/patchable.rb', line 53

def compatible?
  available?
end

#loaded?Boolean

Is the target loaded into the application? (e.g. gem required? Constant defined?)

The target's objects should be ready to be referenced by the instrumented when loaded returns true.

Returns:

  • (Boolean)

    is the target ready to be referenced during instrumentation?



47
48
49
# File 'lib/datadog/tracing/contrib/patchable.rb', line 47

def loaded?
  true
end

#patchable?Object

Can the patch for this integration be applied?

By default, this is equivalent to #available?, #loaded?, and #compatible? all being truthy.



61
62
63
# File 'lib/datadog/tracing/contrib/patchable.rb', line 61

def patchable?
  available? && loaded? && compatible?
end

#versionObject

Version of the integration target code in the environment.

This is the gem version, when the instrumentation target is a Ruby gem.

If the target for instrumentation has concept of versioning, override #version, otherwise override #available? and implement a custom target presence check.

Returns:

  • (Object)

    the target version



23
24
25
# File 'lib/datadog/tracing/contrib/patchable.rb', line 23

def version
  nil
end