Class: Datadog::CI::Contrib::Integration

Inherits:
Object
  • Object
show all
Defined in:
lib/datadog/ci/contrib/integration.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.inherited(subclass) ⇒ Object



10
11
12
# File 'lib/datadog/ci/contrib/integration.rb', line 10

def self.inherited(subclass)
  Instrumentation.register_integration(subclass)
end

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?



42
43
44
# File 'lib/datadog/ci/contrib/integration.rb', line 42

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?



58
59
60
# File 'lib/datadog/ci/contrib/integration.rb', line 58

def compatible?
  available?
end

#configurationObject

returns the configuration instance.



71
72
73
# File 'lib/datadog/ci/contrib/integration.rb', line 71

def configuration
  @configuration ||= new_configuration
end

#configure(options = {}, &block) ⇒ Object



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

def configure(options = {}, &block)
  configuration.configure(options, &block)
  configuration
end

#dependantsObject

List of integrations names that depend on this integration. Specify when you might need to automatically instrument other integrations (like test runner for the test framework).



17
18
19
# File 'lib/datadog/ci/contrib/integration.rb', line 17

def dependants
  []
end

#enabledObject



80
81
82
# File 'lib/datadog/ci/contrib/integration.rb', line 80

def enabled
  configuration.enabled
end

#late_instrument?Boolean

Can the patch for this integration be applied automatically?

Returns:

  • (Boolean)

    can the tracer activate this instrumentation without explicit user input?



116
117
118
# File 'lib/datadog/ci/contrib/integration.rb', line 116

def late_instrument?
  false
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?



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

def loaded?
  true
end

#new_configurationDatadog::CI::Contrib::Settings

Returns a new configuration object for this integration.

This method normally needs to be overridden for each integration as their settings, defaults and environment variables are specific for each integration.

Returns:



127
128
129
# File 'lib/datadog/ci/contrib/integration.rb', line 127

def new_configuration
  Datadog::CI::Contrib::Settings.new
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)


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

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

#patched?Boolean

Returns:

  • (Boolean)


110
111
112
# File 'lib/datadog/ci/contrib/integration.rb', line 110

def patched?
  patcher&.patched?
end

#patcherContrib::Patcher

The patcher module to inject instrumented objects into the instrumentation target.

Patcher includes the basic functionality of a patcher. ‘include`ing Patcher into a new module is the recommend way to create a custom patcher.

Returns:



90
91
92
# File 'lib/datadog/ci/contrib/integration.rb', line 90

def patcher
  nil
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



28
29
30
# File 'lib/datadog/ci/contrib/integration.rb', line 28

def version
  nil
end