Class: DdPostGauge::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/dd_post_gauge/client.rb

Instance Method Summary collapse

Constructor Details

#initialize(api_key: nil, site: nil) ⇒ Client

Returns a new instance of Client.

Parameters:

  • (defaults to: nil)
  • (defaults to: nil)


10
11
12
13
14
15
# File 'lib/dd_post_gauge/client.rb', line 10

def initialize(api_key: nil, site: nil)
  Dotenv.load
  @api_key = api_key || ENV.fetch("DATADOG_API_KEY", nil)
  @site = site || ENV.fetch("DATADOG_SITE", "datadoghq.com")
  configure
end

Instance Method Details

#call(metric_name, value, timestamp: nil, resource_name: nil, type_name: nil) ⇒ void

This method returns an undefined value.

Parameters:

  • (defaults to: nil)
  • (defaults to: nil)
  • (defaults to: nil)


23
24
25
26
27
28
29
30
31
32
33
# File 'lib/dd_post_gauge/client.rb', line 23

def call(metric_name, value, timestamp: nil, resource_name: nil, type_name: nil)
  api_instance.submit_metrics(
    body(
      metric_name,
      value,
      unix_timestamp(timestamp),
      resource_name,
      type_name
    )
  )
end