Class: Sentry::TransactionEvent

Inherits:
Event
  • Object
show all
Defined in:
lib/sentry/transaction_event.rb

Overview

TransactionEvent represents events that carry transaction data (type: “transaction”).

Constant Summary collapse

TYPE =
"transaction"

Constants inherited from Event

Event::MAX_MESSAGE_SIZE_IN_BYTES, Event::SERIALIZEABLE_ATTRIBUTES, Event::SKIP_INSPECTION_ATTRIBUTES, Event::WRITER_ATTRIBUTES

Instance Attribute Summary collapse

Attributes inherited from Event

#attachments, #dynamic_sampling_context, #request

Instance Method Summary collapse

Methods inherited from Event

#level=, #rack_env=, #timestamp=, #to_json_compatible

Constructor Details

#initialize(transaction:, **options) ⇒ TransactionEvent

Returns a new instance of TransactionEvent.



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/sentry/transaction_event.rb', line 20

def initialize(transaction:, **options)
  super(**options)

  self.transaction = transaction.name
  self.transaction_info = { source: transaction.source }
  self.contexts.merge!(transaction.contexts)
  self.contexts.merge!(trace: transaction.get_trace_context)
  self.timestamp = transaction.timestamp
  self.start_timestamp = transaction.start_timestamp
  self.tags = transaction.tags
  self.dynamic_sampling_context = transaction.get_baggage.dynamic_sampling_context
  self.measurements = transaction.measurements

  finished_spans = transaction.span_recorder.spans.select { |span| span.timestamp && span != transaction }
  self.spans = finished_spans.map(&:to_h)

  populate_profile(transaction)
end

Instance Attribute Details

#measurementsHash

Returns:

  • (Hash)


12
13
14
# File 'lib/sentry/transaction_event.rb', line 12

def measurements
  @measurements
end

#profileHash?

Returns:

  • (Hash, nil)


18
19
20
# File 'lib/sentry/transaction_event.rb', line 18

def profile
  @profile
end

#spans<Array[Span]>

Returns:



9
10
11
# File 'lib/sentry/transaction_event.rb', line 9

def spans
  @spans
end

#start_timestampFloat?

Returns:

  • (Float, nil)


15
16
17
# File 'lib/sentry/transaction_event.rb', line 15

def start_timestamp
  @start_timestamp
end

Instance Method Details

#to_hHash

Returns:

  • (Hash)


47
48
49
50
51
52
53
# File 'lib/sentry/transaction_event.rb', line 47

def to_h
  data = super
  data[:spans] = @spans.map(&:to_h) if @spans
  data[:start_timestamp] = @start_timestamp
  data[:measurements] = @measurements
  data
end