Class: Codebeacon::Tracer::TraceMetadata

Inherits:
Object
  • Object
show all
Defined in:
lib/codebeacon/tracer/src/data/trace_metadata.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name: nil, description: nil, caller_location: nil, trigger_type: nil) ⇒ TraceMetadata

Returns a new instance of TraceMetadata.



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/codebeacon/tracer/src/data/trace_metadata.rb', line 8

def initialize(name: nil, description: nil, caller_location: nil, trigger_type: nil)
  @name = name
  @description = description
  @start_time = Time.now
  @end_time = nil
  @duration_ms = nil
  @trigger_type = trigger_type
  @language = "ruby"
  
  if caller_location
    capture_caller_info_from_location(caller_location)
  end
end

Instance Attribute Details

#caller_classObject (readonly)

Returns the value of attribute caller_class.



4
5
6
# File 'lib/codebeacon/tracer/src/data/trace_metadata.rb', line 4

def caller_class
  @caller_class
end

#caller_defined_classObject (readonly)

Returns the value of attribute caller_defined_class.



4
5
6
# File 'lib/codebeacon/tracer/src/data/trace_metadata.rb', line 4

def caller_defined_class
  @caller_defined_class
end

#caller_fileObject (readonly)

Returns the value of attribute caller_file.



4
5
6
# File 'lib/codebeacon/tracer/src/data/trace_metadata.rb', line 4

def caller_file
  @caller_file
end

#caller_lineObject (readonly)

Returns the value of attribute caller_line.



4
5
6
# File 'lib/codebeacon/tracer/src/data/trace_metadata.rb', line 4

def caller_line
  @caller_line
end

#caller_methodObject (readonly)

Returns the value of attribute caller_method.



4
5
6
# File 'lib/codebeacon/tracer/src/data/trace_metadata.rb', line 4

def caller_method
  @caller_method
end

#descriptionObject (readonly)

Returns the value of attribute description.



4
5
6
# File 'lib/codebeacon/tracer/src/data/trace_metadata.rb', line 4

def description
  @description
end

#duration_msObject (readonly)

Returns the value of attribute duration_ms.



4
5
6
# File 'lib/codebeacon/tracer/src/data/trace_metadata.rb', line 4

def duration_ms
  @duration_ms
end

#end_timeObject (readonly)

Returns the value of attribute end_time.



4
5
6
# File 'lib/codebeacon/tracer/src/data/trace_metadata.rb', line 4

def end_time
  @end_time
end

#languageObject (readonly)

Returns the value of attribute language.



4
5
6
# File 'lib/codebeacon/tracer/src/data/trace_metadata.rb', line 4

def language
  @language
end

#nameObject (readonly)

Returns the value of attribute name.



4
5
6
# File 'lib/codebeacon/tracer/src/data/trace_metadata.rb', line 4

def name
  @name
end

#start_timeObject (readonly)

Returns the value of attribute start_time.



4
5
6
# File 'lib/codebeacon/tracer/src/data/trace_metadata.rb', line 4

def start_time
  @start_time
end

#trigger_typeObject (readonly)

Returns the value of attribute trigger_type.



4
5
6
# File 'lib/codebeacon/tracer/src/data/trace_metadata.rb', line 4

def trigger_type
  @trigger_type
end

Instance Method Details

#finish_traceObject



22
23
24
25
# File 'lib/codebeacon/tracer/src/data/trace_metadata.rb', line 22

def finish_trace
  @end_time = Time.now
  @duration_ms = ((@end_time - @start_time) * 1000).round(2)
end

#to_hashObject



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/codebeacon/tracer/src/data/trace_metadata.rb', line 27

def to_hash
  {
    name: @name,
    description: @description,
    caller_file: @caller_file,
    caller_method: @caller_method,
    caller_line: @caller_line,
    caller_class: @caller_class,
    caller_defined_class: @caller_defined_class,
    start_time: @start_time,
    end_time: @end_time,
    duration_ms: @duration_ms,
    trigger_type: @trigger_type,
    language: @language
  }
end