Class: Datadog::DI::Context Private

Inherits:
Object
  • Object
show all
Defined in:
lib/datadog/di/context.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Contains local and instance variables used when evaluating expressions in DI Expression Language.

API:

  • private

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(probe:, settings:, serializer:, locals: nil, target_self: nil, path: nil, caller_locations: nil, serialized_entry_args: nil, return_value: nil, duration: nil, exception: nil) ⇒ Context

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Context.

API:

  • private



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/datadog/di/context.rb', line 10

def initialize(probe:, settings:, serializer:, locals: nil,
  # In Ruby everything is a method, therefore we should always have
  # a target self. However, if we are not capturing a snapshot,
  # there is no need to pass in the target self.
  target_self: nil,
  path: nil, caller_locations: nil,
  serialized_entry_args: nil,
  return_value: nil, duration: nil, exception: nil)
  @probe = probe
  @settings = settings
  @serializer = serializer
  @locals = locals
  @target_self = target_self
  @path = path
  @caller_locations = caller_locations
  @serialized_entry_args = serialized_entry_args
  @return_value = return_value
  @duration = duration
  @exception = exception
end

Instance Attribute Details

#caller_locationsObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

TODO check how many stack frames we should be keeping/sending, this should be all frames for enriched probes and no frames for non-enriched probes?

API:

  • private



43
44
45
# File 'lib/datadog/di/context.rb', line 43

def caller_locations
  @caller_locations
end

#durationObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

How long the method took to execute, for a method probe

API:

  • private



51
52
53
# File 'lib/datadog/di/context.rb', line 51

def duration
  @duration
end

#exceptionObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Exception raised by the method, if any, for a method probe

API:

  • private



54
55
56
# File 'lib/datadog/di/context.rb', line 54

def exception
  @exception
end

#localsObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

API:

  • private



34
35
36
# File 'lib/datadog/di/context.rb', line 34

def locals
  @locals
end

#pathObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Actual path of the instrumented file.

API:

  • private



38
39
40
# File 'lib/datadog/di/context.rb', line 38

def path
  @path
end

#probeObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

API:

  • private



31
32
33
# File 'lib/datadog/di/context.rb', line 31

def probe
  @probe
end

#return_valueObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Return value for the method, for a method probe

API:

  • private



48
49
50
# File 'lib/datadog/di/context.rb', line 48

def return_value
  @return_value
end

#serialized_entry_argsObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

API:

  • private



45
46
47
# File 'lib/datadog/di/context.rb', line 45

def serialized_entry_args
  @serialized_entry_args
end

#serializerObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

API:

  • private



33
34
35
# File 'lib/datadog/di/context.rb', line 33

def serializer
  @serializer
end

#settingsObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

API:

  • private



32
33
34
# File 'lib/datadog/di/context.rb', line 32

def settings
  @settings
end

#target_selfObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

API:

  • private



35
36
37
# File 'lib/datadog/di/context.rb', line 35

def target_self
  @target_self
end

Instance Method Details

#fetch(var_name) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

API:

  • private



63
64
65
66
67
68
69
# File 'lib/datadog/di/context.rb', line 63

def fetch(var_name)
  unless locals
    # TODO return "undefined" instead?
    return nil
  end
  locals[var_name.to_sym]
end

#fetch_ivar(var_name) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

API:

  • private



71
72
73
# File 'lib/datadog/di/context.rb', line 71

def fetch_ivar(var_name)
  target_self.instance_variable_get(var_name)
end

#serialized_localsObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

API:

  • private



56
57
58
59
60
61
# File 'lib/datadog/di/context.rb', line 56

def serialized_locals
  # TODO cache?
  locals && serializer.serialize_vars(locals,
    depth: probe.max_capture_depth || settings.dynamic_instrumentation.max_capture_depth,
    attribute_count: probe.max_capture_attribute_count || settings.dynamic_instrumentation.max_capture_attribute_count,)
end