Class: StackifyRubyAPM::AgentBaseTransport Private

Inherits:
Object
  • Object
show all
Includes:
Log
Defined in:
lib/stackify_apm/transport/agent_base.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.

This class will take care of building a protobuf message.

Direct Known Subclasses

AgentHTTPClient, UnixSocketClient

Constant Summary

Constants included from Log

Log::PREFIX

Instance Method Summary collapse

Methods included from Log

#debug, #error, #fatal, #info, #log, #warn

Constructor Details

#initialize(config) ⇒ AgentBaseTransport

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 AgentBaseTransport.



11
12
13
14
# File 'lib/stackify_apm/transport/agent_base.rb', line 11

def initialize(config)
  @config = config
  @transaction_serializers = Serializers::Transactions.new(config)
end

Instance Method Details

#build_json_message(transactions = []) ⇒ 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.



41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/stackify_apm/transport/agent_base.rb', line 41

def build_json_message(transactions = [])
  traces = []
  transactions.each do |transaction|
    # convert transaction to json
    json_transaction = @transaction_serializers.build_json(@config, transaction)
    # add to traces array
    traces << json_transaction
  end
  return traces
rescue StandardError => e
  debug "[AgentBaseTransport] build_json_message() exception: #{e.inspect}"
end

#build_message(transactions = []) ⇒ 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.

This method will build a group of Stackify::Traces from the protobuf objects. It accept Array of transactions.



27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/stackify_apm/transport/agent_base.rb', line 27

def build_message(transactions = [])
  # convert transactions to protobuf
  traces = StackifyProtoBuf::Traces.new
  transactions.each do |transaction|
    # convert transaction to protobuf
    protobuf_transaction = @transaction_serializers.build_protobuf(@config, transaction)
    # add to traces array
    traces.traces.push(protobuf_transaction)
  end
  return traces
rescue StandardError => e
  debug "[AgentBaseTransport] build_message() exception: #{e.inspect}"
end

#get_json_message(transactions) ⇒ 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.



21
22
23
# File 'lib/stackify_apm/transport/agent_base.rb', line 21

def get_json_message(transactions)
  JSON.generate(build_json_message(transactions))
end

#get_protobuf_message(transactions) ⇒ 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.



16
17
18
19
# File 'lib/stackify_apm/transport/agent_base.rb', line 16

def get_protobuf_message(transactions)
  protobuf_obj = build_message(transactions)
  StackifyProtoBuf::Traces.encode(protobuf_obj)
end

#post(_transactions = []) ⇒ 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.

Raises:

  • (NotImplementedError)


54
55
56
# File 'lib/stackify_apm/transport/agent_base.rb', line 54

def post(_transactions = [])
  raise NotImplementedError
end