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.

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, entry_capture_expressions: nil, entry_capture_evaluation_errors: 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.



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# 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,
  entry_capture_expressions: nil,
  entry_capture_evaluation_errors: 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
  @entry_capture_expressions = entry_capture_expressions
  @entry_capture_evaluation_errors = entry_capture_evaluation_errors
  @return_value = return_value
  @duration = duration
  @exception = exception
end

Instance Attribute Details

#caller_locations ⇒ Object (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?



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

def caller_locations
  @caller_locations
end

#duration ⇒ Object (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



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

def duration
  @duration
end

#entry_capture_evaluation_errors ⇒ Object (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.



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

def entry_capture_evaluation_errors
  @entry_capture_evaluation_errors
end

#entry_capture_expressions ⇒ Object (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.



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

def entry_capture_expressions
  @entry_capture_expressions
end

#exception ⇒ Object (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



62
63
64
# File 'lib/datadog/di/context.rb', line 62

def exception
  @exception
end

#locals ⇒ Object (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.



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

def locals
  @locals
end

#path ⇒ Object (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.



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

def path
  @path
end

#probe ⇒ Object (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.



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

def probe
  @probe
end

#return_value ⇒ Object (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



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

def return_value
  @return_value
end

#serialized_entry_args ⇒ Object (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.



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

def serialized_entry_args
  @serialized_entry_args
end

#serializer ⇒ Object (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.



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

def serializer
  @serializer
end

#settings ⇒ Object (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.



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

def settings
  @settings
end

#target_self ⇒ Object (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.



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

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.



69
70
71
72
73
74
75
# File 'lib/datadog/di/context.rb', line 69

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.



77
78
79
# File 'lib/datadog/di/context.rb', line 77

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

#serialized_locals ⇒ 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.



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

def serialized_locals
  # TODO cache?
  locals && serializer.serialize_vars(locals, **probe.snapshot_serializer_limits(settings))
end