Module: Stackdriver::Client::Custom

Included in:
Stackdriver::Client
Defined in:
lib/stackdriver/client/custom.rb

Constant Summary collapse

ENDPOINT =
'v1/custom'.freeze

Instance Method Summary collapse

Instance Method Details

#custom(name, value, collected_at = Time.now.to_i, instance = nil) ⇒ Object



10
11
12
13
14
15
16
17
18
19
# File 'lib/stackdriver/client/custom.rb', line 10

def custom(name, value, collected_at=Time.now.to_i, instance=nil)
  data_point = {
    name:         name,
    value:        value,
    collected_at: collected_at,
    instance:     instance,
  }

  request(:post, ENDPOINT, gateway_message(data_point))
end

#gateway_message(data) ⇒ Object

Wraps the datapoint per doc.



24
25
26
27
28
29
30
# File 'lib/stackdriver/client/custom.rb', line 24

def gateway_message(data)
  {
    data: data,
    timestamp: Time.now.to_i,
    proto_version: 1,
  }
end