Class: Bigcommerce::Lightstep::Transport
- Inherits:
-
LightStep::Transport::Base
- Object
- LightStep::Transport::Base
- Bigcommerce::Lightstep::Transport
- Defined in:
- lib/bigcommerce/lightstep/transport.rb
Overview
This is a transport that sends reports via HTTP in JSON format. It is thread-safe, however it is not fork-safe. When forking, all items in the queue will be copied and sent in duplicate.
Defined Under Namespace
Classes: InvalidAccessTokenError, Verbosity
Constant Summary collapse
- ENCRYPTION_TLS =
'tls'
- ENCRYPTION_NONE =
'none'
- HEADER_ACCESS_TOKEN =
'LightStep-Access-Token'
- LIGHTSTEP_HOST =
'collector.lightstep.com'
- LIGHTSTEP_PORT =
443
- REPORTS_API_ENDPOINT =
'/api/v0/reports'
- DEFAULT_OPEN_TIMEOUT =
20
- DEFAULT_READ_TIMEOUT =
20
- DEFAULT_KEEPALIVE_TIMEOUT =
2
- DEFAULT_SSL_PORT =
443
Instance Method Summary collapse
-
#initialize(access_token:, host: nil, port: nil, verbose: nil, encryption: nil, ssl_verify_peer: true, ssl_port: nil, open_timeout: nil, read_timeout: nil, continue_timeout: nil, keep_alive_timeout: nil, logger: nil) ⇒ Transport
constructor
Initialize the transport.
-
#report(report) ⇒ NilClass
Queue a report for sending.
Constructor Details
#initialize(access_token:, host: nil, port: nil, verbose: nil, encryption: nil, ssl_verify_peer: true, ssl_port: nil, open_timeout: nil, read_timeout: nil, continue_timeout: nil, keep_alive_timeout: nil, logger: nil) ⇒ Transport
Initialize the transport
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/bigcommerce/lightstep/transport.rb', line 61 def initialize( access_token:, host: nil, port: nil, verbose: nil, encryption: nil, ssl_verify_peer: true, ssl_port: nil, open_timeout: nil, read_timeout: nil, continue_timeout: nil, keep_alive_timeout: nil, logger: nil ) @host = host || LIGHTSTEP_HOST @port = port || LIGHTSTEP_PORT @verbose = verbose || Verbosity::FATAL @encryption = encryption || ENCRYPTION_TLS @ssl_verify_peer = ssl_verify_peer @ssl_port = (ssl_port || DEFAULT_SSL_PORT).to_i @open_timeout = (open_timeout || DEFAULT_OPEN_TIMEOUT).to_i @read_timeout = (read_timeout || DEFAULT_READ_TIMEOUT).to_i @continue_timeout = continue_timeout @keep_alive_timeout = (keep_alive_timeout || DEFAULT_KEEPALIVE_TIMEOUT).to_i @access_token = access_token.to_s default_logger = ::Logger.new($stdout) default_logger.level = ::Logger::INFO @logger = logger || default_logger super() end |
Instance Method Details
#report(report) ⇒ NilClass
Queue a report for sending
99 100 101 102 103 104 105 106 107 108 |
# File 'lib/bigcommerce/lightstep/transport.rb', line 99 def report(report) @logger.info report if @verbose >= Verbosity::INFO req = build_request(report) res = connection.request(req) @logger.info res.to_s if @verbose >= Verbosity::INFO nil end |