Module: SignalFx

Defined in:
lib/signalfx/version.rb,
lib/signalfx.rb

Overview

Copyright © 2015-2020 SignalFx, Inc. All rights reserved.

Defined Under Namespace

Modules: Version

Class Method Summary collapse

Class Method Details

.new(api_token, enable_aws_unique_id: false, ingest_endpoint: RbConfig::DEFAULT_INGEST_ENDPOINT, stream_endpoint: RbConfig::DEFAULT_STREAM_ENDPOINT, timeout: RbConfig::DEFAULT_TIMEOUT, batch_size: RbConfig::DEFAULT_BATCH_SIZE, user_agents: [], logger: Logger.new(STDOUT, progname: "signalfx")) ⇒ Object

SignalFx API client. This class presents a programmatic interface to SignalFx’s metadata and ingest APIs. At the time being, only ingest is supported; more will come later.

Parameters:

  • api_token
    • Your private SignalFx token

  • enable_aws_unique_id (defaults to: false)
    • boolean, ‘false` by default.

    If ‘true`, library will retrieve Amazon unique identifier and set it as `AWSUniqueId` dimension for each datapoint and event. Use this option only if your application deployed to Amazon

  • ingest_endpoint (defaults to: RbConfig::DEFAULT_INGEST_ENDPOINT)
    • string

  • stream_endpoint (defaults to: RbConfig::DEFAULT_STREAM_ENDPOINT)
    • string

  • timeout (defaults to: RbConfig::DEFAULT_TIMEOUT)
    • number

  • batch_size (defaults to: RbConfig::DEFAULT_BATCH_SIZE)
    • number

  • user_agents (defaults to: [])
    • array



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/signalfx.rb', line 23

def self.new(api_token,
             enable_aws_unique_id: false,
             ingest_endpoint: RbConfig::DEFAULT_INGEST_ENDPOINT,
             stream_endpoint: RbConfig::DEFAULT_STREAM_ENDPOINT,
             timeout: RbConfig::DEFAULT_TIMEOUT,
             batch_size: RbConfig::DEFAULT_BATCH_SIZE,
             user_agents: [],
             logger: Logger.new(STDOUT, progname: "signalfx"))
  begin
    require_relative './proto/signal_fx_protocol_buffers.pb'
    ProtoBufSignalFx.new(api_token,
                         enable_aws_unique_id: enable_aws_unique_id,
                         ingest_endpoint: ingest_endpoint,
                         stream_endpoint: stream_endpoint,
                         timeout: timeout,
                         batch_size: batch_size,
                         user_agents: user_agents)

  rescue Exception => e
    logger.warn("Protocol Buffers not installed properly. Switching to JSON.
          #{e}")
    JsonSignalFx.new(api_token,
                     enable_aws_unique_id: enable_aws_unique_id,
                     ingest_endpoint: ingest_endpoint,
                     stream_endpoint: stream_endpoint,
                     timeout: timeout,
                     batch_size: batch_size,
                     user_agents: user_agents)
  end
end