Module: Datadog::CI::Contrib::Integration::ClassMethods

Defined in:
lib/datadog/ci/contrib/integration.rb

Overview

Class-level methods for Integration

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?



51
52
53
# File 'lib/datadog/ci/contrib/integration.rb', line 51

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?



67
68
69
# File 'lib/datadog/ci/contrib/integration.rb', line 67

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?



61
62
63
# File 'lib/datadog/ci/contrib/integration.rb', line 61

def loaded?
  true
end

#patchable?Boolean

Can the patch for this integration be applied?

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

Returns:

  • (Boolean)


75
76
77
# File 'lib/datadog/ci/contrib/integration.rb', line 75

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

#register_as(name) ⇒ Object



26
27
28
# File 'lib/datadog/ci/contrib/integration.rb', line 26

def register_as(name)
  Integration.register(self, name)
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



37
38
39
# File 'lib/datadog/ci/contrib/integration.rb', line 37

def version
  nil
end