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, 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
# 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?



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

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



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

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



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

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.



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.



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

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.



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



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

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.



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

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.



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.



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.



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.



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

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.



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

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.



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

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