Class: Watchforge::Transaction
- Inherits:
-
Object
- Object
- Watchforge::Transaction
- Defined in:
- lib/watchforge/tracing.rb
Instance Attribute Summary collapse
-
#op ⇒ Object
readonly
Returns the value of attribute op.
-
#spans ⇒ Object
readonly
Returns the value of attribute spans.
-
#tags ⇒ Object
readonly
Returns the value of attribute tags.
-
#trace_id ⇒ Object
readonly
Returns the value of attribute trace_id.
-
#transaction ⇒ Object
readonly
Returns the value of attribute transaction.
-
#transaction_name ⇒ Object
readonly
Returns the value of attribute transaction_name.
Instance Method Summary collapse
- #finish(status = "ok") ⇒ Object
-
#initialize(client, transaction, transaction_name, op) ⇒ Transaction
constructor
A new instance of Transaction.
- #start_span(op, description = "", data: nil) ⇒ Object
Constructor Details
#initialize(client, transaction, transaction_name, op) ⇒ Transaction
Returns a new instance of Transaction.
50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/watchforge/tracing.rb', line 50 def initialize(client, transaction, transaction_name, op) @client = client @trace_id = SecureRandom.uuid @transaction = transaction @transaction_name = transaction_name || transaction @op = op || "http.server" @spans = [] @tags = {} @start_timestamp = (Time.now.to_f * 1000).to_i @status = "ok" end |
Instance Attribute Details
#op ⇒ Object (readonly)
Returns the value of attribute op.
48 49 50 |
# File 'lib/watchforge/tracing.rb', line 48 def op @op end |
#spans ⇒ Object (readonly)
Returns the value of attribute spans.
48 49 50 |
# File 'lib/watchforge/tracing.rb', line 48 def spans @spans end |
#tags ⇒ Object (readonly)
Returns the value of attribute tags.
48 49 50 |
# File 'lib/watchforge/tracing.rb', line 48 def @tags end |
#trace_id ⇒ Object (readonly)
Returns the value of attribute trace_id.
48 49 50 |
# File 'lib/watchforge/tracing.rb', line 48 def trace_id @trace_id end |
#transaction ⇒ Object (readonly)
Returns the value of attribute transaction.
48 49 50 |
# File 'lib/watchforge/tracing.rb', line 48 def transaction @transaction end |
#transaction_name ⇒ Object (readonly)
Returns the value of attribute transaction_name.
48 49 50 |
# File 'lib/watchforge/tracing.rb', line 48 def transaction_name @transaction_name end |
Instance Method Details
#finish(status = "ok") ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/watchforge/tracing.rb', line 69 def finish(status = "ok") @status = status = (Time.now.to_f * 1000).to_i spans.each { |span| span.finish if span..nil? } payload = { trace_id: trace_id, transaction: transaction, transaction_name: transaction_name, op: op, start_timestamp: Time.at(@start_timestamp / 1000.0).utc.iso8601, finish_timestamp: Time.at( / 1000.0).utc.iso8601, duration_ms: - @start_timestamp, status: @status, environment: @client.instance_variable_get(:@environment), platform: "ruby", sdk_name: SDK_NAME, sdk_version: VERSION, tags: , spans: spans.map(&:to_h) } @client.instance_variable_get(:@transport).send_trace(payload) end |